Compare commits

..

193 commits

Author SHA1 Message Date
Sen
9930d1bb6d
clean up enchantments 2 2025-06-17 23:03:26 +02:00
Sen
38d29ba9c8
clean up enchantments 2025-06-17 22:05:02 +02:00
Sen
89e5775632
add some commands 2025-06-17 15:31:09 +02:00
Sen
a9770ecea1
add god+noclip command, fix completion list bug 2025-06-17 14:27:55 +02:00
Sen
f579eee88b
add magic command, fix arg parser single digit negative numbers getting interpreted as flags 2025-06-17 11:41:25 +02:00
Sen
f7bb1b0fe7
change mob spawners: fix egg collision 2025-06-16 18:23:05 +02:00
Sen
d45a1a8c4a
change mob spawners 2025-06-16 17:58:55 +02:00
Sen
9e5ca9dd95
change key exchange to ED25519 2025-06-16 15:19:07 +02:00
Sen
6afc26e601
change key exchange to ED25519 2025-06-16 15:12:39 +02:00
Sen
256721aa12
cleanup setClientPosition 2025-06-16 11:14:56 +02:00
Sen
431d54f779
cleanup entitybullet 2025-06-16 11:04:56 +02:00
Sen
d0984b143b
cleanup entitybullet comments 2025-06-16 10:53:10 +02:00
Sen
2281e55a09
fix client bullet physics 2025-06-16 10:37:36 +02:00
Sen
d566db0fc5
improve bullet physics 2025-06-16 10:31:48 +02:00
Sen
fcc5e9b640
remove atrributes, rework item modifiers 2025-06-15 20:21:08 +02:00
Sen
339a7679f7
add foxes, complete texture 2025-06-15 13:15:24 +02:00
Sen
ad930fcbdc
add foxes, temp textures 2025-06-15 01:06:10 +02:00
Sen
cdf8db1b50
add exp command, fix game over screen 2025-06-14 13:08:46 +02:00
Sen
8f1fda3f3d
remove internal link 2025-06-13 12:43:41 +02:00
Sen
85028fd82a
clarify license 2025-06-13 12:41:26 +02:00
Sen
1128aa34ab
cleanup entity debug display 2025-06-13 12:34:04 +02:00
Sen
e3edb3be8a
improve @ and ~ commands 2025-06-13 12:01:33 +02:00
Sen
06517a0d34
fix dev mode, add @ cmd 2025-06-13 11:19:29 +02:00
Sen
53a4f5f1a8
allow cancelling character creation 2025-06-13 00:27:03 +02:00
Sen
58163db658
ui scale fix 2025-06-13 00:02:32 +02:00
Sen
17bb2e57ab
fix ui scaling 2025-06-12 21:30:36 +02:00
Sen
836094a00b
more ui improvements 2025-06-12 20:11:59 +02:00
Sen
48918f0139
add various ui improvements 2025-06-12 19:27:41 +02:00
Sen
6d9522c80d
fix imperial time millenia 2025-06-12 14:15:55 +02:00
Sen
83f66723c9
remove xp usage 2025-06-12 13:50:50 +02:00
Sen
47021f9e49
fix flat world floor, replace read/writeState 2025-06-12 12:39:44 +02:00
Sen
1dea7e9645
add item command, remove legacy ids 2025-06-12 12:28:37 +02:00
Sen
678f37e184
improve some instanceof expressions 2025-06-12 10:01:16 +02:00
Sen
9eb5f2cfd3
fix NO_PLAYERS policy completion 2025-06-12 00:27:31 +02:00
Sen
fa94de734b
modify splashes 2025-06-12 00:11:27 +02:00
Sen
22fa5734a3
remove old credits 2025-06-11 23:29:02 +02:00
Sen
1258c07c1b
add evil chickens, fix shouldFlee bug 2025-06-11 23:11:26 +02:00
Sen
46c73c8c46
remove blackened biome from terra 2025-06-11 21:43:16 +02:00
Sen
8c414d53e3
fix font rendering and gui scale (for now) 2025-06-11 21:34:00 +02:00
Sen
7c2ce73de5
remove old font 2025-06-11 18:46:52 +02:00
Sen
6114da126a
fix fonts 2025-06-11 18:42:53 +02:00
Sen
cd7a739c5d
update README 2025-06-09 12:18:23 +02:00
Sen
98cf245b8d
update .gitignore 2025-06-03 09:46:15 +02:00
Sen
166064f21a
remove legacy gradle eclipse plugin 2025-06-03 09:40:45 +02:00
Sen
4a6da6d0f7
add spring water 2025-06-01 17:24:32 +02:00
Sen
1ae189c238
remove skull tile entity 2025-06-01 16:06:08 +02:00
Sen
618a076c0f
remove skull tile entity 2025-06-01 16:02:45 +02:00
Sen
bda91dac26
move banner blocks to new clkaases 2025-06-01 14:54:13 +02:00
Sen
ee3bf79c4c
renme config class, add blocks/items devmode startup check 2025-06-01 14:51:22 +02:00
Sen
141c1b1f5c
add coomand: clear 2025-06-01 13:45:36 +02:00
Sen
81613186e5
change svar implementation 2025-05-31 23:38:49 +02:00
Sen
126ce64a24
change svar implementation 2025-05-31 22:56:43 +02:00
Sen
367e6f5bfd
remove spawn rotation 2025-05-31 21:19:45 +02:00
Sen
c201df68b2
fix npc jumping 2025-05-31 20:27:12 +02:00
Sen
669fc77eab
fix potions 2025-05-31 20:09:23 +02:00
Sen
821a46b720
remove note block tes 2025-05-31 19:57:32 +02:00
Sen
493230c4a6
fix unneccesary debug classes 2025-05-31 18:56:55 +02:00
Sen
5534531416
make guis more generic 2025-05-31 18:38:53 +02:00
Sen
374e0c4617
remove server side debug 2025-05-31 16:46:48 +02:00
Sen
f4c024cde7
fix command system a bit 2025-05-31 14:02:55 +02:00
Sen
35277daca8
fix command default and required params 2025-05-31 10:47:06 +02:00
Sen
6562d18dc1
fix world parser default 2025-05-31 00:53:32 +02:00
Sen
663ef31db9
gradle: fix server console run 2025-05-31 00:47:33 +02:00
Sen
a6c2695ccb
complete login system for now, misc fixes 2025-05-31 00:23:35 +02:00
Sen
06a14ae645
small fixes 2025-05-30 22:12:50 +02:00
Sen
228eec0a79
encryptutil field cleanup 2025-05-30 21:14:35 +02:00
Sen
ec0a1aa5c3
add password hashing and commands 2025-05-30 21:12:59 +02:00
Sen
1b61f085e3
fix exceptions from net handlers, raise rsa key size to 4096 2025-05-30 19:39:54 +02:00
Sen
d1a0847303
cleanup, remove ambient occlusion from models 2025-05-30 18:08:07 +02:00
Sen
8e0bbd06c2
code cleanup: use records where possible 2025-05-30 17:57:14 +02:00
Sen
f30141c8f3
netty cleanup 2025-05-30 13:30:29 +02:00
Sen
c8e5c16e41
fix gradle compile errors 2025-05-30 13:00:33 +02:00
Sen
18be47866c
upgrade to java 21, remove netty unsafe, remove deprecated features 2025-05-30 12:49:37 +02:00
Sen
b14e539464
add key serialization 2025-05-30 01:43:37 +02:00
Sen
be0ab15153
add float scaling 2025-05-29 16:40:33 +02:00
Sen
f3117767fd
add basic scaling 2025-05-29 16:12:19 +02:00
Sen
414dc668ff
add flying types 2025-05-29 15:03:03 +02:00
Sen
b317139c97
fix client window refresh (useless) 2025-05-29 13:55:20 +02:00
Sen
3d0cc9665a
improve client server guis 2025-05-29 13:52:36 +02:00
Sen
18f37874fa
fix acces password server behaviour and default password auth 2025-05-29 12:57:35 +02:00
Sen
902c795ecc
extend and fix pubkeys 2025-05-29 12:51:39 +02:00
Sen
5a394749bf
add pubkey auth 2025-05-29 03:04:44 +02:00
Sen
bdf67a89f7
add server base seed 2025-05-28 18:44:41 +02:00
Sen
252c157cf0
add server base seed 2025-05-28 18:34:02 +02:00
Sen
b01b602728
formatting for compressed data tree 2025-05-28 18:12:28 +02:00
Sen
815c52e5d7
further compressed data tree cleanup 2025-05-28 17:07:33 +02:00
Sen
b52053f5ea
compressed data tree cleanup, streamlining 2025-05-28 13:51:07 +02:00
Sen
f76d3c8b89
change compressed data tree ids and clean up 2025-05-28 11:29:49 +02:00
Sen
6c55d59f1f
cleanup, rename, nbt->cdt "compressed data tree" 2025-05-28 01:11:46 +02:00
Sen
753b4b8b5d
rename tag methods 2025-05-27 22:57:25 +02:00
Sen
c527989ada
locale fix 2025-05-27 22:51:30 +02:00
Sen
8be702b3aa
change nbt format: small fix 2025-05-27 21:57:15 +02:00
Sen
688d5710c7
change nbt format: rename tags package 2025-05-27 21:47:36 +02:00
Sen
47a69ce8bc
change nbt format: change class names 2025-05-27 21:46:30 +02:00
Sen
4433d3b3df
change nbt format: fix visibility 2025-05-27 21:38:31 +02:00
Sen
dda5ac3573
change nbt format: fix method names 2025-05-27 21:34:46 +02:00
Sen
17aad1f023
change nbt format 2025-05-27 21:25:11 +02:00
Sen
ad4949af16
add some commands, fix exception spam, split converter nbt implementation 2025-05-27 14:29:40 +02:00
Sen
2cee1d6632
raise packet compression limit from 2 to 20mb 2025-05-26 23:57:36 +02:00
Sen
435e3f3e29
make access password mandatory 2025-05-26 20:29:08 +02:00
Sen
5f49d6c036
initial crafting registry cleanup (comments) 2025-05-26 17:35:17 +02:00
Sen
4e51e18bdc
add gradle 2025-05-26 17:09:08 +02:00
Sen
bb6ebb0be8
raise version 2025-05-26 14:14:14 +02:00
Sen
fafcf0e0ab
clean history 2025-05-26 14:07:50 +02:00
Sen
adc81d56d2 change port, config and version mechanisms 2025-05-26 13:27:03 +02:00
Sen
f879b060e8 clean data folder history 2025-05-26 11:27:34 +02:00
Sen
ed02e53122 change gitignore 2025-05-26 11:15:17 +02:00
Sen
72df57fb3d change gitignore 2025-05-26 11:13:34 +02:00
Sen
6af3fd71e5 change netty to modified version from initial commit 2025-05-26 11:10:08 +02:00
Sen
d8be274083 add ore min heights 2025-05-25 22:02:31 +02:00
Sen
0b2ad9f92d cleanup 2025-05-25 21:34:16 +02:00
Sen
e66758cd73 add cloud type and skybox enums 2025-05-25 21:32:32 +02:00
Sen
c0369d14b8 fix ore generation height limit 2025-05-25 20:55:53 +02:00
Sen
1d0dfddf25 remove unused import 2025-05-25 20:49:48 +02:00
Sen
a62dc2309d fix audio issues + potential crash 2025-05-25 20:43:52 +02:00
Sen
93d997c3c0 fix window position restoration on client startup 2025-05-25 20:20:46 +02:00
Sen
09149c7b88 update splashes 2025-05-25 20:11:35 +02:00
Sen
f1219070d2 fix invalid chars in splashes 2025-05-25 20:00:30 +02:00
Sen
8fed598b51 Revert "test chunk array perf"
This reverts commit e2ec9f0c84.
2025-05-25 18:41:45 +02:00
Sen
e2ec9f0c84 test chunk array perf 2025-05-25 18:40:34 +02:00
Sen
20abca12f2 remove server stop double logging 2025-05-25 18:33:08 +02:00
Sen
63c2a18c3a fix all logger names 2025-05-25 18:30:12 +02:00
Sen
bb64949927 change logger (netconnection) 2025-05-25 17:59:22 +02:00
Sen
77b5a34a33 downgrade netty to old version to fix annoying network bugs WHYYYYYYYYYYYYYYYYYYYYY?!?!?!?! 2025-05-25 17:53:55 +02:00
Sen
10fdaf0b1a cleanup player controller method names 2025-05-25 15:41:41 +02:00
Sen
2bc84f0c66 cleanup player controller var names 2025-05-25 15:38:12 +02:00
Sen
64b256c713 cleanup player controller comment 2025-05-25 15:27:36 +02:00
Sen
4a84f9e096 format PlayerController 2025-05-25 15:26:14 +02:00
Sen
2cf7f0036d cleanup player controller comments 2025-05-25 15:25:38 +02:00
Sen
d41ad4db01 change fire type behaviour 2025-05-25 15:04:14 +02:00
Sen
7299ab8e5c general Block* code cleanup 2025-05-25 14:45:04 +02:00
Sen
7fd8879c73 general Block* code cleanup 2025-05-25 12:13:15 +02:00
Sen
8bd9370bab make larger crafting grids possible 2025-05-25 00:10:02 +02:00
Sen
aa0ff6cf96 code cleanup 2025-05-24 21:24:13 +02:00
Sen
d6d934f1f3 small network code cleanup 2025-05-24 20:42:53 +02:00
Sen
bd4b8d427a network code cleanup 2025-05-24 20:38:49 +02:00
Sen
1eefb197f0 rename biome packet 2025-05-24 18:49:50 +02:00
Sen
ffca1f62e5 change biome packet 2025-05-24 18:49:24 +02:00
Sen
88c43d0824 Merge branch 'master' into chunk-intmap 2025-05-24 18:19:21 +02:00
Sen
71e50743fd split chunk class into server and client 2025-05-24 18:18:04 +02:00
Sen
7126ca5a9f add soul+black fire 2025-05-24 11:46:37 +02:00
Sen
0055cbf806 remove some old comments 2025-05-23 09:36:57 +02:00
Sen
41fae1317f network bug workaround test 2025-05-21 18:45:45 +02:00
Sen
f6b2fdf422 fix entity void height 2025-05-21 16:50:59 +02:00
Sen
688522c5ca change view distance default to 8 2025-05-21 16:35:37 +02:00
Sen
272392c8ea change world floor and ceiling to filler an optional flag 2025-05-21 16:32:28 +02:00
Sen
dfa5026a29 cap chunk height check in worldgen 2025-05-21 15:49:02 +02:00
Sen
2dd83c61dc make chunk storage a map 2025-05-21 15:31:50 +02:00
Sen
5e2b36dc82 fix chunk y rendering 2025-05-21 14:31:29 +02:00
Sen
26c71df542 misc fixes, rendering 2025-05-21 13:51:51 +02:00
Sen
7b6cff41c5 fix bottom filler 2025-05-21 12:15:13 +02:00
Sen
c62e3386aa change entity kill height 2025-05-21 12:08:58 +02:00
Sen
7fd8a49d5c initial bugfix for taller chunks 2025-05-21 12:04:28 +02:00
Sen
4d1d323c72 Revert "make world taller"
This reverts commit caef42dc16.
2025-05-20 19:09:19 +02:00
Sen
caef42dc16 make world taller 2025-05-20 19:06:37 +02:00
Sen
3a5a29cf9e replace ChunkPos with LongHashMap#get(X|Z) in WorldClient 2025-05-20 12:19:18 +02:00
Sen
e6d16405c5 remove client world no chunks check, misc 2025-05-20 11:59:51 +02:00
Sen
31dd9d6303 add dummy display chunks 2025-05-20 11:51:35 +02:00
Sen
e145675525 miscellanious fixes 2025-05-19 22:15:06 +02:00
Sen
7c80936c05 fix rain+hail texture and empty chunk 2025-05-19 20:46:04 +02:00
Sen
a7fe2db49f change flying npc players not permananetly flying 2025-05-18 20:18:44 +02:00
Sen
89d2c8f6e4 fix npc sneaking 2025-05-18 19:51:32 +02:00
Sen
9a6c41661b fix server startup time measurement 2025-05-18 18:47:20 +02:00
Sen
5066ddf9af raise RSA key size 1024 -> 2048 2025-05-18 18:40:37 +02:00
Sen
5b6bb3f10d remove unused EncryptUtil methods, rename 2025-05-18 17:49:01 +02:00
Sen
5b2a51a8b5 remove unused EncryptUtil methods, rename 2025-05-18 17:46:15 +02:00
Sen
8d4b4b3619 add encryption and enforce authentication 2025-05-18 17:39:22 +02:00
Sen
2ea3267e3a split text fields 2025-05-18 14:30:35 +02:00
Sen
9077451c08 add registration via command, password fields 2025-05-15 21:25:28 +02:00
Sen
e4034898b9 remove server ipc and preloading 2025-05-14 16:01:08 +02:00
Sen
660199b1d8 misc refactoring 2 2025-05-14 15:45:27 +02:00
Sen
10ba39c70b misc refactoring 2025-05-14 15:12:11 +02:00
Sen
eba8f6ea98 login + network changes, add forms 2025-05-14 14:58:06 +02:00
Sen
111226fe28 move worldgen to server 2025-05-14 00:37:46 +02:00
Sen
e26938ee77 biome split temp commit 2025-05-13 18:31:28 +02:00
Sen
6d1e00ddef fix server copy password 2025-05-13 17:34:21 +02:00
Sen
a3e8566ca2 move clipboard classes 2025-05-13 17:19:40 +02:00
Sen
6e77090c5b server client split world classes 2025-05-13 17:02:57 +02:00
Sen
66e9f68eee move attributes 2025-05-13 14:39:09 +02:00
Sen
1578d22e46 specify client and server 2025-05-12 19:13:37 +02:00
Sen
95b5d0e3e3 move converter to server 2025-05-12 18:52:03 +02:00
Sen
f89724e2aa Revert "split entity ai to server #1"
This reverts commit 02c0bfcbf6.
2025-05-12 18:48:16 +02:00
Sen
d8e54d4d69 Revert "split entity ai to server #2+"
This reverts commit ad828ec6b4.
2025-05-12 18:48:05 +02:00
Sen
541b9cc461 Revert "Revert "add windows support (untested)""
This reverts commit 2158a700f4.
2025-05-12 18:47:43 +02:00
Sen
2158a700f4 Revert "add windows support (untested)"
This reverts commit 6e5c9e842e.
2025-05-12 18:46:07 +02:00
Sen
ad828ec6b4 split entity ai to server #2+ 2025-05-12 18:28:56 +02:00
Sen
02c0bfcbf6 split entity ai to server #1 2025-05-10 00:02:02 +02:00
Sen
6e5c9e842e add windows support (untested) 2025-05-09 13:26:31 +02:00
Sen
f1a13835a6 revert gitignore 2025-05-08 13:05:44 +02:00
Sen
49996f8116 fix gitignore 2025-05-08 13:04:57 +02:00
Sen
812a981e4a rename Game -> Client 2025-05-08 13:03:36 +02:00
Sen
193a12b00f net client 2025-05-08 13:00:17 +02:00
Sen
6b7923cf41 move packages 2025-05-08 12:37:48 +02:00
3236 changed files with 74910 additions and 35644 deletions

12
.gitattributes vendored Normal file
View file

@ -0,0 +1,12 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf
# These are Windows script files and should use crlf
*.bat text eol=crlf
# Binary files should be left untouched
*.jar binary

16
.gitignore vendored
View file

@ -1,8 +1,8 @@
/common/dev /dev
/common/bin .metadata
/client/bin .classpath
/client/run .project
/server/bin .settings
/server/run .gradle
/export bin
/.metadata build

View file

@ -1,3 +1,8 @@
# TCR # TCR - That Cube Rocks
Ein Minecraft®™ 1.8.9 "Fork" Ein Block-basiertes Open-World-Spiel mit vielen Dimensionen und RPG-Elementen.
**Projekt ist in der frühen Entwicklungsphase / Alpha**
Dieses Projekt ist Public Domain, siehe UNLICENSE.
Der Client verwendet LWJGL für GLFW und OpenGL, für dessen Lizenz siehe [Die LWJGL Website](https://www.lwjgl.org/license).

47
client/build.gradle.kts Normal file
View file

@ -0,0 +1,47 @@
plugins {
application
id("com.gradleup.shadow") version "8.3.6"
}
repositories {
mavenCentral()
}
dependencies {
implementation(project(":common"))
implementation(platform("org.lwjgl:lwjgl-bom:3.3.6"))
implementation("org.lwjgl", "lwjgl")
implementation("org.lwjgl", "lwjgl-glfw")
implementation("org.lwjgl", "lwjgl-opengl")
runtimeOnly("org.lwjgl", "lwjgl", classifier = "natives-linux")
runtimeOnly("org.lwjgl", "lwjgl", classifier = "natives-freebsd")
runtimeOnly("org.lwjgl", "lwjgl", classifier = "natives-windows")
runtimeOnly("org.lwjgl", "lwjgl-glfw", classifier = "natives-linux")
runtimeOnly("org.lwjgl", "lwjgl-glfw", classifier = "natives-freebsd")
runtimeOnly("org.lwjgl", "lwjgl-glfw", classifier = "natives-windows")
runtimeOnly("org.lwjgl", "lwjgl-opengl", classifier = "natives-linux")
runtimeOnly("org.lwjgl", "lwjgl-opengl", classifier = "natives-freebsd")
runtimeOnly("org.lwjgl", "lwjgl-opengl", classifier = "natives-windows")
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
application {
mainClass = "client.Client"
tasks.run.get().workingDir = rootProject.file("dev/client")
tasks.run.get().workingDir.mkdirs()
tasks.run.get().systemProperties.put("runtime.devmode", "")
}
tasks.shadowJar {
destinationDirectory = rootProject.file("dev")
archiveFileName = "tcr_client.jar"
}

View file

@ -1,603 +0,0 @@
package client;
import client.network.ClientPlayer;
import common.block.Block;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.init.BlockRegistry;
import common.init.EntityRegistry;
import common.item.ItemBlock;
import common.item.ItemControl;
import common.item.ItemStack;
import common.material.Material;
import common.packet.CPacketAction;
import common.packet.CPacketBreak;
import common.packet.CPacketClick;
import common.packet.CPacketPlace;
import common.sound.PositionedSound;
import common.world.BlockPos;
import common.world.Facing;
import common.world.State;
import common.world.Vec3;
import common.world.World;
import common.world.WorldClient;
public class PlayerController
{
private final Game gm;
private final ClientPlayer netClientHandler;
private BlockPos currentBlock = new BlockPos(-1, -1, -1);
private ItemStack currentItemHittingBlock;
private float curBlockDamageMP;
private float stepSoundTickCounter;
private int blockHitDelay;
private boolean isHittingBlock;
private boolean noclip;
private int currentPlayerItem;
private boolean interacting;
public PlayerController(Game gmIn, ClientPlayer netHandler)
{
this.gm = gmIn;
this.netClientHandler = netHandler;
}
// public static void clickBlockCreative(Game gmIn, PlayerController playerController, BlockPos pos, Facing facing)
// {
// if (!gmIn.theWorld.extinguishFire(gmIn.thePlayer, pos, facing))
// {
// playerController.onPlayerDestroyBlock(pos, facing);
// }
// }
// public void setPlayerCapabilities()
// {
// this.gm.thePlayer.flying &= this.gm.thePlayer.hasEffect(Potion.flying) || this.gm.thePlayer.noclip;
// }
// public boolean isNoclip()
// {
// return this.gm.thePlayer.capabilities.noClip;
// }
// public void setNoclip(boolean noclip)
// {
// this.noclip = noclip;
// }
// public void setCheat(boolean cheat)
// {
// this.cheat = cheat;
// this.setPlayerCapabilities();
// }
// public boolean shouldDrawHUD()
// {
// return !this.creative;
// }
/**
* Called when a player completes the destruction of a block
*/
public boolean onPlayerDestroyBlock(BlockPos pos, Facing side)
{
// if (this.gamemode.isAdventure())
// {
// if (this.gamemode == Gamemode.SPECTATOR)
// {
// return false;
// }
// if (!this.gm.thePlayer.isAllowEdit())
// {
// Block block = this.gm.theWorld.getBlockState(pos).getBlock();
// ItemStack itemstack = this.gm.thePlayer.getCurrentEquippedItem();
//
// if (itemstack == null)
// {
// return false;
// }
//
// if (!itemstack.canDestroy(block))
// {
// return false;
// }
// }
// }
// if (this.gm.thePlayer.getHeldItem() != null && !this.gm.thePlayer.getHeldItem().getItem().canBreakBlocks())
// {
// return false;
// }
// else
// {
World world = this.gm.theWorld;
State iblockstate = world.getState(pos);
Block block1 = iblockstate.getBlock();
if (block1.getMaterial() == Material.air)
{
return false;
}
else
{
world.playAuxSFX(2001, pos, BlockRegistry.getStateId(iblockstate));
boolean flag = world.setBlockToAir(pos);
if (flag)
{
block1.onBlockDestroyedByPlayer(world, pos, iblockstate);
}
this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());
// if (!this.creative)
// {
ItemStack itemstack1 = this.gm.thePlayer.getCurrentEquippedItem();
if (itemstack1 != null)
{
itemstack1.onBlockDestroyed(world, block1, pos, this.gm.thePlayer);
if (itemstack1.stackSize == 0)
{
this.gm.thePlayer.destroyCurrentEquippedItem();
}
}
// }
return flag;
}
// }
}
/**
* Called when the player is hitting a block with an item.
*/
public boolean clickBlock(BlockPos loc, Facing face)
{
// if (this.gamemode.isAdventure())
// {
// if (this.gamemode == Gamemode.SPECTATOR)
// {
// return false;
// }
// if (!this.gm.thePlayer.isAllowEdit())
// {
// Block block = this.gm.theWorld.getBlockState(loc).getBlock();
// ItemStack itemstack = this.gm.thePlayer.getCurrentEquippedItem();
//
// if (itemstack == null)
// {
// return false;
// }
//
// if (!itemstack.canDestroy(block))
// {
// return false;
// }
// }
// }
if (!World.isValidXZ(loc))
{
return false;
}
else
{
ItemStack stack = this.gm.thePlayer.getHeldItem();
if(stack != null && stack.getItem().onAction(stack, this.gm.thePlayer, this.gm.theWorld, ItemControl.PRIMARY, loc)) {
this.interacting = true;
this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, loc, face));
return true;
}
// if (this.creative)
// {
// this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, loc, face));
// clickBlockCreative(this.gm, this, loc, face);
// this.blockHitDelay = 5;
// }
// else
if (!this.isHittingBlock || !this.isHittingPosition(loc))
{
if (this.isHittingBlock)
{
this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.currentBlock, face));
}
this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, loc, face));
Block block1 = this.gm.theWorld.getState(loc).getBlock();
boolean flag = block1.getMaterial() != Material.air;
if (flag && this.curBlockDamageMP == 0.0F)
{
block1.onBlockClicked(this.gm.theWorld, loc, this.gm.thePlayer);
}
if (flag && block1.getPlayerRelativeBlockHardness(this.gm.thePlayer, this.gm.thePlayer.worldObj, loc) >= 1.0F)
{
this.onPlayerDestroyBlock(loc, face);
// if(this.cheat && block1.getPlayerRelativeBlockHardness(this.gm.thePlayer, this.gm.thePlayer.worldObj, loc) < 1.0F)
this.blockHitDelay = 3;
}
else
{
this.isHittingBlock = true;
this.currentBlock = loc;
this.currentItemHittingBlock = this.gm.thePlayer.getHeldItem();
this.curBlockDamageMP = 0.0F;
this.stepSoundTickCounter = 0.0F;
this.gm.theWorld.sendBlockBreakProgress(this.gm.thePlayer.getId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
}
}
return true;
}
}
/**
* Resets current block damage and isHittingBlock
*/
public void resetBlockRemoving()
{
if (this.isHittingBlock)
{
this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.currentBlock, Facing.DOWN));
this.isHittingBlock = false;
this.curBlockDamageMP = 0.0F;
this.gm.theWorld.sendBlockBreakProgress(this.gm.thePlayer.getId(), this.currentBlock, -1);
}
}
public void resetInteraction()
{
this.interacting = false;
}
public boolean onPlayerDamageBlock(BlockPos posBlock, Facing directionFacing)
{
if(this.interacting)
return false;
this.syncCurrentPlayItem();
if (this.blockHitDelay > 0)
{
--this.blockHitDelay;
return true;
}
// else if (this.creative && World.isValidXZ(posBlock))
// {
// this.blockHitDelay = 5;
// this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, posBlock, directionFacing));
// clickBlockCreative(this.gm, this, posBlock, directionFacing);
// return true;
// }
else if (this.isHittingPosition(posBlock))
{
Block block = this.gm.theWorld.getState(posBlock).getBlock();
if (block.getMaterial() == Material.air)
{
this.isHittingBlock = false;
return false;
}
else
{
this.curBlockDamageMP += block.getPlayerRelativeBlockHardness(this.gm.thePlayer, this.gm.thePlayer.worldObj, posBlock);
if (this.stepSoundTickCounter % 4.0F == 0.0F && block.sound.getStepSound() != null)
{
this.gm.getSoundManager().playSound(new PositionedSound(block.sound.getStepSound(), 0.25F, /* block.sound.getFrequency() * 0.5F, */ (float)posBlock.getX() + 0.5F, (float)posBlock.getY() + 0.5F, (float)posBlock.getZ() + 0.5F));
}
++this.stepSoundTickCounter;
if (this.curBlockDamageMP >= 1.0F)
{
this.isHittingBlock = false;
this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.STOP_DESTROY_BLOCK, posBlock, directionFacing));
this.onPlayerDestroyBlock(posBlock, directionFacing);
this.curBlockDamageMP = 0.0F;
this.stepSoundTickCounter = 0.0F;
this.blockHitDelay = 5;
}
this.gm.theWorld.sendBlockBreakProgress(this.gm.thePlayer.getId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
return true;
}
}
else
{
return this.clickBlock(posBlock, directionFacing);
}
}
// /**
// * player reach distance = 4F
// */
// public float getBlockReachDistance()
// {
// return ;
// }
public void updateController()
{
this.syncCurrentPlayItem();
if (this.netClientHandler.getNetworkManager().isChannelOpen())
{
this.netClientHandler.getNetworkManager().processReceivedPackets();
}
else
{
this.netClientHandler.getNetworkManager().checkDisconnected();
}
}
private boolean isHittingPosition(BlockPos pos)
{
ItemStack itemstack = this.gm.thePlayer.getHeldItem();
boolean flag = this.currentItemHittingBlock == null && itemstack == null;
if (this.currentItemHittingBlock != null && itemstack != null)
{
flag = itemstack.getItem() == this.currentItemHittingBlock.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.currentItemHittingBlock) && (itemstack.isItemStackDamageable() || itemstack.getMetadata() == this.currentItemHittingBlock.getMetadata());
}
return pos.equals(this.currentBlock) && flag;
}
/**
* Syncs the current player item with the server
*/
private void syncCurrentPlayItem()
{
int i = this.gm.thePlayer.inventory.currentItem;
if (i != this.currentPlayerItem)
{
this.currentPlayerItem = i;
this.netClientHandler.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ITEMSLOT, this.currentPlayerItem));
}
}
public boolean onPlayerRightClick(EntityNPC player, WorldClient worldIn, ItemStack heldStack, BlockPos hitPos, Facing side, Vec3 hitVec)
{
this.syncCurrentPlayItem();
float f = (float)(hitVec.xCoord - (double)hitPos.getX());
float f1 = (float)(hitVec.yCoord - (double)hitPos.getY());
float f2 = (float)(hitVec.zCoord - (double)hitPos.getZ());
boolean flag = false;
if (!World.isValidXZ(hitPos))
{
return false;
}
else
{
if(heldStack == null || !heldStack.getItem().onAction(heldStack, player, worldIn, ItemControl.SECONDARY, hitPos)) {
// if (this.gamemode != Gamemode.SPECTATOR)
// {
State iblockstate = worldIn.getState(hitPos);
if ((!player.isSneaking() || player.getHeldItem() == null) // && (player.getHeldItem() == null || !player.getHeldItem().getItem().ignoresBlocks())
&& iblockstate.getBlock().onBlockActivated(worldIn, hitPos, iblockstate, player, side, f, f1, f2))
{
flag = true;
}
if (!flag && heldStack != null && heldStack.getItem() instanceof ItemBlock)
{
ItemBlock itemblock = (ItemBlock)heldStack.getItem();
if (!itemblock.canPlaceBlockOnSide(worldIn, hitPos, side, player, heldStack))
{
return false;
}
}
// }
}
else {
heldStack.getItem().onItemUse(heldStack, player, worldIn, hitPos, side, f, f1, f2);
flag = true;
}
this.netClientHandler.addToSendQueue(new CPacketPlace(hitPos, side.getIndex(), player.inventory.getCurrentItem(), f, f1, f2));
if (!flag) // && this.gamemode != Gamemode.SPECTATOR)
{
if (heldStack == null)
{
return false;
}
// else if (this.creative)
// {
// int i = heldStack.getMetadata();
// int j = heldStack.stackSize;
// boolean flag1 = heldStack.onItemUse(player, worldIn, hitPos, side, f, f1, f2);
// heldStack.setItemDamage(i);
// heldStack.stackSize = j;
// return flag1;
// }
else
{
return heldStack.onItemUse(player, worldIn, hitPos, side, f, f1, f2);
}
}
else
{
return true;
}
}
}
/**
* Notifies the server of things like consuming food, etc...
*/
public boolean sendUseItem(EntityNPC playerIn, World worldIn, ItemStack itemStackIn)
{
// if (this.gamemode == Gamemode.SPECTATOR)
// {
// return false;
// }
// else
// {
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new CPacketPlace(playerIn.inventory.getCurrentItem()));
int i = itemStackIn.stackSize;
ItemStack itemstack = itemStackIn.useItemRightClick(worldIn, playerIn);
if (itemstack != itemStackIn || itemstack != null && itemstack.stackSize != i)
{
playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = itemstack;
if (itemstack.stackSize == 0)
{
playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = null;
}
return true;
}
else
{
return false;
}
// }
}
public EntityNPC createPlayerEntity(WorldClient worldIn, int type)
{
EntityNPC player = (EntityNPC)EntityRegistry.createEntityByID(type, worldIn);
player.setClientPlayer(this.gm, this.netClientHandler);
return player;
}
/**
* Attacks an entity
*/
public void attackEntity(EntityNPC playerIn, Entity targetEntity)
{
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new CPacketAction(CPacketAction.Action.ATTACK, targetEntity.getId()));
// if (this.gamemode != Gamemode.SPECTATOR)
// {
playerIn.attackTargetEntityWithCurrentItem(targetEntity);
// }
}
/**
* Send packet to server - player is interacting with another entity (left click)
*/
public boolean interactWithEntitySendPacket(EntityNPC playerIn, Entity targetEntity)
{
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new CPacketAction(CPacketAction.Action.INTERACT, targetEntity.getId()));
return /* this.gamemode != Gamemode.SPECTATOR && */ playerIn.interactWith(targetEntity);
}
// /**
// * Return true when the player rightclick on an entity
// *
// * @param player The player's instance
// * @param entityIn The entity clicked
// * @param movingObject The object clicked
// */
// public boolean isPlayerRightClickingOnEntity(EntityNPC player, Entity entityIn, MovingObjectPosition movingObject)
// {
// this.syncCurrentPlayItem();
// Vec3 vec3 = new Vec3(movingObject.hitVec.xCoord - entityIn.posX, movingObject.hitVec.yCoord - entityIn.posY, movingObject.hitVec.zCoord - entityIn.posZ);
// this.netClientHandler.addToSendQueue(new C02PacketUseEntity(entityIn, vec3));
// return this.gamemode != Gamemode.SPECTATOR && entityIn.interactAt(player, vec3);
// }
/**
* Handles slot clicks sends a packet to the server.
*/
public ItemStack windowClick(int windowId, int slotId, int mouseButtonClicked, int mode, EntityNPC playerIn)
{
short short1 = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
ItemStack itemstack = playerIn.openContainer.slotClick(slotId, mouseButtonClicked, mode, playerIn);
this.netClientHandler.addToSendQueue(new CPacketClick(windowId, slotId, mouseButtonClicked, mode, itemstack, short1));
return itemstack;
}
/**
* GuiEnchantment uses this during multiplayer to tell PlayerControllerMP to send a packet indicating the
* enchantment action the player has taken.
*
* @param windowID The ID of the current window
* @param button The button id (enchantment selected)
*/
public void sendEnchantPacket(int windowID, int button)
{
this.netClientHandler.addToSendQueue(new CPacketAction(CPacketAction.Action.ENCHANT_ITEM, windowID | (button << 8)));
}
// /**
// * Used in PlayerControllerMP to update the server with an ItemStack in a slot.
// */
// public void sendCheatPacket(ItemStack itemStackIn, boolean full)
// {
// }
// /**
// * Sends a Packet107 to the server to drop the item on the ground
// */
// public void sendPacketDropItem(ItemStack itemStackIn)
// {
// if (this.creative && itemStackIn != null)
// {
// this.netClientHandler.addToSendQueue(new CPacketCreative(-1, itemStackIn));
// }
// }
public void onStoppedUsingItem(EntityNPC playerIn)
{
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Facing.DOWN));
playerIn.stopUsingItem();
}
// /**
// * Checks if the player is not creative, used for checking if it should break a block instantly
// */
// public boolean isNotCreative()
// {
// return !this.creative;
// }
// /**
// * returns true if player is in creative mode
// */
// public boolean isCreative()
// {
// return this.creative;
// }
// /**
// * Checks if the player is riding a horse, used to chose the GUI to open
// */
// public boolean isRidingHorse()
// {
// return ;
// }
// public Gamemode getGamemode()
// {
// return this.gamemode;
// }
/**
* Return isHittingBlock
*/
public boolean getIsHittingBlock()
{
return this.isHittingBlock;
}
}

View file

@ -1,30 +0,0 @@
package client;
public class Timing {
public static long tmr_timer;
public static long tmr_start;
public static long tmr_current;
public static long tmr_last;
public static long tmr_delta;
public static long tmr_update;
public static long tmr_frames;
public static long tmr_iters;
public static long tick_torun;
public static long tick_done;
public static long tick_total;
public static long tick_time;
public static long tick_stime;
public static long tick_ftime;
public static long tick_ttime;
public static long tick_update;
public static double tick_fraction;
public static float framerate;
public static float tickrate;
public static float fdelta;
public static int tickTarget;
public static int tickFrame;
}

View file

@ -1,268 +0,0 @@
package client.gui;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode;
import client.gui.element.GuiList;
import client.gui.element.ListEntry;
import client.gui.element.NavButton;
import client.renderer.Drawing;
import common.color.TextColor;
import common.init.Config;
import common.log.Log;
import common.network.IPlayer;
import common.util.FileUtils;
import common.util.Tuple;
import common.util.Util;
public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements ActButton.Callback {
public class ServerInfo implements Comparable<ServerInfo>, ListEntry {
private String name;
private String address;
private int port;
private String user;
private String password;
private String access;
private long lastConnected;
public ServerInfo(String name, String address, int port, String user, String password, String access, long lastConnected) {
this.name = name;
this.address = address;
this.port = port;
this.user = user;
this.password = password;
this.access = access;
this.lastConnected = lastConnected;
}
public String getName() {
return this.name;
}
public String getAddress() {
return this.address;
}
public int getPort() {
return this.port;
}
public String getUser() {
return this.user;
}
public String getPassword() {
return this.password;
}
public String getAccess() {
return this.access;
}
public long getLastConnected() {
return this.lastConnected;
}
public void setData(String name, String address, int port, String user, String password, String access) {
this.name = name;
this.address = address;
this.port = port;
this.user = user;
this.password = password;
this.access = access;
}
public void setLastConnected() {
this.lastConnected = System.currentTimeMillis();
}
public int compareTo(ServerInfo comp) {
return this.lastConnected < comp.lastConnected ? 1 : (this.lastConnected > comp.lastConnected ? -1 : this.name.compareTo(comp.name));
}
public void select(boolean isDoubleClick, int mouseX, int mouseY) {
GuiConnect.this.selectButton.enabled = true;
GuiConnect.this.deleteButton.enabled = true;
GuiConnect.this.editButton.enabled = true;
GuiConnect.this.copyButton.enabled = true;
if(isDoubleClick) {
GuiConnect.this.use(GuiConnect.this.selectButton, Mode.PRIMARY);
}
}
public void draw(int x, int y, int mouseXIn, int mouseYIn, boolean hover) {
Drawing.drawText(this.name + TextColor.GRAY + " - " + TextColor.RESET + this.user, x + 2, y, 0xffffffff);
Drawing.drawText(this.address + TextColor.GRAY + " Port " + TextColor.RESET + this.port, x + 2, y + 18, 0xff808080);
Drawing.drawText("Zuletzt verbunden: " + (this.lastConnected == -1L ? "nie" : DATE_FORMAT.format(new Date(this.lastConnected))), x + 2, y + 18 + 16, 0xff808080);
}
}
public static final GuiConnect INSTANCE = new GuiConnect();
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
private static final File SERVERS_FILE = new File("servers.cfg");
private ActButton deleteButton;
private ActButton selectButton;
private ActButton copyButton;
private ActButton editButton;
private ActButton createButton;
private GuiConnect() {
}
public void init(int width, int height) {
super.init(width, height);
this.setDimensions(width, height, 32, height - 32);
this.elements.clear();
if(SERVERS_FILE.exists()) {
try {
String[] lines = FileUtils.read(SERVERS_FILE).split("\n");
String name = "";
String address = "";
int port = -1;
String user = "";
String password = "";
String access = "";
long time = -1L;
for(int z = 0; z <= lines.length; z++) {
String line = z == lines.length ? null : lines[z];
if(line == null || (line.startsWith("[") && line.endsWith("]"))) {
if(!name.isEmpty() && !address.isEmpty() && !user.isEmpty() && user.length() < IPlayer.MAX_USER_LENGTH && IPlayer.isValidUser(user) && password.length() < IPlayer.MAX_PASS_LENGTH && access.length() < IPlayer.MAX_PASS_LENGTH && address.length() < 128 && name.length() < 128 && port >= 0 && port < 65536)
this.elements.add(new ServerInfo(name, address, port, user, password, access, time));
if(line != null) {
address = "";
port = -1;
user = "";
password = "";
access = "";
time = -1L;
name = line.substring(1, line.length() - 1);
}
}
else {
Tuple<String, String> value = Util.getKeyValue(line);
if(value.first.equals("address"))
address = value.second;
else if(value.first.equals("port"))
try {
port = Integer.parseInt(value.second);
}
catch(NumberFormatException e) {
}
else if(value.first.equals("user"))
user = value.second;
else if(value.first.equals("password"))
password = value.second;
else if(value.first.equals("access"))
access = value.second;
else if(value.first.equals("connected"))
try {
time = Long.parseLong(value.second);
}
catch(NumberFormatException e) {
}
}
}
Collections.sort(this.elements);
}
catch(Exception e) {
Log.IO.error("Konnte Serverliste nicht laden", e);
this.elements.clear();
}
}
this.add(this.selectButton = new ActButton(width / 2 - 383, height - 28, 150, 24, this, "Verbinden"));
this.add(this.createButton = new ActButton(width - 204, 4, 200, 24, this, "Server hinzufügen ..."));
this.add(this.deleteButton = new ActButton(width / 2 - 75, height - 28, 150, 24, this, "Löschen"));
this.add(this.editButton = new ActButton(width / 2 + 79, height - 28, 150, 24, this, "Bearbeiten"));
this.add(this.copyButton = new ActButton(width / 2 - 229, height - 28, 150, 24, this, "Kopieren"));
this.add(new NavButton(4, 4, 200, 24, GuiServer.INSTANCE, "Schnellverbindung ..."));
this.add(new NavButton(width / 2 + 233, height - 28, 150, 24, GuiMenu.INSTANCE, "Abbrechen"));
this.selectButton.enabled = false;
this.deleteButton.enabled = false;
this.editButton.enabled = false;
this.copyButton.enabled = false;
}
public void onGuiClosed() {
this.save();
}
public void applyServer(ServerInfo server) {
if(this.selectedElement < 0)
this.elements.add(server);
this.save();
this.gm.displayGuiScreen(this);
}
private void save() {
try {
StringBuilder sb = new StringBuilder();
for(ServerInfo server : this.elements) {
if(sb.length() > 0)
sb.append("\n");
sb.append("[" + server.getName() + "]\n");
sb.append("address " + server.getAddress() + "\n");
sb.append("port " + server.getPort() + "\n");
sb.append("user " + server.getUser() + "\n");
sb.append("password " + server.getPassword() + "\n");
sb.append("access " + server.getAccess() + "\n");
sb.append("connected " + server.getLastConnected());
}
FileUtils.write(SERVERS_FILE, sb.toString());
}
catch(Exception e) {
Log.IO.error("Konnte Serverliste nicht speichern", e);
}
}
public String getTitle() {
return "Server auswählen";
}
public int getListWidth() {
return 660;
}
public int getSlotHeight() {
return 56;
}
public void use(ActButton button, Mode mode) {
if(button == this.deleteButton) {
if(this.selectedElement >= 0) {
this.elements.remove(this.selectedElement);
this.gm.displayGuiScreen(this);
}
}
else if(button == this.selectButton) {
ServerInfo server = this.getSelected();
if(server != null) {
server.setLastConnected();
this.gm.connect(server.address, server.port, server.user, server.password, server.access);
}
}
else if(button == this.createButton) {
this.setSelected(-1);
this.gm.displayGuiScreen(new GuiServer(new ServerInfo("", "", Config.PORT, "", "", "", -1L)));
}
else if(button == this.editButton) {
ServerInfo server = this.getSelected();
if(server != null)
this.gm.displayGuiScreen(new GuiServer(server));
}
else if(button == this.copyButton) {
ServerInfo server = this.getSelected();
if(server != null) {
this.setSelected(-1);
this.gm.displayGuiScreen(new GuiServer(new ServerInfo(server.name, server.address, server.port, server.user, server.address, server.access, -1L)));
}
}
}
}

View file

@ -1,214 +0,0 @@
package client.gui;
import java.io.File;
import java.io.FileFilter;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import client.Game.FileMode;
import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode;
import client.gui.element.GuiList;
import client.gui.element.ListEntry;
import client.gui.element.NavButton;
import client.renderer.Drawing;
import client.world.Converter;
import common.color.TextColor;
import common.dimension.Space;
import common.log.Log;
import common.world.Region;
import common.world.World;
import common.world.Region.FolderInfo;
import common.world.Region.SaveVersion;
public class GuiConvert extends GuiList<GuiConvert.SaveInfo> implements ActButton.Callback
{
protected class SaveInfo implements Comparable<SaveInfo>, ListEntry {
private final String file;
private final int dimensions;
private final int players;
private final long seed;
private final FolderInfo info;
public SaveInfo(String file, int dimensions, int players, long seed, FolderInfo info) {
this.file = file;
this.dimensions = dimensions;
this.players = players;
this.seed = seed;
this.info = info;
}
public String getFile() {
return this.file;
}
public int getDimensions() {
return this.dimensions;
}
public int getPlayers() {
return this.players;
}
public boolean mustConvert() {
return this.info.legacy != null;
}
public String getVersion() {
return this.info.legacy == null ? (this.info.version == null ? "<Unbekannt>" : this.info.version) : this.info.legacy.toString();
}
public boolean isIncompatible() {
return this.info.legacy == SaveVersion.RELEASE_1_13;
}
public long getLastPlayed() {
return this.info.lastPlayed;
}
public long getSeed() {
return this.seed;
}
public int compareTo(SaveInfo comp) {
return this.info.lastPlayed < comp.info.lastPlayed ? 1 : (this.info.lastPlayed > comp.info.lastPlayed ? -1 : this.file.compareTo(comp.file));
}
public void select(boolean isDoubleClick, int mouseX, int mouseY)
{
boolean use = !this.isIncompatible() && this.mustConvert();
GuiConvert.this.selectButton.enabled = use;
if (isDoubleClick && use)
{
GuiConvert.this.use(GuiConvert.this.selectButton, Mode.PRIMARY);
}
}
public void draw(int x, int y, int mouseXIn, int mouseYIn, boolean hover)
{
Drawing.drawText((this.isIncompatible() ? TextColor.DRED : "") + this.getFile() + (this.mustConvert() ? "" :
(TextColor.GRAY + " - " + TextColor.RESET + (this.getPlayers() > 0 ? this.getPlayers() + " Spieler" : "Keine Spieler"))),
x + 2, y, 0xffffffff);
Drawing.drawText((this.mustConvert() ? (this.isIncompatible() ? TextColor.CRIMSON : "") + this.getVersion() : (this.getDimensions() <= 0 ? "Keine Dimensionen" : this.getDimensions() + " Dimension" + (this.getDimensions() != 1 ? "en" : "") + " erschaffen"))
, x + 2, y + 18, 0xff808080);
Drawing.drawText(this.mustConvert() ? (this.isIncompatible() ? TextColor.CRIMSON + "Kann nicht konvertiert werden!" :
"Muss konvertiert werden!") : ( // "Kreativmodus: " + (info.isNoCreative() ? "Aus" : "An") +
"Zuletzt gespielt: " + DATE_FORMAT.format(new Date(this.getLastPlayed()))) + " " + TextColor.LGRAY + this.getVersion(), x + 2, y + 18 + 16, 0xff808080);
}
}
public static final GuiConvert INSTANCE = new GuiConvert();
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
private ActButton selectButton;
private File dir = null;
private GuiConvert()
{
}
private void load() {
this.elements.clear();
if(this.dir == null || !this.dir.exists() || !this.dir.isDirectory())
return;
try
{
File[] files = dir.listFiles();
if(files == null)
throw new RuntimeException("Kann den Speicherordner für Welten nicht lesen oder öffnen!");
for(File file : files) {
if(!file.isDirectory())
continue;
FolderInfo info = Region.loadWorldInfo(file);
if(info == null)
info = Converter.convertMapFormat(file, false);
if(info == null) {
this.elements.add(new SaveInfo(file.getName(), -1, -1,
0L, new FolderInfo(World.START_TIME, file.lastModified(), null, null)));
continue;
}
int dims = -1;
int players = -1;
if(info.legacy == null) {
dims = 0;
File[] folders = new File(new File(dir, file.getName()), "chunk").listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isDirectory() && !pathname.getName().equals(Space.INSTANCE.getDimensionName());
}
});
if(folders != null) {
for(File sub : folders) {
File[] dim = sub.listFiles();
if(dim != null && dim.length > 0)
dims++;
}
}
File[] plrs = new File(new File(dir, file.getName()), "players").listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().endsWith(".nbt");
}
});
players = plrs == null ? 0 : plrs.length;
}
this.elements.add(new SaveInfo(file.getName(), dims, players,
0L, info));
}
Collections.sort(this.elements);
}
catch (Exception e)
{
Log.IO.error("Konnte Weltliste nicht laden", e);
this.elements.clear();
}
}
public void init(int width, int height)
{
super.init(width, height);
this.setDimensions(width, height, 32, height - 32);
this.load();
this.add(this.selectButton = new ActButton(width / 2 - 383, height - 28, 150, 24, this, "Konvertieren"));
this.add(new NavButton(width / 2 + 233, height - 28, 150, 24, GuiMenu.INSTANCE, "Abbrechen"));
this.add(new ActButton(4, 4, 200, 24, new ActButton.Callback() {
public void use(ActButton elem, ActButton.Mode action) {
if(GuiConvert.this.gm.theWorld != null)
return;
GuiConvert.this.gm.showFileDialog(FileMode.DIRECTORY_LOAD, "Ordner wählen", GuiConvert.this.dir, new FileCallback() {
public void selected(File file) {
GuiConvert.this.dir = file;
GuiConvert.this.gm.displayGuiScreen(GuiConvert.this);
}
});
}
}, "Ordner wählen ..."));
this.selectButton.enabled = false;
}
public String getTitle() {
return "Welt auswählen";
}
public int getListWidth()
{
return 660;
}
public int getSlotHeight()
{
return 56;
}
public void use(ActButton button, Mode mode)
{
String dir = this.getSelected().getFile();
File folder = new File(this.dir, dir);
if(folder.isDirectory())
Converter.convertMapFormat(folder, true);
}
}

View file

@ -1,146 +0,0 @@
package client.gui;
import client.gui.GuiConnect.ServerInfo;
import client.gui.element.ActButton;
import client.gui.element.Label;
import client.gui.element.NavButton;
import client.gui.element.Textbox;
import client.gui.element.Textbox.Action;
import client.vars.CVarCategory;
import client.vars.Variable;
import common.color.TextColor;
import common.init.Config;
import common.network.IPlayer;
public class GuiServer extends Gui implements Textbox.Callback {
public static final GuiServer INSTANCE = new GuiServer(null);
private final ServerInfo server;
private Textbox nameBox;
private Textbox addrBox;
private Textbox portBox;
private Textbox userBox;
private Textbox passBox;
private Textbox accBox;
private Label nameLabel;
private Label addrLabel;
private Label portLabel;
private Label userLabel;
private Label passLabel;
private Label accLabel;
public GuiServer(ServerInfo server) {
this.server = server;
}
@Variable(name = "srv_last_address", category = CVarCategory.SYSTEM, min = 1, max = 128, display = "Letzte Server-Adresse")
private String lastAddr = "";
@Variable(name = "srv_last_port", category = CVarCategory.SYSTEM, min = 0, max = 65535, display = "Letzter Server-Port")
private int lastPort = Config.PORT;
@Variable(name = "srv_last_user", category = CVarCategory.SYSTEM, max = IPlayer.MAX_USER_LENGTH, display = "Letzter Server-Nutzer", validator = IPlayer.UserValidator.class)
private String lastUser = "";
@Variable(name = "srv_last_password", category = CVarCategory.SYSTEM, max = IPlayer.MAX_PASS_LENGTH, display = "Letztes Server-Passwort")
private String lastPass = "";
@Variable(name = "srv_last_access", category = CVarCategory.SYSTEM, max = IPlayer.MAX_PASS_LENGTH, display = "Letzter Server-Zugang")
private String lastAcc = "";
public void init(int width, int height) {
if(this.server != null)
this.nameBox = this.add(new Textbox(0, -50, 400, 24, 128, true, this, this.server.getName()));
this.addrBox = this.add(new Textbox(0, 20, 400, 24, 128, true, this, this.server == null ? this.lastAddr : this.server.getAddress()));
this.portBox = this.add(new Textbox(404, 20, 76, 24, 5, true, this, "" + (this.server == null ? this.lastPort : this.server.getPort())));
this.userBox = this.add(new Textbox(0, 70, 220, 24, IPlayer.MAX_USER_LENGTH, true, this, IPlayer.VALID_USER, this.server == null ? this.lastUser : this.server.getUser()));
this.passBox = this.add(new Textbox(0, 120, 480, 24, IPlayer.MAX_PASS_LENGTH, true, this, this.server == null ? this.lastPass : this.server.getPassword()));
this.accBox = this.add(new Textbox(0, 170, 480, 24, IPlayer.MAX_PASS_LENGTH, true, this, this.server == null ? this.lastAcc : this.server.getAccess()));
this.add(new ActButton(0, 220, 480, 24, new ActButton.Callback() {
public void use(ActButton elem, ActButton.Mode action) {
GuiServer.this.connect();
}
}, this.server == null ? "Verbinden" : (this.server.getName().isEmpty() ? "Hinzufügen" : "Übernehmen")));
this.add(new NavButton(0, 250, 480, 24, GuiConnect.INSTANCE, "Zurück"));
if(this.server != null)
this.nameLabel = this.add(new Label(0, -70, 410, 20, "Name", true));
this.addrLabel = this.add(new Label(0, 0, 410, 20, "Adresse", true));
this.portLabel = this.add(new Label(414, 0, 66, 20, "Port", true));
this.userLabel = this.add(new Label(0, 50, 220, 20, "Nutzer", true));
this.passLabel = this.add(new Label(0, 100, 480, 20, "Passwort", true));
this.accLabel = this.add(new Label(0, 150, 480, 20, "Zugang", true));
this.shift();
}
public String getTitle() {
return this.server == null ? "Mit Server verbinden" : (this.server.getName().isEmpty() ? "Server hinzufügen" : "Server bearbeiten");
}
private void connect() {
if(this.gm.theWorld != null)
return;
String name = null;
if(this.server != null) {
name = this.nameBox.getText();
if(name.isEmpty()) {
this.nameLabel.setText(TextColor.RED + "Name");
return;
}
}
String addr = this.addrBox.getText();
if(addr.isEmpty()) {
this.addrLabel.setText(TextColor.RED + "Adresse");
return;
}
int port = -1;
if(this.portBox.getText().isEmpty()) {
this.portLabel.setText(TextColor.RED + "Port");
return;
}
else {
try {
port = Integer.parseInt(this.portBox.getText());
}
catch(NumberFormatException e) {
}
if(port < 0 || port > 65535) {
this.portLabel.setText(TextColor.RED + "Port");
return;
}
}
String user = this.userBox.getText();
if(user.isEmpty()) {
this.userLabel.setText(TextColor.RED + "Nutzer");
return;
}
String pass = this.passBox.getText();
String acc = this.accBox.getText();
if(this.server == null) {
this.lastAddr = addr;
this.lastPort = port;
this.lastUser = user;
this.lastPass = pass;
this.lastAcc = acc;
this.gm.setDirty();
this.gm.connect(addr, port, user, pass, acc);
}
else {
this.server.setData(name, addr, port, user, pass, acc);
GuiConnect.INSTANCE.applyServer(this.server);
}
}
public void use(Textbox elem, Action value) {
if(value == Action.SEND) {
elem.setDeselected();
this.connect();
}
else if(value == Action.FOCUS) {
if(elem == this.addrBox)
this.addrLabel.setText("Adresse");
else if(elem == this.portBox)
this.portLabel.setText("Port");
else if(elem == this.userBox)
this.userLabel.setText("Nutzer");
else if(this.server != null && elem == this.nameBox)
this.nameLabel.setText("Name");
}
}
}

View file

@ -1,42 +0,0 @@
package client.gui.container;
import common.inventory.ContainerWorkbench;
import common.inventory.InventoryPlayer;
import common.world.BlockPos;
import common.world.World;
public class GuiCrafting extends GuiContainer
{
// private static final String craftingTableGuiTextures = "textures/gui/crafting_table.png";
public GuiCrafting(InventoryPlayer playerInv, World worldIn)
{
this(playerInv, worldIn, BlockPos.ORIGIN);
}
public GuiCrafting(InventoryPlayer playerInv, World worldIn, BlockPos blockPosition)
{
super(new ContainerWorkbench(playerInv, worldIn, blockPosition));
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
*/
public void drawGuiContainerForegroundLayer()
{
this.drawString("Handwerk", 28, 6);
this.drawString("Inventar", 8, this.ySize - 96 + 2);
}
// /**
// * Args : renderPartialTicks, mouseX, mouseY
// */
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
// {
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
// this.gm.getTextureManager().bindTexture(craftingTableGuiTextures);
// int i = (this.width - this.xSize) / 2;
// int j = (this.height - this.ySize) / 2;
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
// }
}

View file

@ -1,44 +0,0 @@
package client.gui.container;
import client.Game;
import common.inventory.ContainerMachine;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.tileentity.TileEntityMachine;
public class GuiMachine extends GuiContainer
{
// private final String texture;
private final IInventory playerInv;
private final IInventory machineInv;
private final TileEntityMachine machine;
public GuiMachine(InventoryPlayer player, IInventory inv, TileEntityMachine machine)
{
super(new ContainerMachine(player, machine, inv, Game.getGame().thePlayer));
this.playerInv = player;
this.machineInv = machine;
// this.allowUserInput = false;
this.ySize = 153;
// this.texture = "textures/gui/" + texture + ".png";
this.machine = machine;
}
public void drawGuiContainerForegroundLayer()
{
this.drawString(this.machine.getStatus().color + this.machineInv.getCommandName() + " - " + this.machine.getStatus().name, 8, 6);
this.drawString(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.drawString(String.format("Temperatur: %d °", this.machine.getTemperature()), 8, 18);
this.drawString(this.machine.formatDisplay(), 8, 28);
}
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
// {
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
// this.gm.getTextureManager().bindTexture(this.texture);
// int i = (this.width - this.xSize) / 2;
// int j = (this.height - this.ySize) / 2;
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
// }
}

View file

@ -1,34 +0,0 @@
package client.gui.element;
import client.gui.Formatter;
import client.window.Button;
public class ActButton extends Element {
public static enum Mode {
PRIMARY, SECONDARY, TERTIARY;
}
public static interface Callback {
void use(ActButton elem, Mode action);
}
private final Callback func;
public ActButton(int x, int y, int w, int h, Callback callback, Formatter<ActButton> formatter) {
super(x, y, w, h, formatter);
this.func = callback;
this.formatText();
}
public ActButton(int x, int y, int w, int h, Callback callback, String text) {
super(x, y, w, h, null);
this.func = callback;
this.setText(text);
}
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) {
this.func.use(this, (ctrl || (btn == Button.MOUSE_MIDDLE)) ? Mode.TERTIARY : ((shift || (btn == Button.MOUSE_RIGHT)) ? Mode.SECONDARY : Mode.PRIMARY));
this.formatText();
this.playSound();
}
}

View file

@ -1,413 +0,0 @@
package client.gui.element;
import java.util.List;
import org.lwjgl.opengl.GL11;
import client.gui.Gui;
import client.renderer.DefaultVertexFormats;
import client.renderer.Drawing;
import client.renderer.GlState;
import client.renderer.RenderBuffer;
import client.renderer.Tessellator;
import client.window.Button;
import common.collect.Lists;
import common.util.ExtMath;
public abstract class GuiList<T extends ListEntry> extends Gui
{
protected final List<T> elements = Lists.newArrayList();
protected int width;
protected int height;
protected int top;
protected int bottom;
protected int right;
protected int left;
protected int mouseX;
protected int mouseY;
protected int initialClickY = -2;
protected float scrollMultiplier;
protected float amountScrolled;
protected int selectedElement = -1;
protected long lastClicked;
public abstract int getListWidth(); // 220
public abstract int getSlotHeight();
protected int getScrollBarX()
{
return 0;
}
public void setDimensions(int widthIn, int heightIn, int topIn, int bottomIn)
{
this.width = widthIn;
this.height = heightIn;
this.top = topIn;
this.bottom = bottomIn;
this.left = 0;
this.right = widthIn;
}
public void init(int width, int height) {
this.selectedElement = -1;
}
public void setSlotXBoundsFromLeft(int leftIn)
{
this.left = leftIn;
this.right = leftIn + this.width;
}
public final T getListEntry(int index) {
return this.elements.get(index);
}
public final T getSelected() {
return this.selectedElement < 0 ? null : this.elements.get(this.selectedElement);
}
public final int getSize() {
return this.elements.size();
}
public final void setSelected(int index) {
this.selectedElement = index;
}
protected int getContentHeight()
{
return this.getSize() * this.getSlotHeight();
}
public int getSlotIndexFromScreenCoords(int x, int y)
{
int i = this.left + this.width / 2 - this.getListWidth() / 2;
int j = this.left + this.width / 2 + this.getListWidth() / 2;
int k = y - this.top + (int)this.amountScrolled - 4;
int l = k / this.getSlotHeight();
return this.isInList(x, y) && x >= i && x <= j && l >= 0 && k >= 0 && l < this.getSize() ? l : -1;
}
protected boolean isInList(int x, int y)
{
return x >= this.getScrollBarX() + 6; // x < this.getScrollBarX();
}
protected final boolean isSelected(int slotIndex)
{
return slotIndex == this.selectedElement;
}
protected void bindAmountScrolled()
{
this.amountScrolled = ExtMath.clampf(this.amountScrolled, 0.0F, (float)this.getMaxScroll());
}
public int getMaxScroll()
{
return Math.max(0, this.getContentHeight() - (this.bottom - this.top - 4));
}
public int getAmountScrolled()
{
return (int)this.amountScrolled;
}
public boolean isMouseYWithinSlotBounds(int p_148141_1_)
{
return p_148141_1_ >= this.top && p_148141_1_ <= this.bottom && this.mouseX >= this.left && this.mouseX <= this.right;
}
public void scrollBy(int amount)
{
this.amountScrolled += (float)amount;
this.bindAmountScrolled();
this.initialClickY = -2;
}
// public void actionPerformed(Button button)
// {
// if (button.enabled)
// {
// if (button.id == this.scrollUpButtonID)
// {
// this.amountScrolled -= (float)(this.slotHeight * 2 / 3);
// this.initialClickY = -2;
// this.bindAmountScrolled();
// }
// else if (button.id == this.scrollDownButtonID)
// {
// this.amountScrolled += (float)(this.slotHeight * 2 / 3);
// this.initialClickY = -2;
// this.bindAmountScrolled();
// }
// }
// }
public void draw()
{
int mouseXIn = this.gm.mouse_x;
int mouseYIn = this.gm.mouse_y;
this.mouseX = mouseXIn;
this.mouseY = mouseYIn;
this.drawBackground();
int i = this.getScrollBarX();
int j = i + 6;
this.bindAmountScrolled();
GlState.disableLighting();
GlState.disableFog();
GlState.enableTexture2D();
RenderBuffer worldrenderer = Tessellator.getBuffer();
this.gm.getTextureManager().bindTexture(Gui.DIRT_BACKGROUND);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
float f = 32.0F;
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldrenderer.pos((double)0, (double)this.bottom, 0.0D).tex((double)((float)0 / f), (double)((float)(this.bottom + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
worldrenderer.pos((double)this.gm.fb_x, (double)this.bottom, 0.0D).tex((double)((float)this.gm.fb_x / f), (double)((float)(this.bottom + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
worldrenderer.pos((double)this.gm.fb_x, (double)this.top, 0.0D).tex((double)((float)this.gm.fb_x / f), (double)((float)(this.top + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
worldrenderer.pos((double)0, (double)this.top, 0.0D).tex((double)((float)0 / f), (double)((float)(this.top + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
Tessellator.draw();
int x = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
int y = this.top + 4 - (int)this.amountScrolled;
this.drawSelectionBox(x, y, mouseXIn, mouseYIn);
GlState.disableDepth();
this.overlayBackground(0, this.top, 255, 255);
this.overlayBackground(this.bottom, this.height, 255, 255);
GlState.enableBlend();
GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
GlState.disableAlpha();
GlState.shadeModel(GL11.GL_SMOOTH);
GlState.disableTexture2D();
int i1 = 4;
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldrenderer.pos((double)0, (double)(this.top + i1), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 0).endVertex();
worldrenderer.pos((double)this.gm.fb_x, (double)(this.top + i1), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 0).endVertex();
worldrenderer.pos((double)this.gm.fb_x, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
worldrenderer.pos((double)0, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
Tessellator.draw();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldrenderer.pos((double)0, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
worldrenderer.pos((double)this.gm.fb_x, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
worldrenderer.pos((double)this.gm.fb_x, (double)(this.bottom - i1), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 0).endVertex();
worldrenderer.pos((double)0, (double)(this.bottom - i1), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 0).endVertex();
Tessellator.draw();
int j1 = this.getMaxScroll();
if (j1 > 0)
{
int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
k1 = ExtMath.clampi(k1, 32, this.bottom - this.top - 8);
int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / j1 + this.top;
if (l1 < this.top)
{
l1 = this.top;
}
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldrenderer.pos((double)i, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
worldrenderer.pos((double)j, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
worldrenderer.pos((double)j, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
worldrenderer.pos((double)i, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
Tessellator.draw();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldrenderer.pos((double)i, (double)(l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
worldrenderer.pos((double)j, (double)(l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
worldrenderer.pos((double)j, (double)l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
Tessellator.draw();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldrenderer.pos((double)i, (double)(l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
worldrenderer.pos((double)(j - 1), (double)(l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
worldrenderer.pos((double)(j - 1), (double)l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
Tessellator.draw();
}
GlState.enableTexture2D();
GlState.shadeModel(GL11.GL_FLAT);
GlState.enableAlpha();
GlState.disableBlend();
super.draw();
}
public void handleMouseInput()
{
if (this.isMouseYWithinSlotBounds(this.mouseY))
{
// if (Button.MOUSE_LEFT.isDown() && this.getEnabled())
// {
if (this.initialClickY == -1)
{
boolean flag1 = true;
if (this.mouseY >= this.top && this.mouseY <= this.bottom)
{
int j2 = (this.width - this.getListWidth()) / 2;
int k2 = (this.width + this.getListWidth()) / 2;
int l2 = this.mouseY - this.top + (int)this.amountScrolled - 4;
int i1 = l2 / this.getSlotHeight();
if (i1 < this.getSize() && this.mouseX >= j2 && this.mouseX <= k2 && i1 >= 0 && l2 >= 0)
{
}
else if (this.mouseX >= j2 && this.mouseX <= k2 && l2 < 0)
{
flag1 = false;
}
int i3 = this.getScrollBarX();
int j1 = i3 + 6;
if (this.mouseX >= i3 && this.mouseX <= j1)
{
this.scrollMultiplier = -1.0F;
int k1 = this.getMaxScroll();
if (k1 < 1)
{
k1 = 1;
}
int l1 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / (float)this.getContentHeight());
l1 = ExtMath.clampi(l1, 32, this.bottom - this.top - 8);
this.scrollMultiplier /= (float)(this.bottom - this.top - l1) / (float)k1;
}
else
{
this.scrollMultiplier = 1.0F;
}
if (flag1)
{
this.initialClickY = this.mouseY;
}
else
{
this.initialClickY = -2;
}
}
else
{
this.initialClickY = -2;
}
}
else if (this.initialClickY >= 0)
{
this.amountScrolled -= (float)(this.mouseY - this.initialClickY) * this.scrollMultiplier;
this.initialClickY = this.mouseY;
}
// }
// else
// {
// this.initialClickY = -1;
// }
}
}
protected void drawSelectionBox(int x, int y, int mouseXIn, int mouseYIn)
{
int size = this.getSize();
RenderBuffer rb = Tessellator.getBuffer();
for (int z = 0; z < size; z++)
{
int y1 = y + z * this.getSlotHeight();
int h = this.getSlotHeight() - 4;
if (this.isSelected(z))
{
int x1 = this.left + (this.width / 2 - this.getListWidth() / 2);
int x2 = this.left + this.width / 2 + this.getListWidth() / 2;
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
GlState.disableTexture2D();
rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
rb.pos((double)x1, (double)(y1 + h + 2), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
rb.pos((double)x2, (double)(y1 + h + 2), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
rb.pos((double)x2, (double)(y1 - 2), 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
rb.pos((double)x1, (double)(y1 - 2), 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
rb.pos((double)(x1 + 1), (double)(y1 + h + 1), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
rb.pos((double)(x2 - 1), (double)(y1 + h + 1), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
rb.pos((double)(x2 - 1), (double)(y1 - 1), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
rb.pos((double)(x1 + 1), (double)(y1 - 1), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
Tessellator.draw();
GlState.enableTexture2D();
}
boolean hover = this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == z;
this.getListEntry(z).draw(x, y1, mouseXIn - x, mouseYIn - y1, hover);
if(hover)
Drawing.drawRect(x - 2, y1 - 2, this.getListWidth(), this.getSlotHeight(), Gui.HOVER_COLOR);
}
}
protected void overlayBackground(int startY, int endY, int startAlpha, int endAlpha)
{
RenderBuffer rb = Tessellator.getBuffer();
this.gm.getTextureManager().bindTexture(Gui.DIRT_BACKGROUND);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
float f = 32.0F;
rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
rb.pos((double)0, (double)endY, 0.0D).tex(0.0D, (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex();
rb.pos((double)this.gm.fb_x, (double)endY, 0.0D).tex((double)((float)this.gm.fb_x / 32.0F), (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex();
rb.pos((double)this.gm.fb_x, (double)startY, 0.0D).tex((double)((float)this.gm.fb_x / 32.0F), (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex();
rb.pos((double)0, (double)startY, 0.0D).tex(0.0D, (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex();
Tessellator.draw();
}
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift)
{
super.mouse(btn, x, y, ctrl, shift);
if (this.isMouseYWithinSlotBounds(y))
{
int i = this.getSlotIndexFromScreenCoords(x, y);
if (i >= 0)
{
int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
int k = this.top + 4 - this.getAmountScrolled() + i * this.getSlotHeight();
int l = x - j;
int i1 = y - k;
boolean flag = i == this.selectedElement && System.currentTimeMillis() - this.lastClicked < (long)this.gm.dclickDelay;
this.selectedElement = i;
this.lastClicked = System.currentTimeMillis();
this.getListEntry(i).select(flag, l, i1);
}
}
if(btn == Button.MOUSE_LEFT && this.clicked(x, y) == null)
this.handleMouseInput();
}
public void mouserel(Button btn, int x, int y) {
super.mouserel(btn, x, y);
if(btn == Button.MOUSE_LEFT)
this.initialClickY = -1;
}
public void scroll(int scr_x, int scr_y, int x, int y, boolean ctrl, boolean shift) {
super.scroll(scr_x, scr_y, x, y, ctrl, shift);
if(scr_y != 0 && this.clicked(x, y) == null)
this.amountScrolled -= (float)(ExtMath.clampi(scr_y, -1, 1) * this.getSlotHeight() / 2);
}
public void drag(int x, int y) {
super.drag(x, y);
if(this.selected == null && Button.MOUSE_LEFT.isDown())
this.handleMouseInput();
}
}

View file

@ -1,514 +0,0 @@
package client.gui.element;
import org.lwjgl.opengl.GL11;
import client.Timing;
import client.gui.Font;
import client.renderer.Drawing;
import client.renderer.Drawing.Offset;
import client.renderer.Drawing.Vec2i;
import client.window.Button;
import client.window.Keysym;
import client.window.Window;
import common.util.CharValidator;
import common.util.ExtMath;
import common.util.Util;
public class Textbox extends Element {
public static enum Action {
FOCUS, UNFOCUS, PREVIOUS, NEXT, FUNCTION, SEND, LINE, FORWARD, BACKWARD;
}
public static interface Callback {
void use(Textbox elem, Action value);
}
private final Callback func;
private final CharValidator validator;
private final int capacity;
private final boolean xbreak;
private final boolean editable;
private long tmr_scroll;
private long tmr_leftmb;
private int scrollx;
private int scrolly;
private int sel_start = -1;
private int sel_end = -1;
private int sel_drag = -1;
private int cursorX = 0;
private int cursorY = 0;
private int tsize_x = 0;
private int tsize_y = 0;
private Textbox(int x, int y, int w, int h, int cap, boolean line, boolean editable, Callback callback, CharValidator validator, String text) {
super(x, y, w, h, null);
this.func = callback;
this.validator = validator;
this.capacity = cap;
this.xbreak = !line;
this.editable = editable;
if(line)
this.text_y = (this.size_y - (this.margin_y1 + this.margin_y2 + Font.YGLYPH)) / 2;
this.setText(text);
}
public Textbox(int x, int y, int w, int h, int cap, boolean line, Callback callback, String text) {
this(x, y, w, h, cap, line, true, callback, null, text);
}
public Textbox(int x, int y, int w, int h, int cap, boolean line, Callback callback, CharValidator validator, String text) {
this(x, y, w, h, cap, line, true, callback, validator, text);
}
public Textbox(int x, int y, int w, int h, int cap, Callback callback, String text) {
this(x, y, w, h, cap, false, true, callback, null, text);
}
public Textbox(int x, int y, int w, int h, String text) {
this(x, y, w, h, Integer.MAX_VALUE, false, false, null, null, text);
}
public Textbox(int x, int y, int w, int h, boolean line, String text) {
this(x, y, w, h, Integer.MAX_VALUE, line, false, null, null, text);
}
// public void setEditable(boolean editable) {
// this.editable = editable;
// }
// protected boolean isTextCenteredX() {
// return false;
// }
//
// protected boolean isTextCenteredY() {
// return false;
// }
// protected boolean hasLinebreak() {
// return this.xbreak;
// }
public void updateText() {
Vec2i size = Drawing.txt_size(this.pos_x + this.margin_x1, this.pos_y + this.margin_y1,
this.pos_x + this.margin_x1, this.pos_y + this.margin_y1,
this.xbreak ? (this.pos_x + (this.size_x - (this.margin_x1 + this.margin_x2))) : Integer.MAX_VALUE, Integer.MAX_VALUE, this.text);
this.tsize_x = size.xpos;
this.tsize_y = size.ypos;
}
public boolean canHover() {
return false;
}
protected int getMarginX() {
return 4;
}
public void setText(String str) {
if(this.validator != null)
str = this.validator.filter(str);
this.text = str.length() > this.capacity ? str.substring(0, this.capacity) : str;
this.updateText();
this.sel_start = this.sel_end = this.sel_drag = this.text.length();
gui_text_update_cur(this.sel_start, true);
}
public void scroll(int scr_x, int scr_y, int x, int y, boolean ctrl, boolean shift) {
if(scr_y != 0 && this.xbreak) {
int limit = Font.YGLYPH + this.tsize_y - (this.size_y - (this.margin_y1 + this.margin_y2));
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
int prev = this.text_y;
this.text_y += (scr_y < 0 ? -1 : 1) * (ctrl ? 1 : Font.YGLYPH) * this.gm.scrollLines * (shift ? 10 : 1);
this.text_y = ExtMath.clampi(this.text_y, -limit, 0);
if(this.sel_start >= 0)
this.cursorY += (this.text_y - prev);
// this.r_dirty = true;
}
else if(scr_y != 0 || scr_x != 0) {
int limit = Font.XGLYPH + this.tsize_x - (this.size_x - (this.margin_x1 + this.margin_x2));
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
int prev = this.text_x;
this.text_x += ((scr_y != 0 ? scr_y : (-scr_x)) < 0 ? -1 : 1) * (ctrl ? 1 : Font.XGLYPH) * this.gm.scrollLines * (shift ? 10 : 1);
this.text_x = ExtMath.clampi(this.text_x, -limit, 0);
if(this.sel_start >= 0)
this.cursorX += (this.text_x - prev);
// this.r_dirty = true;
}
}
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) {
if(btn == Button.MOUSE_LEFT) {
if(!shift && ((Timing.tmr_current - this.tmr_leftmb) <= (((long)this.gm.dclickDelay) * 1000L))) {
this.sel_start = this.sel_drag = 0;
this.sel_end = this.text.length();
// this.r_dirty = true;
}
else {
gui_text_select(x, y, shift);
}
this.tmr_leftmb = Timing.tmr_current;
}
else if((btn == Button.MOUSE_MIDDLE) && this.func != null) {
this.func.use(this, Action.FUNCTION);
}
}
public void mouserel() {
this.scrollx = this.scrolly = 0;
}
public void drag(int x, int y) {
gui_text_select(x, y, true);
}
public void character(char code) {
if(this.editable) {
// int pos = 0;
// char chr[8];
// utf_rwriten(chr, &pos, 8, code);
// chr[pos] = 0;
insertText(Character.toString(code));
}
}
public void key(Keysym key, boolean ctrl, boolean shift) {
if(ctrl && key == Keysym.A) {
this.sel_start = this.sel_drag = 0;
this.sel_end = this.text.length();
// this.r_dirty = true;
}
else if(ctrl && (key == Keysym.C) || (this.editable && (key == Keysym.X))) {
if(this.sel_start >= 0 && this.sel_start != this.sel_end) { // fix empty
// char end = this.text[this.sel_end];
// this.text[this.sel_end] = 0;
String str = Util.strip(this.text, this.sel_start, this.sel_end - this.sel_start, '\n', (char)0, '?');
Window.setClipboard(str);
// this.text[this.sel_end] = end;
if(key == Keysym.X)
insertText("");
}
}
else if(this.editable && ctrl && key == Keysym.V) {
insertText(Window.getClipboard());
}
else if(this.editable && !ctrl && key == Keysym.RETURN) {
if(this.xbreak) {
insertText("\n");
}
else if(this.func != null) {
this.func.use(this, shift ? Action.LINE : Action.SEND);
}
}
else if(this.editable && (!ctrl) && (key == Keysym.BACKSPACE || key == Keysym.DELETE)) {
if(this.sel_start != this.sel_end) {
insertText("");
}
else if(key == Keysym.DELETE && this.sel_start >= 0) {
if(this.sel_end < this.text.length()) {
this.sel_end += 1;
insertText("");
}
else {
this.sel_end = this.sel_start;
}
}
else if(key == Keysym.BACKSPACE && this.sel_start > 0) {
this.sel_start -= 1;
insertText("");
}
}
else if(!ctrl && (key == Keysym.RIGHT || key == Keysym.LEFT)) {
if(key == Keysym.RIGHT && this.sel_start != this.sel_end) {
this.sel_start = this.sel_drag = this.sel_end;
}
else if(key == Keysym.LEFT && this.sel_start != this.sel_end) {
this.sel_end = this.sel_drag = this.sel_start;
}
if(key == Keysym.RIGHT && this.sel_start >= 0) {
if(this.sel_end < this.text.length()) {
this.sel_start = this.sel_drag = this.sel_end += 1;
}
else {
this.sel_end = this.sel_drag = this.sel_start;
}
gui_text_update_cur(this.sel_end, true);
}
else if(key == Keysym.LEFT && this.sel_start >= 0) {
if(this.sel_start > 0)
this.sel_start -= 1;
this.sel_end = this.sel_drag = this.sel_start;
gui_text_update_cur(this.sel_end, true);
}
}
else if(!ctrl && (key == Keysym.DOWN || key == Keysym.UP)) {
if(this.xbreak) {
if(key == Keysym.DOWN && this.sel_start != this.sel_end) {
this.sel_start = this.sel_drag = this.sel_end;
}
else if(key == Keysym.UP && this.sel_start != this.sel_end) {
this.sel_end = this.sel_drag = this.sel_start;
}
if(key == Keysym.DOWN && this.sel_start >= 0) {
if(this.sel_end < this.text.length()) {
// char ch = this.text.charAt(this.sel_end);
// this.sel_end += 1;
int nl = this.text.indexOf('\n', this.sel_end);
// while(ch && ch != '\n') {
// ch = utf_readn(this.text, &this.sel_end);
// }
this.sel_end = nl >= 0 ? nl + 1 : this.text.length();
// else
// this.sel_end -= 1;
this.sel_start = this.sel_drag = this.sel_end;
}
else {
this.sel_end = this.sel_drag = this.sel_start;
}
gui_text_update_cur(this.sel_end, true);
}
else if(key == Keysym.UP && this.sel_start >= 0) {
// uint ch;
if(this.sel_start > 0) {
int nl = this.text.lastIndexOf('\n', this.sel_start);
this.sel_start = nl >= 0 ? nl : 0;
// do {
// ch = utf_rreadn(this.text, &this.sel_start);
// }
// while(ch && ch != '\n');
}
this.sel_end = this.sel_drag = this.sel_start;
gui_text_update_cur(this.sel_end, true);
}
}
else if(this.func != null) {
this.func.use(this, (key == Keysym.DOWN) ? Action.NEXT : Action.PREVIOUS);
}
}
else if((!ctrl) && key == Keysym.TAB) {
if(this.func != null) {
this.func.use(this, shift ? Action.BACKWARD : Action.FORWARD);
}
}
}
public void select() {
if(this.func != null) {
this.func.use(this, Action.FOCUS);
}
}
public void deselect() {
this.sel_start = this.sel_end = this.sel_drag = -1;
this.tmr_leftmb = 0L;
// this.r_dirty = true;
if(this.func != null) {
this.func.use(this, Action.UNFOCUS);
}
}
public void update() {
if((this.scrollx != 0 && !(this.xbreak)) || (this.scrolly != 0 && this.xbreak)) {
int n;
if(!this.xbreak)
this.text_x += (n = (int)((float)((float)this.tmr_scroll) / 1000000.0f * 4.0f * ((float)this.scrollx)));
else
this.text_y += (n = (int)((float)((float)this.tmr_scroll) / 1000000.0f * 4.0f * ((float)this.scrolly)));
if(n != 0) {
gui_text_clamp_scroll();
// this.r_dirty = true;
}
if((((long)n) * 1000000L) <= this.tmr_scroll)
this.tmr_scroll -= ((long)n) * 1000000L;
else
this.tmr_scroll = 0L;
this.tmr_scroll += Timing.tmr_delta;
}
}
public void shift(int shift_x, int shift_y) {
super.shift(shift_x, shift_y);
this.cursorX += shift_x;
this.cursorY += shift_y;
}
private void gui_text_clamp_scroll() {
int limit;
if(this.xbreak) {
limit = Font.YGLYPH + this.tsize_y - (this.size_y - (this.margin_y1 + this.margin_y2));
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
this.text_y = ExtMath.clampi(this.text_y, -limit, 0);
}
else {
limit = Font.XGLYPH + this.tsize_x - (this.size_x - (this.margin_x1 + this.margin_x2));
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
this.text_x = ExtMath.clampi(this.text_x, -limit, 0);
}
}
private void gui_text_update_cur(int offset, boolean shift) {
int x1 = this.pos_x + this.margin_x1;
int y1 = this.pos_y + this.margin_y1;
int x2 = this.size_x - (this.margin_x1 + this.margin_x2);
int y2 = this.size_y - (this.margin_y1 + this.margin_y2);
gui_text_clamp_scroll();
Vec2i coord = Drawing.txt_coord(offset, x1 + (this.xbreak ? 0 : this.text_x), y1 + this.text_y,
x1 + this.text_x, y1 + this.text_y, this.xbreak ? (this.pos_x + x2) : 0x7fffffff, 0x7fffffff, this.text);
this.cursorX = coord.xpos;
this.cursorY = coord.ypos;
if(shift) {
if(this.xbreak && this.cursorY < y1)
this.text_y += y1 - this.cursorY;
else if(this.xbreak && (this.cursorY + Font.YGLYPH) >= (y1 + y2))
this.text_y -= (this.cursorY + Font.YGLYPH) - (y1 + y2);
if(!(this.xbreak) && this.cursorX < x1)
this.text_x += x1 - this.cursorX;
else if(!(this.xbreak) && (this.cursorX + Font.XGLYPH) >= (x1 + x2))
this.text_x -= (this.cursorX + Font.XGLYPH) - (x1 + x2);
gui_text_update_cur(offset, false);
}
// else {
// this.r_dirty = true;
// }
}
public void insertText(String str) {
if(str == null || (this.sel_start == -1))
return;
str = Util.strip(str, 0, str.length(), this.xbreak ? '\n' : ' ', ' ', (char)0);
if(this.validator != null)
str = this.validator.filter(str);
// plen = strlen(&sys.work_buf[1 + olen - this.sel_end]);
// logd("t", "%d %d %d", olen, slen, plen);
if((str.length() + this.text.length() - (this.sel_end - this.sel_start)) > this.capacity)
return;
this.text = this.text.substring(0, this.sel_start) + str + this.text.substring(this.sel_end);
// memcpy(sys.work_buf, &this.text[this.sel_end], 1 + this.text.length() - this.sel_end);
// memcpy(&this.text[this.sel_start], &sys.work_buf[1 + this.text.length() - this.sel_end], str.length());
// memcpy(&this.text[this.sel_start + str.length()], sys.work_buf, 1 + this.text.length() - this.sel_end);
this.sel_start += str.length();
this.sel_end = this.sel_drag = this.sel_start;
this.updateText();
gui_text_update_cur(this.sel_end, true);
}
private void gui_text_select(int x, int y, boolean drag) {
int x1 = this.pos_x + this.margin_x1;
int y1 = this.pos_y + this.margin_y1;
int x2 = this.size_x - (this.margin_x1 + this.margin_x2);
int y2 = this.size_y - (this.margin_y1 + this.margin_y2);
Offset off = Drawing.txt_offset(x, y, x1 + (this.xbreak ? 0 : this.text_x), y1 + this.text_y,
x1 + this.text_x, y1 + this.text_y, this.xbreak ? (this.pos_x + x2) : 0x7fffffff, 0x7fffffff, this.text);
if(off != null) {
this.cursorX = off.xpos;
this.cursorY = off.ypos;
}
int offset = off == null ? 0 : off.offset;
// logd("tst", "@A %d %d -. %d %d", x1, y1, x2, y2);
// logd("tst", "@C %d %d -. %d, %d %d", x, y, offset, this.min, this.max);
if(!drag) {
this.sel_drag = this.sel_start = this.sel_end = offset;
}
else if(drag && this.sel_drag >= 0 && offset >= this.sel_drag) {
this.sel_start = this.sel_drag;
this.sel_end = offset;
}
else if(drag && this.sel_drag >= 0 && offset < this.sel_drag) {
this.sel_start = offset;
this.sel_end = this.sel_drag;
}
// logd("tst", "@S %d . %d . %d", this.sel_start, this.sel_drag, this.sel_end);
// this.r_dirty = true;
if(x < x1)
this.scrollx = x1 - x;
else if(x >= (x1 + x2))
this.scrollx = -(x - (x1 + x2));
if(y < y1)
this.scrolly = y1 - y;
else if(y >= (y1 + y2))
this.scrolly = -(y - (y1 + y2));
}
protected void drawBackground() {
if(this.enabled)
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.field_top, this.gm.style.field_btm, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm);
else
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.field_top, 0.5f), Util.mulColor(this.gm.style.field_btm, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
}
protected void drawForeground(int x1, int y1, int x2, int y2) {
Drawing.txt_draw(x1 + (this.xbreak ? 0 : this.text_x), y1 + this.text_y,
x1 + this.text_x, y1 + this.text_y,
this.xbreak ? (this.pos_x + x2) : Integer.MAX_VALUE, Integer.MAX_VALUE, this.enabled ? this.gm.style.text_field : Util.mulColor(this.gm.style.text_field, 0.5f), this.text);
if(this.sel_start >= 0 && this.sel_end != this.sel_start)
Drawing.txt_overlay(this.sel_start, this.sel_end, x1 + (this.xbreak ? 0 : this.text_x), y1 + this.text_y,
x1 + this.text_x, y1 + this.text_y,
this.xbreak ? (this.pos_x + x2) : Integer.MAX_VALUE, Integer.MAX_VALUE, this.enabled ? 0x808080ff : 0x80404040, this.text);
}
public void drawOverlay() {
if(this.editable && this.sel_start >= 0 && this.sel_end == this.sel_start && Util.ftime() % 1.0f < 0.5f) {
int x1 = this.pos_x + this.margin_x1;
int y1 = this.pos_y + this.margin_y1;
int x2 = this.size_x - (this.margin_x1 + this.margin_x2);
int y2 = this.size_y - (this.margin_y1 + this.margin_y2);
GL11.glScissor(x1 < 0 ? 0 : x1, (this.gm.fb_y - (y1 + y2)) < 0 ? 0 : (this.gm.fb_y - (y1 + y2)), x2 < 0 ? 0 : x2, y2 < 0 ? 0 : y2);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
Drawing.drawRect(this.cursorX, this.cursorY, 1, Font.YGLYPH, 0xff000000 | (~Util.mixColor(this.gm.style.field_top, this.gm.style.field_btm)));
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
}
public void deleteFromCursor() {
int num = this.getNthCharFromPos() - this.sel_start;
if(this.text.length() != 0) {
if(this.sel_start != this.sel_end) {
this.insertText("");
}
else {
// boolean flag = num < 0;
int i = this.sel_start + num; // flag ? this.sel_start + num : this.sel_start;
int j = this.sel_start; // flag ? this.sel_start : this.sel_start + num;
String s = "";
if(i >= 0) {
s = this.text.substring(0, i);
}
if(j < this.text.length()) {
s = s + this.text.substring(j);
}
// this.setText(s);
this.text = s;
this.updateText();
this.sel_start = this.sel_end = this.sel_drag = i;
gui_text_update_cur(this.sel_start, true);
//
// if(flag) {
// this.moveCursorBy(num);
// }
}
}
}
public int getNthCharFromPos() {
int i = this.sel_start;
while(i > 0 && this.text.charAt(i - 1) != ' ') {
--i;
}
return i;
}
public int getCursorPosition() {
return this.sel_start == this.sel_end ? this.sel_start : -1;
}
}

View file

@ -1,40 +0,0 @@
package client.gui.ingame;
import client.gui.Gui;
import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode;
import common.color.TextColor;
import client.gui.element.Label;
public class GuiGameOver extends Gui {
public static final GuiGameOver INSTANCE = new GuiGameOver();
private ActButton button;
private int timer;
private GuiGameOver() {
}
public void init(int width, int height) {
this.timer = 0;
this.add(new Label(0, 0, 200, 20, "Du bist gestorben!"));
this.add(new Label(0, 32, 200, 20, "Punktestand: " + TextColor.YELLOW + this.gm.thePlayer.experienceLevel));
this.button = this.add(new ActButton(0, 100, 200, 24, new ActButton.Callback() {
public void use(ActButton elem, Mode action) {
GuiGameOver.this.gm.thePlayer.respawnPlayer();
GuiGameOver.this.gm.displayGuiScreen(null);
}
}, "Wiederbeleben"));
this.shift();
this.button.enabled = false;
}
public String getTitle() {
return "Game over";
}
public void updateScreen() {
if(++this.timer >= 20)
this.button.enabled = true;
}
}

View file

@ -1,49 +0,0 @@
package client.gui.ingame;
import client.gui.Gui;
import client.gui.element.NavButton;
import client.gui.element.Textbox;
import client.gui.element.Textbox.Action;
import client.network.ClientPlayer;
import common.packet.CPacketSign;
import common.world.BlockPos;
public class GuiSign extends Gui implements Textbox.Callback {
private final BlockPos position;
private final Textbox[] lines = new Textbox[4];
private final String[] tempLines = new String[this.lines.length];
public void init(int width, int height) {
for(int z = 0; z < this.lines.length; z++) {
this.lines[z] = this.add(new Textbox(0, 40 * z, 300, 24, 50, true, this, this.tempLines[z] == null ? "" : this.tempLines[z]));
}
this.add(new NavButton(0, 40 * (this.lines.length + 1), 300, 24, null, "Fertig"));
this.shift();
}
public String getTitle() {
return "Schild bearbeiten";
}
public void onGuiClosed() {
ClientPlayer nethandler = this.gm.getNetHandler();
if(nethandler != null) {
for(int z = 0; z < this.lines.length; z++) {
this.tempLines[z] = this.lines[z].getText();
}
nethandler.addToSendQueue(new CPacketSign(this.position, this.tempLines));
}
}
public GuiSign(BlockPos sign, String[] lines) {
this.position = sign;
System.arraycopy(lines, 0, this.tempLines, 0, this.lines.length);
}
public void use(Textbox elem, Action value) {
if(value == Action.SEND)
this.gm.displayGuiScreen(null);
}
}

View file

@ -1,103 +0,0 @@
package client.gui.options;
import client.gui.Formatter;
import client.gui.element.Dropdown;
import client.gui.element.Element;
import client.gui.element.Fill;
import client.gui.element.Slider;
import client.gui.element.Toggle;
import client.window.Button;
import client.window.DisplayMode;
import client.window.Window;
import common.color.TextColor;
public class GuiDisplay extends GuiOptions {
private static final String[] DISTANCES = new String[] {"Gruselig", "Winzig", "Gering", "Normal", "Weit"};
private Element distanceSlider;
protected GuiDisplay() {
}
public void init(int width, int height) {
DisplayMode[] dmodes = Window.getDisplayModes();
if(dmodes != null && dmodes.length > 0) {
int offset = 0;
int pos = 0;
int num = dmodes.length;
if(dmodes.length > DisplayMode.VID_MODES) {
offset = dmodes.length - DisplayMode.VID_MODES;
num = DisplayMode.VID_MODES;
}
DisplayMode[] modes = new DisplayMode[num];
DisplayMode selected = dmodes[num + offset - 1];
for(int z = 0; z < num; z++) {
modes[z] = dmodes[z + offset];
if(modes[z].equals(this.gm.vidMode))
selected = modes[z];
}
this.add(new Dropdown<DisplayMode>(30, 80, 440, 24, false, modes, modes[modes.length - 1], selected, new Dropdown.Callback<DisplayMode>() {
public void use(Dropdown<DisplayMode> elem, DisplayMode value) {
GuiDisplay.this.gm.vidMode = value;
GuiDisplay.this.gm.full(true);
}
}, "Auflösung"));
}
else {
this.add(new Fill(30, 80, 440, 24, TextColor.RED + "Auflösung: <?>"));
}
this.add(new Toggle(490, 80, 440, 24, false, GuiDisplay.this.gm.fullscreen, new Toggle.Callback() {
public void use(Toggle elem, boolean value) {
GuiDisplay.this.gm.full(value);
}
}, "Vollbild"));
this.add(new Slider(30, 120, 440, 24, 0, 0, 360 - 8, 0, (this.gm.sync < 0) ? (360 - 8) : (this.gm.sync != 0 ? ((this.gm.sync < 10) ? 1 : (this.gm.sync - 9)) : 0), new Slider.Callback() {
public void use(Slider elem, int value) {
GuiDisplay.this.gm.getVar("win_sync").parse("" + ((value > 0 && value < 360 - 8) ? (value + 9) : (value != 0 ? -1 : 0)));
GuiDisplay.this.gm.setDirty();
}
}, new Formatter<Slider>() {
public String use(Slider elem) {
int value = elem.getValue();
return "Max. Bildrate: " + (value > 0 && value < (360 - 8) ? (value + 9) + " FPS" : (value != 0 ? "Unbegrenzt" : "VSync"));
}
}));
this.addSelector("gl_vsync_flush", 490, 120, 440, 24);
this.addSelector("overlay_enabled", 30, 200, 440, 24);
this.addSelector("overlay_opacity", 490, 200, 440, 24);
this.addSelector("overlay_fadeout", 30, 240, 440, 24);
this.addSelector("chat_permanent", 490, 240, 440, 24);
this.addSelector("console_size", 30, 280, 440, 24);
this.addSelector("chat_size", 490, 280, 440, 24);
this.addSelector("feed_size", 30, 320, 440, 24);
this.addSelector("hotbar_size", 490, 320, 440, 24);
this.addSelector("gl_fov", 30, 400, 440, 24);
this.distanceSlider = this.addSelector("chunk_view_distance", 30, 440, 440, 24);
this.addSelector("chunk_build_time", 490, 440, 440, 24);
super.init(width, height);
}
public String getTitle() {
return "Grafik und Anzeige";
}
private String getDistanceName() {
int distance = this.gm.renderDistance;
distance = distance > 16 ? 16 : distance;
String str = distance < 0 ? DISTANCES[0] : DISTANCES[(distance + 1) / 4];
if(distance > 2 && (((distance + 1) / 2) & 1) == 1)
str = str + "+";
return String.format("Sichtweite: %d Chunks [%d Blöcke, %s]", this.gm.renderDistance, this.gm.renderDistance * 16, str);
}
public void updateScreen() {
if(!Button.isMouseDown())
this.distanceSlider.setText(this.getDistanceName());
}
}

View file

@ -1,37 +0,0 @@
package client.gui.options;
import client.audio.Volume;
import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode;
public class GuiSound extends GuiOptions {
protected GuiSound() {
}
public void init(int width, int height) {
this.addSelector("snd_enabled", 30, 380, 440, 24);
this.addSelector("snd_buffer_size", 30, 420, 440, 24);
this.addSelector("snd_frame_size", 490, 420, 440, 24);
this.add(new ActButton(30, 480, 900, 24, new ActButton.Callback() {
public void use(ActButton elem, Mode action) {
GuiSound.this.gm.restartSound(false);
}
}, "Übernehmen und Audio-Thread neu starten"));
int x = 30;
int y = 220;
for(Volume volume : Volume.values()) {
this.addSelector(volume.getCVarName(), x, y, 440, 24);
x = (x == 30) ? 490 : 30;
if(x == 30)
y += 40;
}
super.init(width, height);
}
public String getTitle() {
return "Audio und Ton";
}
}

View file

@ -1,22 +0,0 @@
package client.init;
import java.util.Map;
import client.renderer.texture.TextureTicked;
import client.renderer.ticked.TextureFlamesFX1;
import client.renderer.ticked.TextureFlamesFX2;
import client.renderer.ticked.TextureLavaFX;
import client.renderer.ticked.TextureLavaFlowFX;
import client.renderer.ticked.TextureWaterFX;
import client.renderer.ticked.TextureWaterFlowFX;
public abstract class AnimationRegistry {
public static void registerAnimations(Map<String, Class<? extends TextureTicked>> anim) {
anim.put("fire1", TextureFlamesFX1.class);
anim.put("fire2", TextureFlamesFX2.class);
anim.put("lavaflow", TextureLavaFlowFX.class);
anim.put("lava", TextureLavaFX.class);
anim.put("waterflow", TextureWaterFlowFX.class);
anim.put("water", TextureWaterFX.class);
}
}

View file

@ -1,57 +0,0 @@
package client.network;
import client.Game;
import common.network.IClientLoginHandler;
import common.network.NetConnection;
import common.network.NetHandler;
import common.network.PacketRegistry;
import common.packet.RPacketDisconnect;
import common.packet.RPacketEnableCompression;
import common.packet.RPacketLoginSuccess;
public class ClientLoginHandler extends NetHandler implements IClientLoginHandler {
private final Game gm;
private final NetConnection networkManager;
public ClientLoginHandler(NetConnection conn, Game gmIn) {
this.networkManager = conn;
this.gm = gmIn;
}
public void onDisconnect(String reason)
{
this.gm.disconnected(reason);
}
public final void handleDisconnect(RPacketDisconnect packetIn)
{
this.networkManager.closeChannel(packetIn.getReason());
}
public void handleLoginSuccess(RPacketLoginSuccess packetIn)
{
this.networkManager.setConnectionState(PacketRegistry.PLAY);
this.networkManager.setNetHandler(new ClientPlayer(this.gm, this.networkManager));
}
public final void handleEnableCompression(RPacketEnableCompression packetIn)
{
this.networkManager.setCompressionTreshold(packetIn.getValue());
}
// public void handlePasswordRequest(RPacketPasswordRequest packetIn) {
// if(this.server == null) {
// this.networkManager.sendPacket(new LPacketPasswordResponse(this.user, "", ""));
// }
// else if((packetIn.getPasswordRequested() && this.server.pass.isEmpty()) ||
// (packetIn.getPasswordProtected() && this.server.access.isEmpty())) {
//// this.toChange = this.gm.getConnected();
// this.accessRequired = packetIn.getPasswordProtected() && this.server.access.isEmpty();
// this.passwordRequired = packetIn.getPasswordRequested() && this.server.pass.isEmpty();
// this.networkManager.closeChannel("");
// }
// else {
// this.networkManager.sendPacket(new LPacketPasswordResponse(this.user, this.access, this.pass));
// }
// }
}

View file

@ -1,156 +0,0 @@
package client.renderer;
import org.lwjgl.opengl.GL11;
import common.log.Log;
public class VertexFormatElement
{
private final VertexFormatElement.EnumType type;
private final VertexFormatElement.EnumUsage usage;
private int index;
private int elementCount;
public VertexFormatElement(int indexIn, VertexFormatElement.EnumType typeIn, VertexFormatElement.EnumUsage usageIn, int count)
{
if (!this.isValid(indexIn, usageIn))
{
Log.JNI.warn("Mehrere Vertex-Elemente des gleichen Typs außer UVs sind nicht unterstützt. Erzwinge Typ UV.");
this.usage = VertexFormatElement.EnumUsage.UV;
}
else
{
this.usage = usageIn;
}
this.type = typeIn;
this.index = indexIn;
this.elementCount = count;
}
private final boolean isValid(int index, VertexFormatElement.EnumUsage usage)
{
return index == 0 || usage == VertexFormatElement.EnumUsage.UV;
}
public final VertexFormatElement.EnumType getType()
{
return this.type;
}
public final VertexFormatElement.EnumUsage getUsage()
{
return this.usage;
}
public final int getElementCount()
{
return this.elementCount;
}
public final int getIndex()
{
return this.index;
}
public String toString()
{
return this.elementCount + "," + this.usage.getDisplayName() + "," + this.type.getDisplayName();
}
public final int getSize()
{
return this.type.getSize() * this.elementCount;
}
public final boolean isPositionElement()
{
return this.usage == VertexFormatElement.EnumUsage.POSITION;
}
public boolean equals(Object p_equals_1_)
{
if (this == p_equals_1_)
{
return true;
}
else if (p_equals_1_ != null && this.getClass() == p_equals_1_.getClass())
{
VertexFormatElement vertexformatelement = (VertexFormatElement)p_equals_1_;
return this.elementCount != vertexformatelement.elementCount ? false : (this.index != vertexformatelement.index ? false : (this.type != vertexformatelement.type ? false : this.usage == vertexformatelement.usage));
}
else
{
return false;
}
}
public int hashCode()
{
int i = this.type.hashCode();
i = 31 * i + this.usage.hashCode();
i = 31 * i + this.index;
i = 31 * i + this.elementCount;
return i;
}
public static enum EnumType
{
FLOAT(4, "Float", GL11.GL_FLOAT),
UBYTE(1, "Unsigned Byte", GL11.GL_UNSIGNED_BYTE),
BYTE(1, "Byte", GL11.GL_BYTE),
USHORT(2, "Unsigned Short", GL11.GL_UNSIGNED_SHORT),
SHORT(2, "Short", GL11.GL_SHORT),
UINT(4, "Unsigned Int", GL11.GL_UNSIGNED_INT),
INT(4, "Int", GL11.GL_INT);
private final int size;
private final String displayName;
private final int glConstant;
private EnumType(int sizeIn, String displayNameIn, int glConstantIn)
{
this.size = sizeIn;
this.displayName = displayNameIn;
this.glConstant = glConstantIn;
}
public int getSize()
{
return this.size;
}
public String getDisplayName()
{
return this.displayName;
}
public int getGlConstant()
{
return this.glConstant;
}
}
public static enum EnumUsage
{
POSITION("Position"),
NORMAL("Normal"),
COLOR("Vertex Color"),
UV("UV"),
// MATRIX("Bone Matrix"),
// BLEND_WEIGHT("Blend Weight"),
PADDING("Padding");
private final String displayName;
private EnumUsage(String displayNameIn)
{
this.displayName = displayNameIn;
}
public String getDisplayName()
{
return this.displayName;
}
}
}

View file

@ -1,153 +0,0 @@
package client.renderer.blockmodel;
import java.util.ArrayList;
import java.util.List;
import client.renderer.texture.TextureAtlasSprite;
import common.collect.Lists;
import common.model.Transforms;
import common.world.Facing;
public class BakedModel implements IBakedModel
{
protected final List<BakedQuad> generalQuads;
protected final List<List<BakedQuad>> faceQuads;
protected final boolean ambientOcclusion;
protected final boolean gui3d;
protected final TextureAtlasSprite texture;
protected final Transforms cameraTransforms;
public BakedModel(List<BakedQuad> generalQuadsIn, List<List<BakedQuad>> faceQuadsIn, boolean ambientOcclusionIn, boolean gui3dIn, TextureAtlasSprite textureIn, Transforms cameraTransformsIn)
{
this.generalQuads = generalQuadsIn;
this.faceQuads = faceQuadsIn;
this.ambientOcclusion = ambientOcclusionIn;
this.gui3d = gui3dIn;
this.texture = textureIn;
this.cameraTransforms = cameraTransformsIn;
}
public List<BakedQuad> getFaceQuads(Facing facing)
{
return this.faceQuads.get(facing.ordinal());
}
public List<BakedQuad> getGeneralQuads()
{
return this.generalQuads;
}
public boolean isAmbientOcclusion()
{
return this.ambientOcclusion;
}
public boolean isGui3d()
{
return this.gui3d;
}
public boolean isBuiltInRenderer()
{
return false;
}
public TextureAtlasSprite getParticleTexture()
{
return this.texture;
}
public Transforms getItemCameraTransforms()
{
return this.cameraTransforms;
}
public static class Builder
{
private final List<BakedQuad> builderGeneralQuads;
private final List<List<BakedQuad>> builderFaceQuads;
private final boolean builderAmbientOcclusion;
private TextureAtlasSprite builderTexture;
private boolean builderGui3d;
private Transforms builderCameraTransforms;
public Builder(ModelBlock model)
{
this(model.isAmbientOcclusion(), model.isGui3d(), model.getTransform());
}
public Builder(IBakedModel bakedModel, TextureAtlasSprite texture)
{
this(bakedModel.isAmbientOcclusion(), bakedModel.isGui3d(), bakedModel.getItemCameraTransforms());
this.builderTexture = bakedModel.getParticleTexture();
for (Facing enumfacing : Facing.values())
{
this.addFaceBreakingFours(bakedModel, texture, enumfacing);
}
this.addGeneralBreakingFours(bakedModel, texture);
}
private void addFaceBreakingFours(IBakedModel bakedModel, TextureAtlasSprite texture, Facing facing)
{
for (BakedQuad bakedquad : bakedModel.getFaceQuads(facing))
{
this.addFaceQuad(facing, new BreakingFour(bakedquad, texture));
}
}
private void addGeneralBreakingFours(IBakedModel p_177647_1_, TextureAtlasSprite texture)
{
for (BakedQuad bakedquad : p_177647_1_.getGeneralQuads())
{
this.addGeneralQuad(new BreakingFour(bakedquad, texture));
}
}
private Builder(boolean ambientOcclusion, boolean gui3d, Transforms cameraTransforms)
{
this.builderGeneralQuads = Lists.<BakedQuad>newArrayList();
this.builderFaceQuads = new ArrayList<List<BakedQuad>>(6);
for (Facing enumfacing : Facing.values())
{
this.builderFaceQuads.add(Lists.<BakedQuad>newArrayList());
}
this.builderAmbientOcclusion = ambientOcclusion;
this.builderGui3d = gui3d;
this.builderCameraTransforms = cameraTransforms;
}
public BakedModel.Builder addFaceQuad(Facing facing, BakedQuad quad)
{
((List)this.builderFaceQuads.get(facing.ordinal())).add(quad);
return this;
}
public BakedModel.Builder addGeneralQuad(BakedQuad quad)
{
this.builderGeneralQuads.add(quad);
return this;
}
public BakedModel.Builder setTexture(TextureAtlasSprite texture)
{
this.builderTexture = texture;
return this;
}
public BakedModel makeBakedModel()
{
if (this.builderTexture == null)
{
throw new RuntimeException("Missing particle!");
}
else
{
return new BakedModel(this.builderGeneralQuads, this.builderFaceQuads, this.builderAmbientOcclusion, this.builderGui3d, this.builderTexture, this.builderCameraTransforms);
}
}
}
}

View file

@ -1,52 +0,0 @@
package client.renderer.blockmodel;
import java.util.List;
import client.renderer.texture.TextureAtlasSprite;
import common.model.Transforms;
import common.world.Facing;
public class BuiltInModel implements IBakedModel
{
private Transforms cameraTransforms;
public BuiltInModel(Transforms p_i46086_1_)
{
this.cameraTransforms = p_i46086_1_;
}
public List<BakedQuad> getFaceQuads(Facing facing)
{
return null;
}
public List<BakedQuad> getGeneralQuads()
{
return null;
}
public boolean isAmbientOcclusion()
{
return false;
}
public boolean isGui3d()
{
return true;
}
public boolean isBuiltInRenderer()
{
return true;
}
public TextureAtlasSprite getParticleTexture()
{
return null;
}
public Transforms getItemCameraTransforms()
{
return this.cameraTransforms;
}
}

View file

@ -1,24 +0,0 @@
package client.renderer.blockmodel;
import java.util.List;
import client.renderer.texture.TextureAtlasSprite;
import common.model.Transforms;
import common.world.Facing;
public interface IBakedModel
{
List<BakedQuad> getFaceQuads(Facing facing);
List<BakedQuad> getGeneralQuads();
boolean isAmbientOcclusion();
boolean isGui3d();
boolean isBuiltInRenderer();
TextureAtlasSprite getParticleTexture();
Transforms getItemCameraTransforms();
}

View file

@ -1,36 +0,0 @@
package client.renderer.model;
import common.entity.Entity;
public class ModelHumanoidHead extends ModelHead
{
private final ModelRenderer head = new ModelRenderer(this, 32, 0);
public ModelHumanoidHead()
{
super(0, 0, 64, 64);
this.head.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.25F);
this.head.setRotationPoint(0.0F, 0.0F, 0.0F);
}
/**
* Sets the models various rotation angles then renders the model.
*/
public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale)
{
super.render(entityIn, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale);
this.head.render(scale);
}
/**
* Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
* and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
* "far" arms and legs can swing at most.
*/
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
this.head.rotateAngleY = this.mainHead.rotateAngleY;
this.head.rotateAngleX = this.mainHead.rotateAngleX;
}
}

View file

@ -1,76 +0,0 @@
package client.renderer.tileentity;
import org.lwjgl.opengl.GL11;
import client.renderer.GlState;
import common.block.Block;
import common.init.Blocks;
import common.init.Items;
import common.item.ItemStack;
import common.tileentity.TileEntityBanner;
import common.tileentity.TileEntityChest;
import common.tileentity.TileEntitySkull;
import common.world.Facing;
public class TileEntityItemStackRenderer
{
public static TileEntityItemStackRenderer instance = new TileEntityItemStackRenderer();
private TileEntityChest field_147717_b = new TileEntityChest(0);
private TileEntityChest field_147718_c = new TileEntityChest(1);
// private TileEntityWarpChest warpChest = new TileEntityWarpChest();
private TileEntityBanner banner = new TileEntityBanner();
private TileEntitySkull skull = new TileEntitySkull();
public void renderByItem(ItemStack itemStackIn)
{
if (itemStackIn.getItem() == Items.banner)
{
this.banner.setItemValues(itemStackIn);
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
}
else if (itemStackIn.getItem() == Items.skull)
{
// String user = null;
//
// if (itemStackIn.hasTagCompound())
// {
// NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();
//
// if (nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0)
// {
// user = nbttagcompound.getString("SkullOwner");
// }
// }
if (TileEntitySkullRenderer.instance != null)
{
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
GL11.glScalef(2.0F, 2.0F, 2.0F);
boolean flag = GlState.isCullEnabled();
GlState.disableCull();
TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, Facing.UP, 0.0F, -1);
if(flag)
GlState.enableCull();
GL11.glPopMatrix();
}
}
else
{
Block block = itemStackIn.getItem().getBlock();
// if (block == Blocks.warp_chest)
// {
// TileEntityRendererDispatcher.instance.renderTileEntityAt(this.warpChest, 0.0D, 0.0D, 0.0D, 0.0F);
// }
if (block == Blocks.trapped_chest)
{
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F);
}
else
{
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F);
}
}
}
}

View file

@ -1,38 +0,0 @@
package client.renderer.tileentity;
import org.lwjgl.opengl.GL11;
import client.Game;
import common.entity.Entity;
import common.tileentity.TileEntityMobSpawner;
public class TileEntityMobSpawnerRenderer extends TileEntitySpecialRenderer<TileEntityMobSpawner>
{
public void renderTileEntityAt(TileEntityMobSpawner te, double x, double y, double z, float partialTicks, int destroyStage)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y, (float)z + 0.5F);
renderMob(te, x, y, z, partialTicks);
GL11.glPopMatrix();
}
/**
* Render the mob inside the mob spawner.
*/
public static void renderMob(TileEntityMobSpawner mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks)
{
Entity entity = mobSpawnerLogic.createRenderEntity(mobSpawnerLogic.getWorld());
if (entity != null)
{
float f = 0.4375F;
GL11.glTranslatef(0.0F, 0.4F, 0.0F);
GL11.glRotatef((float)(mobSpawnerLogic.getPrevMobRotation() + (mobSpawnerLogic.getMobRotation() - mobSpawnerLogic.getPrevMobRotation()) * (double)partialTicks) * 10.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0F, -0.4F, 0.0F);
GL11.glScalef(f, f, f);
entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
Game.getGame().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, partialTicks);
}
}
}

View file

@ -1,124 +0,0 @@
package client.renderer.tileentity;
import org.lwjgl.opengl.GL11;
import client.renderer.GlState;
import client.renderer.model.ModelHumanoidHead;
import common.tileentity.TileEntitySkull;
import common.world.Facing;
public class TileEntitySkullRenderer extends TileEntitySpecialRenderer<TileEntitySkull>
{
private static final String TEXTURE_SKULL = "textures/entity/skull.png";
public static TileEntitySkullRenderer instance;
private final ModelHumanoidHead humanoidHead = new ModelHumanoidHead();
public void renderTileEntityAt(TileEntitySkull te, double x, double y, double z, float partialTicks, int destroyStage)
{
Facing enumfacing = Facing.getFront(te.getBlockMetadata() & 7);
this.renderSkull((float)x, (float)y, (float)z, enumfacing, (float)(te.getSkullRotation() * 360) / 16.0F, destroyStage);
}
public void setRendererDispatcher(TileEntityRendererDispatcher rendererDispatcherIn)
{
super.setRendererDispatcher(rendererDispatcherIn);
instance = this;
}
public void renderSkull(float x, float y, float z, Facing dir, float rot, int destroyStage)
{
// ModelBase modelbase = this.skeletonHead;
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glScalef(4.0F, 2.0F, 1.0F);
GL11.glTranslatef(0.0625F, 0.0625F, 0.0625F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
else
{
// switch (p_180543_6_)
// {
// case 0:
// default:
// this.bindTexture(SKELETON_TEXTURES);
// break;
//
// case 1:
// this.bindTexture(WITHER_SKELETON_TEXTURES);
// break;
//
// case 2:
// this.bindTexture(ZOMBIE_TEXTURES);
// modelbase = this.humanoidHead;
// break;
//
// case 3:
// modelbase = this.humanoidHead;
// String tex = TEXTURE_SKULL; // EntitySkinManager.TEXTURE_DEF;
// if (user != null && EntityTexManager.getModel(user) == ModelType.HUMANOID)
// {
// tex = EntityTexManager.getSkin(user, ModelType.HUMANOID);
// }
this.bindTexture(TEXTURE_SKULL);
// break;
//
// case 4:
// this.bindTexture(CREEPER_TEXTURES);
// }
}
GL11.glPushMatrix();
GlState.disableCull();
if (dir != Facing.UP)
{
switch (dir)
{
case NORTH:
GL11.glTranslatef(x + 0.5F, y + 0.25F, z + 0.74F);
break;
case SOUTH:
GL11.glTranslatef(x + 0.5F, y + 0.25F, z + 0.26F);
rot = 180.0F;
break;
case WEST:
GL11.glTranslatef(x + 0.74F, y + 0.25F, z + 0.5F);
rot = 270.0F;
break;
case EAST:
default:
GL11.glTranslatef(x + 0.26F, y + 0.25F, z + 0.5F);
rot = 90.0F;
}
}
else
{
GL11.glTranslatef(x + 0.5F, y, z + 0.5F);
}
float f = 0.0625F;
GlState.enableRescaleNormal();
GL11.glScalef(-1.0F, -1.0F, 1.0F);
GlState.enableAlpha();
this.humanoidHead.render(null, 0.0F, 0.0F, 0.0F, rot, 0.0F, f);
GL11.glPopMatrix();
if (destroyStage >= 0)
{
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
}
}

View file

@ -1,13 +0,0 @@
package client.window;
public class WindowEvent {
public final WindowAction action;
public final int param1;
public final int param2;
public WindowEvent(WindowAction action, int p1, int p2) {
this.action = action;
this.param1 = p1;
this.param2 = p2;
}
}

View file

@ -11,7 +11,6 @@ import javax.sound.sampled.DataLine.Info;
import common.collect.Lists; import common.collect.Lists;
import common.log.Log; import common.log.Log;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine; import javax.sound.sampled.SourceDataLine;
public class AudioInterface implements Runnable { public class AudioInterface implements Runnable {
@ -138,12 +137,12 @@ public class AudioInterface implements Runnable {
public void run() { public void run() {
AudioFormat format = new AudioFormat(Encoding.PCM_SIGNED, 48000, 16, 2, 2 * 2, 48000, false); AudioFormat format = new AudioFormat(Encoding.PCM_SIGNED, 48000, 16, 2, 2 * 2, 48000, false);
Info info = new Info(SourceDataLine.class, format, this.devbufsize); Info info = new Info(SourceDataLine.class, format, this.devbufsize == 0 ? AudioSystem.NOT_SPECIFIED : this.devbufsize);
try { try {
this.line = (SourceDataLine)AudioSystem.getLine(info); this.line = (SourceDataLine)AudioSystem.getLine(info);
this.line.open(format, this.devbufsize); this.line.open(format, this.devbufsize == 0 ? AudioSystem.NOT_SPECIFIED : this.devbufsize);
} }
catch(LineUnavailableException e) { catch(Exception e) {
this.line = null; this.line = null;
Log.SOUND.error(e, "Konnte Audiogerät nicht öffnen"); Log.SOUND.error(e, "Konnte Audiogerät nicht öffnen");
} }

View file

@ -10,7 +10,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import client.Game; import client.Client;
import client.util.FileUtils;
import common.collect.BiMap; import common.collect.BiMap;
import common.collect.HashBiMap; import common.collect.HashBiMap;
import common.collect.Lists; import common.collect.Lists;
@ -22,7 +23,6 @@ import common.rng.Random;
import common.sound.MovingSound; import common.sound.MovingSound;
import common.sound.Sound; import common.sound.Sound;
import common.util.ExtMath; import common.util.ExtMath;
import common.util.FileUtils;
public class SoundManager { public class SoundManager {
private class Source { private class Source {
@ -85,7 +85,7 @@ public class SoundManager {
private final Map<String, Integer> playingSoundsStopTime = Maps.<String, Integer>newHashMap(); private final Map<String, Integer> playingSoundsStopTime = Maps.<String, Integer>newHashMap();
private final Map<String, Source> sources = new HashMap<String, Source>(); private final Map<String, Source> sources = new HashMap<String, Source>();
private final String[] channels = new String[28]; private final String[] channels = new String[28];
private final Game gm; private final Client gm;
private float listenerX; private float listenerX;
private float listenerY; private float listenerY;
@ -94,7 +94,7 @@ public class SoundManager {
private int playTime = 0; private int playTime = 0;
private int eventId = 0; private int eventId = 0;
public SoundManager(Game gm) { public SoundManager(Client gm) {
this.gm = gm; this.gm = gm;
} }
@ -238,8 +238,8 @@ public class SoundManager {
this.sources.put(s, new Source(getBuffer(sound.getSoundLocation()), Volume.getByType(sound.getChannelType()), sound.canRepeat(), s, sound.getXPosF(), sound.getYPosF(), sound.getZPosF(), sound.getAttenuationType(), attn, volume)); this.sources.put(s, new Source(getBuffer(sound.getSoundLocation()), Volume.getByType(sound.getChannelType()), sound.canRepeat(), s, sound.getXPosF(), sound.getYPosF(), sound.getZPosF(), sound.getAttenuationType(), attn, volume));
this.playingSoundsStopTime.put(s, this.playTime + 20); this.playingSoundsStopTime.put(s, this.playTime + 20);
this.playingSounds.put(s, sound); this.playingSounds.put(s, sound);
if (sound instanceof MovingSound) if (sound instanceof MovingSound moving)
this.tickableSounds.add((MovingSound)sound); this.tickableSounds.add(moving);
} }
} }

View file

@ -1,7 +1,8 @@
package client.audio; package client.audio;
import client.Game; import client.Client;
import client.gui.element.Slider; import client.gui.element.Slider;
import client.gui.element.SliderCallback;
import client.vars.CVar; import client.vars.CVar;
import client.vars.CVarCategory; import client.vars.CVarCategory;
import common.color.TextColor; import common.color.TextColor;
@ -91,12 +92,12 @@ public enum Volume implements CVar {
} }
public void apply() { public void apply() {
if(Game.getGame().getAudioInterface() != null) if(Client.CLIENT.getAudioInterface() != null)
Game.getGame().getAudioInterface().alSetVolume(this, (short)(((float)this.value) / 100.0f * 32767.0f)); Client.CLIENT.getAudioInterface().alSetVolume(this, (short)(((float)this.value) / 100.0f * 32767.0f));
} }
public Slider selector(int x, int y, int w, int h) { public Slider selector(int x, int y, int w, int h) {
return new Slider(x, y, w, h, 0, 0, 100, 100, this.value, new Slider.Callback() { return new Slider(x, y, w, h, 0, 0, 100, 100, this.value, new SliderCallback() {
public void use(Slider elem, int value) { public void use(Slider elem, int value) {
Volume.this.value = value; Volume.this.value = value;
Volume.this.apply(); Volume.this.apply();

View file

@ -8,13 +8,14 @@ import org.lwjgl.opengl.GL11;
import client.renderer.GlState; import client.renderer.GlState;
import client.renderer.texture.TextureUtil; import client.renderer.texture.TextureUtil;
import client.util.FileUtils;
import common.log.Log; import common.log.Log;
import common.util.FileUtils;
public class Font { public class Font {
public static final FontChar[] SIZES = new FontChar[256]; public static final FontChar[] SIZES = new FontChar[256];
public static final int XGLYPH = 12;
public static final int YGLYPH = 18; public static int XGLYPH = 12;
public static int YGLYPH = 14;
private static int texture; private static int texture;
@ -72,10 +73,12 @@ public class Font {
} }
} }
public static void load() { public static void load(boolean tiny) {
XGLYPH = tiny ? 6 : 12;
YGLYPH = tiny ? 7 : 14;
BufferedImage img = null; BufferedImage img = null;
try { try {
img = TextureUtil.readImage(FileUtils.getResource("textures/font.png")); img = TextureUtil.readImage(FileUtils.getResource("textures/font" + (tiny ? "_tiny" : "") + ".png"));
} }
catch(FileNotFoundException e) { catch(FileNotFoundException e) {
Log.IO.error("Konnte Font-Textur nicht laden: Datei nicht vorhanden"); Log.IO.error("Konnte Font-Textur nicht laden: Datei nicht vorhanden");

View file

@ -4,7 +4,7 @@ import java.util.List;
import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL13;
import client.Game; import client.Client;
import client.gui.element.Dropdown; import client.gui.element.Dropdown;
import client.gui.element.Dropdown.Handle; import client.gui.element.Dropdown.Handle;
import client.gui.element.Element; import client.gui.element.Element;
@ -16,11 +16,11 @@ import client.window.Keysym;
import common.collect.Lists; import common.collect.Lists;
public abstract class Gui { public abstract class Gui {
public static final String DIRT_BACKGROUND = "textures/background.png"; public static final String BACKGROUND = "textures/background.png";
public static final int HOVER_COLOR = 0x288080ff; public static final int HOVER_COLOR = 0x288080ff;
public static final int PRESS_COLOR = 0x30afafff; public static final int PRESS_COLOR = 0x30afafff;
protected final Game gm = Game.getGame(); protected final Client gm = Client.CLIENT;
public Element selected; public Element selected;
private int min_x; private int min_x;
@ -176,8 +176,8 @@ public abstract class Gui {
this.min_y = Math.min(this.min_y, elem.getY()); this.min_y = Math.min(this.min_y, elem.getY());
this.max_x = Math.max(this.max_x, elem.getX() + elem.getWidth()); this.max_x = Math.max(this.max_x, elem.getX() + elem.getWidth());
this.max_y = Math.max(this.max_y, elem.getY() + elem.getHeight()); this.max_y = Math.max(this.max_y, elem.getY() + elem.getHeight());
if(elem instanceof Dropdown) if(elem instanceof Dropdown drop)
this.add(((Dropdown)elem).getHandle()); this.add(drop.getHandle());
return elem; return elem;
} }
@ -301,13 +301,13 @@ public abstract class Gui {
// } // }
public void drawMainBackground() { public void drawMainBackground() {
if(this.gm.theWorld != null && !this.gm.charEditor) { if(this.gm.world != null && !this.gm.charEditor) {
// Drawing.drawGradient(0, 0, this.fb_x, this.fb_y, this.theWorld == null ? this.style.bg_top : 0x3f202020, // Drawing.drawGradient(0, 0, this.fb_x, this.fb_y, this.theWorld == null ? this.style.bg_top : 0x3f202020,
// this.theWorld == null ? this.style.bg_btm : 0x3f000000); // this.theWorld == null ? this.style.bg_btm : 0x3f000000);
Drawing.drawGradient(0, 0, this.gm.fb_x, this.gm.fb_y, 0xc0101010, 0xd0101010); Drawing.drawGradient(0, 0, this.gm.fb_x, this.gm.fb_y, 0xc0101010, 0xd0101010);
} }
else { else {
Drawing.drawScaled(this.gm, DIRT_BACKGROUND); Drawing.drawScaled(this.gm, BACKGROUND);
} }
} }

View file

@ -1,20 +1,22 @@
package client.gui; package client.gui;
import client.gui.element.ActButton; import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode; import client.gui.element.ButtonCallback;
import client.gui.element.Label; import client.gui.element.Label;
import client.gui.element.TransparentBox; import client.gui.element.MultiLabel;
import client.gui.element.PressType;
public class GuiConfirm extends Gui implements ActButton.Callback { public class GuiConfirm extends Gui implements ButtonCallback {
public static interface Callback { public static interface Callback {
void confirm(boolean confirmed); void confirm(boolean confirmed);
} }
protected Callback callback; private final Callback callback;
protected String messageLine1; private final String messageLine1;
private String messageLine2; private final String messageLine2;
protected String confirmButtonText; private final String confirmButtonText;
protected String cancelButtonText; private final String cancelButtonText;
private ActButton confirmBtn; private ActButton confirmBtn;
private ActButton cancelBtn; private ActButton cancelBtn;
@ -27,10 +29,10 @@ public class GuiConfirm extends Gui implements ActButton.Callback {
} }
public void init(int width, int height) { public void init(int width, int height) {
this.add(new Label(0, 0, 500, 24, this.messageLine1, true)); this.add(new Label(0, 0, 700, 0, this.messageLine1));
this.add(new TransparentBox(0, 80, 500, 300, this.messageLine2, this.gm.theWorld != null && !this.gm.charEditor)); this.add(new MultiLabel(0, 40, 700, 300, this.messageLine2, true));
this.confirmBtn = this.add(new ActButton(48, 500, 200, 24, this, this.confirmButtonText)); this.confirmBtn = this.add(new ActButton(100, 400, 245, 0, this, this.confirmButtonText));
this.cancelBtn = this.add(new ActButton(252, 500, 200, 24, this, this.cancelButtonText)); this.cancelBtn = this.add(new ActButton(355, 400, 245, 0, this, this.cancelButtonText));
this.shift(); this.shift();
} }
@ -38,7 +40,7 @@ public class GuiConfirm extends Gui implements ActButton.Callback {
return "Aktion bestätigen"; return "Aktion bestätigen";
} }
public void use(ActButton btn, Mode mode) { public void use(ActButton btn, PressType mode) {
this.callback.confirm(btn == this.confirmBtn); this.callback.confirm(btn == this.confirmBtn);
} }
} }

View file

@ -0,0 +1,379 @@
package client.gui;
import java.io.File;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import client.gui.element.ActButton;
import client.gui.element.ButtonCallback;
import client.gui.element.GuiList;
import client.gui.element.ListEntry;
import client.gui.element.NavButton;
import client.gui.element.PressType;
import client.renderer.Drawing;
import client.util.FileUtils;
import common.color.TextColor;
import common.log.Log;
import common.network.IPlayer;
import common.util.EncryptUtil;
import common.util.Pair;
import common.util.Util;
public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements ButtonCallback {
public class ServerInfo implements Comparable<ServerInfo>, ListEntry {
private final boolean direct;
private String name;
private String address;
private int port;
private String user;
private String password;
private String access;
private KeyPair keypair;
private String keyDigest;
private PublicKey serverKey;
private String serverDigest;
private boolean enforceEncryption;
private long lastConnected;
public ServerInfo(String address, int port, String user, String password, String access) {
this.direct = true;
this.name = DIRECT_NAME;
this.address = address;
this.port = port;
this.user = user;
this.password = password;
this.access = access;
this.lastConnected = -1L;
}
public ServerInfo(String name, String address, int port, String user, String password, String access, KeyPair keypair, long lastConnected, PublicKey serverKey, boolean enforceEnc) {
this.direct = false;
this.name = name;
this.address = address;
this.port = port;
this.user = user;
this.password = password;
this.access = access;
this.keypair = keypair;
this.lastConnected = lastConnected;
this.serverKey = serverKey;
this.enforceEncryption = enforceEnc;
if(this.keypair != null)
this.keyDigest = EncryptUtil.getXorSha512Hash(this.keypair.getPublic().getEncoded());
if(this.serverKey != null)
this.serverDigest = EncryptUtil.getXorSha512Hash(this.serverKey.getEncoded());
}
public boolean isDirect() {
return this.direct;
}
public String getName() {
return this.name;
}
public String getAddress() {
return this.address;
}
public int getPort() {
return this.port;
}
public String getUser() {
return this.user;
}
public String getPassword() {
return this.password;
}
public String getAccess() {
return this.access;
}
public KeyPair getKeypair() {
return this.keypair;
}
public PublicKey getServerKey() {
return this.serverKey;
}
public boolean requiresEncryption() {
return this.enforceEncryption;
}
public long getLastConnected() {
return this.lastConnected;
}
public void setData(String name, String address, int port, String user, String password, String access, KeyPair keypair, PublicKey serverKey, boolean encryptReq) {
this.name = name;
this.address = address;
this.port = port;
this.user = user;
this.password = password;
this.access = access;
this.keypair = keypair;
this.serverKey = serverKey;
this.enforceEncryption = encryptReq;
this.keyDigest = this.keypair != null ? EncryptUtil.getXorSha512Hash(this.keypair.getPublic().getEncoded()) : null;
this.serverDigest = this.serverKey != null ? EncryptUtil.getXorSha512Hash(this.serverKey.getEncoded()) : null;
}
public void setLastConnected() {
this.lastConnected = System.currentTimeMillis();
}
public void setServerKey(PublicKey key) {
this.serverKey = key;
this.serverDigest = this.serverKey != null ? EncryptUtil.getXorSha512Hash(this.serverKey.getEncoded()) : null;
}
public int compareTo(ServerInfo comp) {
return this.lastConnected < comp.lastConnected ? 1 : (this.lastConnected > comp.lastConnected ? -1 : this.name.compareTo(comp.name));
}
public void select(boolean isDoubleClick, int mouseX, int mouseY) {
GuiConnect.this.selectButton.enabled = true;
GuiConnect.this.deleteButton.enabled = true;
GuiConnect.this.editButton.enabled = true;
GuiConnect.this.copyButton.enabled = true;
if(isDoubleClick) {
GuiConnect.this.use(GuiConnect.this.selectButton, PressType.PRIMARY);
}
}
public void draw(int x, int y, int width, int height, int mouseXIn, int mouseYIn, boolean hover) {
Drawing.drawText(this.name + TextColor.GRAY + " - " + TextColor.RESET + this.user, x + 2, y, 0xffffffff);
if(this.keypair != null || !this.password.isEmpty())
Drawing.drawTextRight(
(this.keypair != null ? "Pubkey " + this.keyDigest : "") + (this.keypair != null && !this.password.isEmpty() ? " + " : "") + (!this.password.isEmpty() ? "Passwort" : ""),
x + width - 2, y, 0xffffffff);
Drawing.drawText(this.address + TextColor.GRAY + " Port " + TextColor.RESET + this.port + (this.enforceEncryption ? TextColor.GRAY + ", nur verschlüsselt" : ""),
x + 2, y + height - Font.YGLYPH * 2, 0xffb0b0b0);
if(!this.access.isEmpty())
Drawing.drawTextRight((this.keypair != null || !this.password.isEmpty() ? "+ " : "") + "Server-Passwort", x + width - 2, y + height - Font.YGLYPH * 2, 0xffb0b0b0);
Drawing.drawText("Zuletzt verbunden: " + (this.lastConnected == -1L ? "nie" : DATE_FORMAT.format(new Date(this.lastConnected))), x + 2, y + height - Font.YGLYPH, 0xffb0b0b0);
if(this.serverDigest != null)
Drawing.drawTextRight("Server-ID: " + this.serverDigest, x + width - 2, y + height - Font.YGLYPH, 0xffb0b0b0);
}
}
public static final GuiConnect INSTANCE = new GuiConnect();
private static final String DIRECT_NAME = "<Direktverbindung>";
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
private static final File SERVERS_FILE = new File("servers.cfg");
private ActButton deleteButton;
private ActButton selectButton;
private ActButton copyButton;
private ActButton editButton;
private ActButton createButton;
private GuiConnect() {
}
public void init(int width, int height) {
super.init(width, height);
this.setDimensions(width, height, 32, height - 32);
this.elements.clear();
if(SERVERS_FILE.exists()) {
try {
String[] lines = FileUtils.read(SERVERS_FILE).split("\n");
String name = "";
String address = "";
int port = -1;
String user = "";
String password = "";
String access = "";
byte[] key = null;
byte[] pubkey = null;
byte[] serverKey = null;
boolean enforceEnc = false;
long time = -1L;
for(int z = 0; z <= lines.length; z++) {
String line = z == lines.length ? null : lines[z];
if(line == null || (line.startsWith("[") && line.endsWith("]"))) {
if(!name.isEmpty() && !address.isEmpty() && !user.isEmpty() && user.length() < IPlayer.MAX_USER_LENGTH && IPlayer.isValidUser(user) &&
password.length() < IPlayer.MAX_PASS_LENGTH && access.length() < IPlayer.MAX_PASS_LENGTH && address.length() < 128 && name.length() < 128 &&
port >= 1024 && port <= 32767 && (password.length() >= 8 || password.isEmpty()) && (access.length() >= 8 || access.isEmpty()) && !this.isNameTaken(name)) {
PrivateKey priv = key == null ? null : EncryptUtil.decodePrivateKey(key);
PublicKey pub = pubkey == null ? null : EncryptUtil.decodePublicKey(pubkey);
PublicKey serv = serverKey == null ? null : EncryptUtil.decodePublicKey(serverKey);
this.elements.add(new ServerInfo(name, address, port, user, password, access, priv == null || pub == null ? null : new KeyPair(pub, priv), time, serv, enforceEnc));
}
if(line != null) {
address = "";
port = -1;
user = "";
password = "";
access = "";
key = null;
pubkey = null;
serverKey = null;
enforceEnc = false;
time = -1L;
name = line.substring(1, line.length() - 1);
}
}
else {
Pair<String, String> value = Util.getKeyValue(line);
if(value.first().equals("address"))
address = value.second();
else if(value.first().equals("port"))
try {
port = Integer.parseInt(value.second());
}
catch(NumberFormatException e) {
}
else if(value.first().equals("user"))
user = value.second();
else if(value.first().equals("password"))
password = value.second();
else if(value.first().equals("access"))
access = value.second();
else if(value.first().equals("connected"))
try {
time = Long.parseLong(value.second());
}
catch(NumberFormatException e) {
}
else if(value.first().equals("encryption_enforced"))
enforceEnc = true;
else if(value.first().equals("serverkey"))
serverKey = Util.fromHexString(value.second());
else if(value.first().equals("key"))
key = Util.fromHexString(value.second());
else if(value.first().equals("pubkey"))
pubkey = Util.fromHexString(value.second());
}
}
Collections.sort(this.elements);
}
catch(Exception e) {
Log.IO.error("Konnte Serverliste nicht laden", e);
this.elements.clear();
}
}
this.add(this.selectButton = new ActButton(width / 2 - 379, height - 30, 150, 0, this, "Verbinden"));
this.add(this.createButton = new ActButton(width - 202, 12, 200, 0, this, "Server hinzufügen ..."));
this.add(this.deleteButton = new ActButton(width / 2 - 75, height - 30, 150, 0, this, "Löschen"));
this.add(this.editButton = new ActButton(width / 2 + 77, height - 30, 150, 0, this, "Bearbeiten"));
this.add(this.copyButton = new ActButton(width / 2 - 227, height - 30, 150, 0, this, "Kopieren"));
this.add(new NavButton(width / 2 + 229, height - 30, 150, 0, GuiMenu.INSTANCE, "Abbrechen"));
this.selectButton.enabled = false;
this.deleteButton.enabled = false;
this.editButton.enabled = false;
this.copyButton.enabled = false;
}
public void onGuiClosed() {
this.save();
}
public void applyServer(ServerInfo server) {
if(this.selectedElement < 0)
this.elements.add(server);
this.save();
this.gm.displayGuiScreen(this);
}
public boolean isNameTaken(String name) {
for(int z = 0; z < this.elements.size(); z++) {
if(this.selectedElement != z && this.elements.get(z).getName().equals(name))
return true;
}
return DIRECT_NAME.equals(name);
}
public void editServer(ServerInfo server) {
if(!server.isDirect())
this.save();
}
public void connect(String address, int port, String user, String pass, String access) {
this.gm.connect(new ServerInfo(address, port, user, pass, access));
}
private void save() {
try {
StringBuilder sb = new StringBuilder();
for(ServerInfo server : this.elements) {
if(sb.length() > 0)
sb.append("\n");
sb.append("[" + server.getName() + "]");
sb.append("\naddress " + server.getAddress());
sb.append("\nport " + server.getPort());
sb.append("\nuser " + server.getUser());
if(!server.getPassword().isEmpty())
sb.append("\npassword " + server.getPassword());
if(!server.getAccess().isEmpty())
sb.append("\naccess " + server.getAccess());
if(server.getKeypair() != null) {
sb.append("\nkey " + Util.getHexString(server.getKeypair().getPrivate().getEncoded()));
sb.append("\npubkey " + Util.getHexString(server.getKeypair().getPublic().getEncoded()));
}
if(server.requiresEncryption())
sb.append("\nencryption_enforced");
if(server.getLastConnected() != -1L)
sb.append("\nconnected " + server.getLastConnected());
if(server.getServerKey() != null)
sb.append("\nserverkey " + Util.getHexString(server.getServerKey().getEncoded()));
}
FileUtils.write(SERVERS_FILE, sb.toString());
}
catch(Exception e) {
Log.IO.error("Konnte Serverliste nicht speichern", e);
}
}
public String getTitle() {
return "Server auswählen";
}
public int getSlotHeight() {
return 56;
}
public void use(ActButton button, PressType mode) {
if(button == this.deleteButton) {
if(this.selectedElement >= 0) {
this.elements.remove(this.selectedElement);
this.gm.displayGuiScreen(this);
}
}
else if(button == this.selectButton) {
ServerInfo server = this.getSelected();
if(server != null) {
server.setLastConnected();
this.gm.connect(server);
}
}
else if(button == this.createButton) {
this.setSelected(-1);
this.gm.displayGuiScreen(new GuiServer(new ServerInfo("", "", -1, "", "", "", null, -1L, null, false)));
}
else if(button == this.editButton) {
ServerInfo server = this.getSelected();
if(server != null)
this.gm.displayGuiScreen(new GuiServer(server));
}
else if(button == this.copyButton) {
ServerInfo server = this.getSelected();
if(server != null) {
this.setSelected(-1);
this.gm.displayGuiScreen(new GuiServer(new ServerInfo(server.name, server.address, server.port, server.user, server.password, server.access, server.keypair, -1L, null, server.enforceEncryption)));
}
}
}
}

View file

@ -2,25 +2,28 @@ package client.gui;
import java.util.List; import java.util.List;
import client.Game; import client.Client;
import client.gui.element.ActButton; import client.gui.element.ActButton;
import client.gui.element.ButtonCallback;
import client.gui.element.Element;
import client.gui.element.Fill; import client.gui.element.Fill;
import client.gui.element.Textbox; import client.gui.element.PressType;
import client.gui.element.Textbox.Action; import client.gui.element.FieldAction;
import client.network.ClientPlayer; import client.gui.element.Field;
import client.gui.element.FieldCallback;
import client.vars.BoolVar; import client.vars.BoolVar;
import client.vars.CVar; import client.vars.CVar;
import client.gui.element.TransparentBox; import client.gui.element.TransparentArea;
import client.window.Keysym; import client.window.Keysym;
import common.collect.Lists; import common.collect.Lists;
import common.color.TextColor; import common.color.TextColor;
import common.network.IPlayer; import common.network.IPlayer;
import common.packet.CPacketComplete; import common.packet.CPacketComplete;
import common.util.BlockPos;
import common.util.ExtMath; import common.util.ExtMath;
import common.world.BlockPos; import common.util.HitPosition;
import common.world.HitPosition;
public class GuiConsole extends Gui implements Textbox.Callback { public class GuiConsole extends Gui implements FieldCallback {
public static final GuiConsole INSTANCE = new GuiConsole(); public static final GuiConsole INSTANCE = new GuiConsole();
private final List<String> sentMessages = Lists.<String>newArrayList(); private final List<String> sentMessages = Lists.<String>newArrayList();
@ -35,8 +38,8 @@ public class GuiConsole extends Gui implements Textbox.Callback {
private String prefixFirst; private String prefixFirst;
private int autocompleteIndex; private int autocompleteIndex;
private List<String> foundPlayerNames = Lists.<String>newArrayList(); private List<String> foundPlayerNames = Lists.<String>newArrayList();
private Textbox inputField; private Field inputField;
private TransparentBox logBox; private TransparentArea logBox;
public GuiConsole setFull(boolean full) { public GuiConsole setFull(boolean full) {
this.full = full; this.full = full;
@ -45,20 +48,20 @@ public class GuiConsole extends Gui implements Textbox.Callback {
public void init(int width, int height) { public void init(int width, int height) {
if(this.full) { if(this.full) {
this.addSelector("con_autoclose", 0, 0, 160, 24); this.addSelector("con_autoclose", 0, 0, 160, 0);
this.addSelector("con_timestamps", 160, 0, 160, 24); this.addSelector("con_timestamps", 160, 0, 160, 0);
this.addSelector("con_loglevel", 320, 0, 160, 24); this.addSelector("con_loglevel", 320, 0, 160, 0);
this.add(new ActButton(480, 0, 160, 24, new ActButton.Callback() { this.add(new ActButton(480, 0, 160, 0, new ButtonCallback() {
public void use(ActButton elem, ActButton.Mode action) { public void use(ActButton elem, PressType action) {
GuiConsole.this.reset(); GuiConsole.this.reset();
GuiConsole.this.setLog(GuiConsole.this.gm.getBuffer()); GuiConsole.this.setLog(GuiConsole.this.gm.getBuffer());
} }
}, "Löschen")); }, "Löschen"));
} }
this.logBox = this.add(new TransparentBox(0, this.full ? 24 : 0, width, height - (this.full ? 48 : 24), this.gm.getBuffer(), this.gm.theWorld != null && !this.gm.charEditor)); this.logBox = this.add(new TransparentArea(0, this.full ? Element.BASE_HEIGHT : 0, width, height - Element.BASE_HEIGHT * (this.full ? 2 : 1), this.gm.getBuffer(), this.gm.world != null && !this.gm.charEditor));
if(this.full) if(this.full)
this.add(new Fill(640, 0, width - 640, 24)); this.add(new Fill(640, 0, width - 640, 0));
this.inputField = this.add(new Textbox(0, height - 24, width, 24, IPlayer.MAX_CMD_LENGTH, true, this, "")); this.inputField = this.add(new Field(0, height - Element.BASE_HEIGHT, width, 0, IPlayer.MAX_CMD_LENGTH, this, ""));
this.inputField.setSelected(); this.inputField.setSelected();
this.sentHistoryCursor = this.sentMessages.size(); this.sentHistoryCursor = this.sentMessages.size();
} }
@ -79,7 +82,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
} }
public void drawMainBackground() { public void drawMainBackground() {
if(this.gm.theWorld == null || this.gm.charEditor) if(this.gm.world == null || this.gm.charEditor)
super.drawMainBackground(); super.drawMainBackground();
} }
@ -90,13 +93,13 @@ public class GuiConsole extends Gui implements Textbox.Callback {
this.playerNamesFound = false; this.playerNamesFound = false;
} }
public void use(Textbox elem, Action value) public void use(Field elem, FieldAction value)
{ {
this.waitingOnAutocomplete = false; this.waitingOnAutocomplete = false;
if (value == Action.FORWARD || value == Action.BACKWARD) if (value == FieldAction.FORWARD || value == FieldAction.BACKWARD)
{ {
this.reverse = value == Action.BACKWARD; this.reverse = value == FieldAction.BACKWARD;
this.autocompletePlayerNames(); this.autocompletePlayerNames();
} }
else else
@ -104,11 +107,11 @@ public class GuiConsole extends Gui implements Textbox.Callback {
this.playerNamesFound = false; this.playerNamesFound = false;
} }
if(value == Action.PREVIOUS) if(value == FieldAction.PREVIOUS)
this.getSentHistory(-1); this.getSentHistory(-1);
else if (value == Action.NEXT) else if (value == FieldAction.NEXT)
this.getSentHistory(1); this.getSentHistory(1);
if(value == Action.SEND) if(value == FieldAction.SEND)
{ {
String s = this.inputField.getText().trim(); String s = this.inputField.getText().trim();
@ -123,7 +126,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
} }
this.inputField.setText(""); this.inputField.setText("");
if((this.gm.conAutoclose || !this.full) && this.gm.theWorld != null) if((this.gm.conAutoclose || !this.full) && this.gm.world != null)
this.gm.displayGuiScreen(null); this.gm.displayGuiScreen(null);
} }
} }
@ -142,7 +145,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
private void addMessage(String msg) { private void addMessage(String msg) {
String buffer = this.gm.getBuffer(); String buffer = this.gm.getBuffer();
if((buffer.length() + msg.length() + 2) > Game.LOG_BUFFER) { if((buffer.length() + msg.length() + 2) > Client.LOG_BUFFER) {
int offset = (msg.length() + 2) > 1024 ? (msg.length() + 2) : 1024; int offset = (msg.length() + 2) > 1024 ? (msg.length() + 2) : 1024;
int nl = buffer.indexOf('\n', offset); int nl = buffer.indexOf('\n', offset);
buffer = nl >= 0 ? buffer.substring(nl + 1) : ""; buffer = nl >= 0 ? buffer.substring(nl + 1) : "";
@ -154,7 +157,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
{ {
if (this.playerNamesFound) if (this.playerNamesFound)
{ {
this.inputField.deleteFromCursor(); this.inputField.deleteSpaceToCur();
if (this.autocompleteIndex >= this.foundPlayerNames.size()) if (this.autocompleteIndex >= this.foundPlayerNames.size())
{ {
@ -167,11 +170,11 @@ public class GuiConsole extends Gui implements Textbox.Callback {
} }
else else
{ {
int i = this.inputField.getNthCharFromPos(); int i = this.inputField.getSpaceBeforeCur();
this.foundPlayerNames.clear(); this.foundPlayerNames.clear();
this.autocompleteIndex = 0; this.autocompleteIndex = 0;
// String s = this.inputField.getText().substring(i).toLowerCase(); // String s = this.inputField.getText().substring(i).toLowerCase();
String s1 = this.inputField.getText().substring(0, this.inputField.getCursorPosition()); String s1 = this.inputField.getText().substring(0, this.inputField.getCursorPos());
String[] localMatches = this.sendAutocompleteRequest(s1); String[] localMatches = this.sendAutocompleteRequest(s1);
if(localMatches != null) { if(localMatches != null) {
this.onAutocompleteResponse(localMatches); this.onAutocompleteResponse(localMatches);
@ -184,7 +187,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
} }
this.playerNamesFound = true; this.playerNamesFound = true;
this.inputField.deleteFromCursor(); this.inputField.deleteSpaceToCur();
} }
if (this.foundPlayerNames.size() > 1) if (this.foundPlayerNames.size() > 1)
@ -215,7 +218,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
s = argv[argv.length - 1]; s = argv[argv.length - 1];
Iterable<String> res = pre.startsWith("#") ? Iterable<String> res = pre.startsWith("#") ?
(argv.length == 1 ? this.gm.getVars() : (argv.length == 2 ? getVarCompletion(argv[0].substring(1)) : Lists.newArrayList())) : (argv.length == 1 ? this.gm.getVars() : (argv.length == 2 ? getVarCompletion(argv[0].substring(1)) : Lists.newArrayList())) :
(this.gm.thePlayer == null ? Lists.newArrayList() : ((ClientPlayer)this.gm.thePlayer.sendQueue).getPlayerNames()); (this.gm.player == null ? Lists.newArrayList() : this.gm.playerList.keySet());
if(argv.length == 1 && pre.startsWith("#")) if(argv.length == 1 && pre.startsWith("#"))
s = s.substring(1); s = s.substring(1);
for(String s1 : res) { for(String s1 : res) {
@ -252,10 +255,10 @@ public class GuiConsole extends Gui implements Textbox.Callback {
blockpos = new BlockPos(this.gm.pointed.entity); blockpos = new BlockPos(this.gm.pointed.entity);
} }
if(currentText.startsWith("/")) { if(currentText.startsWith("/")) {
if(this.gm.thePlayer != null) { if(this.gm.player != null) {
currentText = currentText.substring(1); currentText = currentText.substring(1);
this.prefixFirst = currentText.split(" ", -1).length == 1 ? "/" : null; this.prefixFirst = currentText.split(" ", -1).length == 1 ? "/" : null;
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketComplete(currentText, eid, blockpos)); this.gm.player.client.addToSendQueue(new CPacketComplete(currentText, eid, blockpos));
this.waitingOnAutocomplete = true; this.waitingOnAutocomplete = true;
} }
} }
@ -314,12 +317,12 @@ public class GuiConsole extends Gui implements Textbox.Callback {
} }
} }
String s1 = this.inputField.getText().substring(this.inputField.getNthCharFromPos()); String s1 = this.inputField.getText().substring(this.inputField.getSpaceBeforeCur());
String s2 = getCommonPrefix(choices); String s2 = getCommonPrefix(choices);
if (s2.length() > 0 && !s1.equalsIgnoreCase(s2)) if (s2.length() > 0 && !s1.equalsIgnoreCase(s2))
{ {
this.inputField.deleteFromCursor(); this.inputField.deleteSpaceToCur();
this.inputField.insertText(s2); this.inputField.insertText(s2);
} }
else if (this.foundPlayerNames.size() > 0) else if (this.foundPlayerNames.size() > 0)

View file

@ -1,32 +1,35 @@
package client.gui; package client.gui;
import client.Client;
import client.gui.element.MultiLabel;
import client.gui.element.NavButton; import client.gui.element.NavButton;
import client.gui.element.TransparentBox; import common.Version;
import common.color.TextColor; import common.color.TextColor;
import common.init.Config;
import common.log.Log; import common.log.Log;
import common.util.Util;
public class GuiInfo extends Gui { public class GuiInfo extends Gui {
private static final String VER = private static final String VER =
TextColor.GREEN + "" + TextColor.BUG + "" + TextColor.BUG + "" + TextColor.BUG + " " + TextColor.VIOLET + "" + Config.VERSION + "" + TextColor.GREEN + "" + Util.repeatString(TextColor.BUG, Version.RELEASE.getId()) + TextColor.DVIOLET + "|-| " + TextColor.VIOLET + Client.VERSION + TextColor.DVIOLET + " |-|" +
TextColor.GREEN + " " + TextColor.BUG + "" + TextColor.BUG + "" + TextColor.BUG; TextColor.GREEN + Util.repeatString(TextColor.BUG, Version.RELEASE.getId());
private static final String INFO = "Ein Spiel zur Simulation, zum Testen, für Rollenspiele, Mehrspieler und vieles mehr." + "\n" + private static final String INFO = "Ein Spiel zur Simulation, zum Testen, für Rollenspiele, Mehrspieler und vieles mehr." + "\n" +
"Optimiert für Geschwindigkeit, Stabilität und" + TextColor.UNKNOWN + "" + TextColor.UNKNOWN + " [Speicherzugriffsfehler]"; "Optimiert für Geschwindigkeit, Stabilität und" + TextColor.UNKNOWN + "" + TextColor.UNKNOWN + " [Speicherzugriffsfehler]";
private static final String HACKED = "Ein weiterer Release von WAAAAAAAAAAAAAAAAAAAAAAAAAAAAGHDRIVE!!!1!!!ONEoneOnetyone!1!!!" + "\n" + private static final String HACKED = "Ein weiterer Release von WAAAAAAAAAAAAGHDRIVE!!!1!!!ONEoneOnetyone!1!!!" + "\n" +
"Update 0.2 - Läuft jetzt auch mit nur 512KB Fast-RAM!"; "Update 0.2 - Läuft jetzt auch mit nur 512KB Fast-RAM!";
private static final String[] LIBRARIES = { private static final String[] LIBRARIES = {
"LWJGL 3.3.6+1 (GLFW + OpenGL)", "LWJGL 3.3.6",
"Netty 4.1.119-Final" "LWJGL-GLFW 3.3.6",
"LWJGL-OpenGL 3.3.6"
}; };
private static final String[] CODE = { private static final String[] CODE = {
"Albert Pham - WorldEdit (Snippets)", "Albert Pham - WorldEdit (Snippets)",
"Joonas Vali - NameGenerator", "Joonas Vali - NameGenerator",
"LWJGL 2.9.4-nightly-20150209 - Project, Vector*, Matrix*", "LWJGL 2.9.4-nightly-20150209 - Project, Vector*, Matrix*",
"Guava 17.0 - collect, future, Predicates", "Guava 17.0 - collect, future, Predicates",
"JOrbis 20101023 (JCraft) - jogg, jorbis, CodecJOrbis", "Netty 4.0.23-Final - net.*",
"MC 1.8.9" "JOrbis 20101023 (JCraft) - jogg, jorbis, CodecJOrbis"
}; };
public static final GuiInfo INSTANCE = new GuiInfo("Über dieses Programm", getFormat(false)); public static final GuiInfo INSTANCE = new GuiInfo("Über dieses Programm", getFormat(false));
@ -36,12 +39,12 @@ public class GuiInfo extends Gui {
private final String info; private final String info;
private static String getFormat(boolean hax) { private static String getFormat(boolean hax) {
return getInfo(hax) + "\n\n" + getCredits(hax) + "\n\n" + getLibraries(hax) + "\n\n" + getCode(hax) + "\n\n" + getOldCredits(hax) + "\n\n" + getColors(); return getInfo(hax) + "\n\n" + getCredits(hax) + "\n\n" + getLibraries(hax) + "\n\n" + getCode(hax) + "\n\n" + getColors();
} }
private static String getHeader(boolean hax, String normal, String hacked) { private static String getHeader(boolean hax, String normal, String hacked) {
return (hax ? TextColor.RED : TextColor.YELLOW) + (hax ? hacked : normal) + "\n" + return (hax ? TextColor.RED : TextColor.YELLOW) + (hax ? hacked : normal) + "\n" +
(hax ? TextColor.CYAN : TextColor.WHITE) + "==========================================+=========================================="; (hax ? TextColor.CYAN : TextColor.WHITE) + "==========================+==========================";
} }
private static void addLines(StringBuilder sb, boolean hax, String alternate, String category, String... authors) { private static void addLines(StringBuilder sb, boolean hax, String alternate, String category, String... authors) {
@ -61,7 +64,7 @@ public class GuiInfo extends Gui {
private static String getLibraries(boolean hax) { private static String getLibraries(boolean hax) {
StringBuilder sb = new StringBuilder(getHeader(hax, "Verwendete Programmbibliotheken", "U$3d 3xpl0its")); StringBuilder sb = new StringBuilder(getHeader(hax, "Verwendete Programmbibliotheken", "U$3d 3xpl0its"));
for(String lib : LIBRARIES) { for(String lib : LIBRARIES) {
sb.append("\n" + TextColor.LGRAY + "-> " + TextColor.NEON + lib); sb.append("\n" + TextColor.NEON + lib);
} }
return sb.toString(); return sb.toString();
} }
@ -69,7 +72,7 @@ public class GuiInfo extends Gui {
private static String getCode(boolean hax) { private static String getCode(boolean hax) {
StringBuilder sb = new StringBuilder(getHeader(hax, "Zusätzlicher Quellcode", "M0ar 3xpl01ts")); StringBuilder sb = new StringBuilder(getHeader(hax, "Zusätzlicher Quellcode", "M0ar 3xpl01ts"));
for(String lib : CODE) { for(String lib : CODE) {
sb.append("\n" + TextColor.LGRAY + "-> " + TextColor.NEON + lib); sb.append("\n" + TextColor.NEON + lib);
} }
return sb.toString(); return sb.toString();
} }
@ -78,37 +81,16 @@ public class GuiInfo extends Gui {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int num = 0; int num = 0;
for(TextColor color : TextColor.values()) { for(TextColor color : TextColor.values()) {
if(num > 0) if(num == 14)
sb.append(' '); sb.append('\n');
if((color.code >= Log.CHR_COLORS1 && color.code <= Log.CHR_COLORE1) || (color.code >= Log.CHR_COLORS2 && color.code <= Log.CHR_COLORE2)) { if((color.code >= Log.CHR_COLORS1 && color.code <= Log.CHR_COLORE1) || (color.code >= Log.CHR_COLORS2 && color.code <= Log.CHR_COLORE2)) {
sb.append(color + "#" + (char)(num < 10 ? ('0' + num) : ('A' + (num - 10)))); sb.append(color + "#" + (char)(num < 10 ? ('0' + num) : ('A' + (num - 10))) + ' ');
num++; num++;
} }
} }
return sb.toString(); return sb.toString();
} }
private static String getOldCredits(boolean hax) {
StringBuilder sb = new StringBuilder(getHeader(hax, "Ursprüngliche Mitwirkende", "Das Team -- Nicht TCQ"));
addLines(sb, hax, "Absolut größter Lamer des Universums", "Spielidee und ursprüngliche Umsetzung",
"Markus Persson");
addLines(sb, hax, "Crack und weitere Programmierung", "Spiel-Design, Programmierung und Grafiken",
"Jens Bergensten", "Nathan Adams", "Ryan Holtz", "Michael Stoyke");
addLines(sb, hax, "Entschlüsselung von Ressourcen", "Programmierung",
"Erik Broes", "Paul Spooner", "Ryan Hitchman", "Elliot Segal");
addLines(sb, hax, "Cracktro, Grafiken und Intromusik", "Töne und Geräusche",
"Daniel Rosenfeld", "freesound.org");
addLines(sb, hax, "Packing und Verbreitung", "Management, Administration und Spaß",
"Carl Manneh", "Daniel Kaplan", "Lydia Winters");
addLines(sb, hax, "Server und Hosting", "Zahlen und Statistiken",
"Patrick Geuder");
addLines(sb, hax, "Weiterer Dank und Grüße", "Entwickler von Mo' Creatures (Pferde usw.)",
"John Olarte", "Kent Christian Jensen", "Dan Roque");
return sb.toString();
}
private static String getCredits(boolean hax) { private static String getCredits(boolean hax) {
StringBuilder sb = new StringBuilder(getHeader(hax, "Mitwirkende dieses Programms", "Das Team -- TCQ")); StringBuilder sb = new StringBuilder(getHeader(hax, "Mitwirkende dieses Programms", "Das Team -- TCQ"));
@ -125,8 +107,8 @@ public class GuiInfo extends Gui {
} }
public void init(int width, int height) { public void init(int width, int height) {
this.add(new TransparentBox(10, 10, width - 20, height - 44, this.info, this.gm.theWorld != null && !this.gm.charEditor)); this.add(new MultiLabel(10, 10, width - 20, height - 44, this.info, false));
this.add(new NavButton(0, height - 24, width, 24, GuiMenu.INSTANCE, "Zurück")); this.add(new NavButton((width - 280) / 2, height - 20, 280, 0, GuiMenu.INSTANCE, "Zurück"));
} }
public String getTitle() { public String getTitle() {

View file

@ -1,12 +1,12 @@
package client.gui; package client.gui;
import client.Game; import client.Client;
import client.gui.element.Bar; import client.gui.element.Bar;
import client.gui.element.Label; import client.gui.element.Label;
public class GuiLoading extends Gui { public class GuiLoading extends Gui {
public static interface Callback { public static interface Callback {
void poll(Game gm, GuiLoading gui); void poll(Client gm, GuiLoading gui);
} }
private final String message; private final String message;
@ -19,7 +19,7 @@ public class GuiLoading extends Gui {
public static GuiLoading makeServerTask(String message) { public static GuiLoading makeServerTask(String message) {
return new GuiLoading(message, new Callback() { return new GuiLoading(message, new Callback() {
public void poll(Game gm, GuiLoading gui) { public void poll(Client gm, GuiLoading gui) {
int progress = gm.progress; int progress = gm.progress;
if(progress < 0) { if(progress < 0) {
gui.resetBar(); gui.resetBar();
@ -35,7 +35,7 @@ public class GuiLoading extends Gui {
public static GuiLoading makeWaitTask(String message) { public static GuiLoading makeWaitTask(String message) {
return new GuiLoading(message, new Callback() { return new GuiLoading(message, new Callback() {
public void poll(Game gm, GuiLoading gui) { public void poll(Client gm, GuiLoading gui) {
} }
}); });
} }
@ -46,11 +46,11 @@ public class GuiLoading extends Gui {
} }
public void init(int width, int height) { public void init(int width, int height) {
this.taskLabel = this.add(new Label(0, 40, 500, 20, "")); this.taskLabel = this.add(new Label(0, 40, 500, 0, ""));
this.progressBar1 = this.add(new Bar(0, 80, 500, 24)); this.progressBar1 = this.add(new Bar(0, 80, 500, 0));
this.progressBar2 = this.add(new Bar(0, 120, 500, 24)); this.progressBar2 = this.add(new Bar(0, 120, 500, 0));
this.shift(); this.shift();
this.headerLabel = this.add(new Label(0, 40, width, 20, this.message)); this.headerLabel = this.add(new Label(0, 40, width, 0, this.message));
this.progressBar1.visible = false; this.progressBar1.visible = false;
this.progressBar2.visible = false; this.progressBar2.visible = false;
} }

View file

@ -1,18 +1,17 @@
package client.gui; package client.gui;
import client.Timing; import client.Client;
import client.gui.character.GuiChar; import client.gui.character.GuiChar;
import client.gui.character.GuiCharacters; import client.gui.character.GuiCharacters;
import client.gui.element.ActButton; import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode; import client.gui.element.ButtonCallback;
import client.gui.element.Label; import client.gui.element.Label;
import client.gui.element.NavButton; import client.gui.element.NavButton;
import client.gui.element.Textbox; import client.gui.element.PressType;
import client.gui.options.GuiOptions; import client.gui.options.GuiOptions;
import client.renderer.Drawing; import client.renderer.Drawing;
import client.window.Keysym; import client.window.Keysym;
import common.color.TextColor; import common.color.TextColor;
import common.init.Config;
import common.rng.Random; import common.rng.Random;
import common.util.ExtMath; import common.util.ExtMath;
@ -23,10 +22,10 @@ public class GuiMenu extends Gui {
} }
public void drawMainBackground() { public void drawMainBackground() {
if(this.gm.theWorld != null) if(this.gm.world != null)
super.drawMainBackground(); super.drawMainBackground();
else else
this.gm.renderGlobal.renderStarField(this.gm.fb_x, this.gm.fb_y, 0x000000, 0xffffff, (float)this.ticks + (float)Timing.tick_fraction, this.rand); this.gm.renderGlobal.renderStarField(this.gm.fb_x, this.gm.fb_y, 0x000000, 0xffffff, (float)this.ticks + this.gm.getTickFraction(), this.rand);
} }
private final Random rand = new Random(); private final Random rand = new Random();
@ -48,12 +47,16 @@ public class GuiMenu extends Gui {
private boolean animStep; private boolean animStep;
public void init(int width, int height) { public void init(int width, int height) {
if(this.gm.theWorld == null) { if(this.gm.world == null) {
this.ticks = 0; this.ticks = 0;
this.hacked = 0; this.hacked = 0;
this.resetAnimation(); this.resetAnimation();
this.add(new ActButton(0, 0, 400, 24, new ActButton.Callback() { this.add(new ActButton(0, 0, 180, 0, new ButtonCallback() {
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
if(action == PressType.SECONDARY) {
GuiMenu.this.gm.joinDebugWorld();
return;
}
if(GuiMenu.this.hacked == 9) { if(GuiMenu.this.hacked == 9) {
GuiMenu.this.hacked++; GuiMenu.this.hacked++;
GuiMenu.this.splashLabel.setText(TextColor.VIOLET + "Hax!"); GuiMenu.this.splashLabel.setText(TextColor.VIOLET + "Hax!");
@ -63,19 +66,20 @@ public class GuiMenu extends Gui {
} }
} }
}, "Server beitreten")); }, "Server beitreten"));
this.add(new ActButton(0, 28, 400, 24, new ActButton.Callback() { this.add(new ActButton(0, 20, 180, 0, new ButtonCallback() {
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
if(GuiMenu.this.hacked == 8) if(GuiMenu.this.hacked == 8)
GuiMenu.this.hacked++; GuiMenu.this.hacked++;
else else
GuiMenu.this.gm.displayGuiScreen(GuiOptions.getPage()); GuiMenu.this.gm.displayGuiScreen(GuiServer.INSTANCE);
} }
}, "Einstellungen")); }, "Schnellverbindung"));
this.infoButton = this.add(new ActButton(0, 56, 400, 24, new ActButton.Callback() { this.add(new NavButton(0, 40, 180, 0, GuiOptions.getPage(), "Einstellungen"));
public void use(ActButton elem, Mode action) { this.infoButton = this.add(new ActButton(0, 60, 180, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
GuiMenu.this.gm.displayGuiScreen(GuiMenu.this.hacked == 10 ? GuiInfo.HAX : GuiInfo.INSTANCE); GuiMenu.this.gm.displayGuiScreen(GuiMenu.this.hacked == 10 ? GuiInfo.HAX : GuiInfo.INSTANCE);
} }
}, "Info / Über / Mitwirkende") { }, "Info / Mitwirkende") {
public void drawHover() { public void drawHover() {
if(GuiMenu.this.hacked == 10) { if(GuiMenu.this.hacked == 10) {
Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, 0x287f00ff); Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, 0x287f00ff);
@ -83,9 +87,9 @@ public class GuiMenu extends Gui {
int width = Drawing.getWidth("Hax!"); int width = Drawing.getWidth("Hax!");
for(int z = 0; z < 64; z++) { for(int z = 0; z < 64; z++) {
Drawing.drawText("Hax!", GuiMenu.this.rand.zrange(Math.max(1, this.gm.fb_x - width)) + Drawing.drawText("Hax!", GuiMenu.this.rand.zrange(Math.max(1, this.gm.fb_x - width)) +
(int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + (float)Timing.tick_fraction) / 100.0f * (float)Math.PI * 2.0f) * 16.0f), (int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + this.gm.getTickFraction()) / 100.0f * (float)Math.PI * 2.0f) * 16.0f),
GuiMenu.this.rand.zrange(Math.max(1, this.gm.fb_y - Font.YGLYPH)) + GuiMenu.this.rand.zrange(Math.max(1, this.gm.fb_y - Font.YGLYPH)) +
(int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + (float)Timing.tick_fraction) / 100.0f * (float)Math.PI * 2.0f) * 16.0f), (int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + this.gm.getTickFraction()) / 100.0f * (float)Math.PI * 2.0f) * 16.0f),
0xff0000ff | (GuiMenu.this.rand.zrange(256) << 16)); 0xff0000ff | (GuiMenu.this.rand.zrange(256) << 16));
} }
} }
@ -94,34 +98,33 @@ public class GuiMenu extends Gui {
} }
} }
}); });
this.add(new NavButton(0, 102, 196, 24, GuiConvert.INSTANCE, "Welt konvertieren")); this.add(new ActButton(0, 90, 180, 0, new ButtonCallback() {
this.add(new ActButton(204, 102, 196, 24, new ActButton.Callback() { public void use(ActButton elem, PressType action) {
public void use(ActButton elem, ActButton.Mode action) {
GuiMenu.this.gm.interrupted = true; GuiMenu.this.gm.interrupted = true;
} }
}, "Spiel beenden")); }, "Client schließen"));
this.shift(); this.shift();
this.add(new Label(4, /* this.gm.fb_y - 2 */ 0, 200, 20, TextColor.VIOLET + Config.VERSION, true)); this.add(new Label(4, 4, 200, 0, TextColor.VIOLET + Client.VERSION, true));
this.splashLabel = this.add(new Label(0, 160, width, 24, "")); this.splashLabel = this.add(new Label(0, 100, width, 0, ""));
this.pickSplash(); this.pickSplash();
} }
else { else {
this.add(new NavButton(0, 0, 400, 24, this.gm.charEditor ? GuiChar.INSTANCE : null, this.gm.charEditor ? "Zurück zum Charakter-Editor" : "Zurück zum Spiel")); this.add(new NavButton(0, 0, 180, 0, this.gm.charEditor ? GuiChar.INSTANCE : null, this.gm.charEditor ? "Zurück zum Editor" : "Zurück zum Spiel"));
this.add(new NavButton(0, 28, this.gm.charEditor ? 400 : 198, 24, GuiOptions.getPage(), "Einstellungen")); this.add(new NavButton(0, 20, 180, 0, GuiOptions.getPage(), "Einstellungen"));
if(!this.gm.charEditor) if(!this.gm.charEditor)
this.add(new NavButton(202, 28, 198, 24, GuiCharacters.INSTANCE, "Charakter")); this.add(new NavButton(0, 40, 180, 0, GuiCharacters.INSTANCE, "Charakter"));
this.add(new ActButton(0, 102, 400, 24, new ActButton.Callback() { this.add(new ActButton(0, this.gm.charEditor ? 50 : 70, 180, 0, new ButtonCallback() {
public void use(ActButton elem, ActButton.Mode action) { public void use(ActButton elem, PressType action) {
GuiMenu.this.gm.unload(true); GuiMenu.this.gm.unload(true);
// GuiMenu.this.gm.displayGuiScreen(INSTANCE); // GuiMenu.this.gm.displayGuiScreen(INSTANCE);
} }
}, "Server verlassen und Verbindung trennen")); }, "Server verlassen"));
this.shift(); this.shift();
} }
} }
public String getTitle() { public String getTitle() {
return this.gm.theWorld == null ? "Hauptmenü" : "Menü"; return this.gm.world == null ? "Hauptmenü" : "Menü";
} }
private void pickSplash() { private void pickSplash() {
@ -224,9 +227,9 @@ public class GuiMenu extends Gui {
} }
public void updateScreen() { public void updateScreen() {
if(this.gm.theWorld == null) { if(this.gm.world == null) {
this.ticks++; this.ticks++;
if(this.gm.shift() && !(this.selected instanceof Textbox)) if(this.gm.shift())
this.pickSplash(); this.pickSplash();
this.updateAnimation(); this.updateAnimation();
} }
@ -234,7 +237,7 @@ public class GuiMenu extends Gui {
public void key(Keysym key, boolean ctrl, boolean shift) { public void key(Keysym key, boolean ctrl, boolean shift) {
super.key(key, ctrl, shift); super.key(key, ctrl, shift);
if(this.gm.theWorld == null) { if(this.gm.world == null) {
if((key == Keysym.UP || key == Keysym.W) && (this.hacked == 0 || this.hacked == 1)) if((key == Keysym.UP || key == Keysym.W) && (this.hacked == 0 || this.hacked == 1))
this.hacked++; this.hacked++;
else if((key == Keysym.DOWN || key == Keysym.S) && (this.hacked == 2 || this.hacked == 3)) else if((key == Keysym.DOWN || key == Keysym.S) && (this.hacked == 2 || this.hacked == 3))
@ -288,8 +291,8 @@ public class GuiMenu extends Gui {
public void drawOverlays() { public void drawOverlays() {
super.drawOverlays(); super.drawOverlays();
if(this.gm.theWorld == null) { if(this.gm.world == null) {
int y = 164; int y = 99;
int h = 16; int h = 16;
int n = Drawing.getWidth(this.splashLabel.getText()); int n = Drawing.getWidth(this.splashLabel.getText());
Drawing.drawRect(0, y, this.gm.fb_x / 2 - n / 2 - 10, h, 0x7f7f00ff); Drawing.drawRect(0, y, this.gm.fb_x / 2 - n / 2 - 10, h, 0x7f7f00ff);

View file

@ -0,0 +1,279 @@
package client.gui;
import java.security.KeyPair;
import java.security.PublicKey;
import client.gui.GuiConnect.ServerInfo;
import client.gui.element.ActButton;
import client.gui.element.ButtonCallback;
import client.gui.element.Element;
import client.gui.element.Label;
import client.gui.element.NavButton;
import client.gui.element.PasswordField;
import client.gui.element.PressType;
import client.gui.element.Toggle;
import client.gui.element.FieldAction;
import client.gui.element.Field;
import client.gui.element.FieldCallback;
import client.vars.CVarCategory;
import client.vars.Variable;
import client.window.Window;
import common.color.TextColor;
import common.network.IPlayer;
import common.util.EncryptUtil;
public class GuiServer extends Gui implements FieldCallback {
public static final GuiServer INSTANCE = new GuiServer(null);
private final ServerInfo server;
private Field nameBox;
private Field addrBox;
private Field portBox;
private Field userBox;
private PasswordField passBox;
private PasswordField accBox;
private Label nameLabel;
private Label addrLabel;
private Label portLabel;
private Label rangeLabel;
private Label userLabel;
private Label passLabel;
private Label accLabel;
private Label keyLabel;
private Label idLabel;
private Toggle encToggle;
private ActButton keyButton;
private ActButton resetButton;
private ActButton copyKeyButton;
private ActButton copyIdButton;
private KeyPair keypair;
private String keyDigest;
private PublicKey serverKey;
private String serverDigest;
public GuiServer(ServerInfo server) {
this.server = server;
}
@Variable(name = "srv_last_address", category = CVarCategory.SYSTEM, min = 1, max = 128, display = "Letzte Server-Adresse")
private String lastAddr = "";
@Variable(name = "srv_last_port", category = CVarCategory.SYSTEM, min = 1024, max = 32767, display = "Letzter Server-Port")
private int lastPort = -1;
@Variable(name = "srv_last_user", category = CVarCategory.SYSTEM, max = IPlayer.MAX_USER_LENGTH, display = "Letzter Server-Nutzer", validator = IPlayer.UserValidator.class)
private String lastUser = "";
@Variable(name = "srv_last_password", category = CVarCategory.SYSTEM, max = IPlayer.MAX_PASS_LENGTH, display = "Letztes Server-Passwort")
private String lastPass = "";
@Variable(name = "srv_last_access", category = CVarCategory.SYSTEM, max = IPlayer.MAX_PASS_LENGTH, display = "Letzter Server-Zugang")
private String lastAcc = "";
public void init(int width, int height) {
if(this.server != null) {
this.nameBox = this.add(new Field(0, 0, 400, 0, 128, this, this.server.getName()));
this.nameLabel = this.add(new Label(0, 0, 410, "Name in der Liste", true));
this.keypair = this.server.getKeypair();
this.keyDigest = this.keypair == null ? null : EncryptUtil.getXorSha512Hash(this.keypair.getPublic().getEncoded());
}
this.addrBox = this.add(new Field(0, 34, 400, 0, 128, this, this.server == null ? this.lastAddr : this.server.getAddress()));
this.addrLabel = this.add(new Label(0, 34, 410, "Adresse / Hostname", true));
int port = this.server == null ? this.lastPort : this.server.getPort();
this.portBox = this.add(new Field(404, 34, 76, 0, 5, this, port < 0 ? "" : "" + port));
this.portLabel = this.add(new Label(404, 34, 76, "Port", true));
this.rangeLabel = this.add(new Label(370, 34 + Element.BASE_HEIGHT, 110, 0, "[1024..32767]", true));
this.userBox = this.add(new Field(0, 68, 220, 0, IPlayer.MAX_USER_LENGTH, this, IPlayer.VALID_USER, this.server == null ? this.lastUser : this.server.getUser()));
this.userLabel = this.add(new Label(0, 68, 220, "Benutzername", true));
this.passBox = this.add(new PasswordField(0, this.server == null ? 102 : 136, 480, 0, IPlayer.MAX_PASS_LENGTH, this, this.server == null ? this.lastPass : this.server.getPassword()));
this.passLabel = this.add(new Label(0, this.server == null ? 102 : 136, 480, (this.keypair == null ? "Anmelde" : "Ersatz") + "-Passwort (mind. 8 Zeichen)", true));
this.accBox = this.add(new PasswordField(0, this.server == null ? 136 : 170, 480, 0, IPlayer.MAX_PASS_LENGTH, this, this.server == null ? this.lastAcc : this.server.getAccess()));
this.accLabel = this.add(new Label(0, this.server == null ? 136 : 170, 480, "Server-Passwort (mind. 8 Zeichen)", true));
this.add(new ActButton(241, this.server == null ? 166 : 254, 239, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
GuiServer.this.connect();
}
}, this.server == null ? "Verbinden" : (this.server.getName().isEmpty() ? "Hinzufügen" : "Übernehmen")));
this.add(new NavButton(0, this.server == null ? 166 : 254, 239, 0, this.server != null ? GuiConnect.INSTANCE : GuiMenu.INSTANCE, "Zurück"));
if(this.server != null) {
this.keyButton = this.add(new ActButton(0, 102, 391, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
if(GuiServer.this.keypair == null) {
GuiServer.this.keypair = EncryptUtil.createKeypair();
GuiServer.this.keyDigest = EncryptUtil.getXorSha512Hash(GuiServer.this.keypair.getPublic().getEncoded());
GuiServer.this.keyLabel.setText("Anmelde-Pubkey: " + EncryptUtil.KEY_ALGO_DISPLAY + " " + GuiServer.this.keyDigest);
GuiServer.this.keyButton.setText("Schlüsselpaar entfernen");
GuiServer.this.passLabel.setText("Ersatz-Passwort (mind. 8 Zeichen)");
GuiServer.this.copyKeyButton.enabled = true;
}
else {
final String name = GuiServer.this.nameBox.getText();
final String addr = GuiServer.this.addrBox.getText();
final String port = GuiServer.this.portBox.getText();
final String pass = GuiServer.this.passBox.getText();
final String acc = GuiServer.this.accBox.getText();
final boolean reqEnc = GuiServer.this.encToggle.getValue();
final KeyPair keys = GuiServer.this.keypair;
final PublicKey key = GuiServer.this.serverKey;
final String digest = GuiServer.this.keyDigest;
final String sdigest = GuiServer.this.serverDigest;
GuiServer.this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() {
public void confirm(boolean confirmed) {
GuiServer.this.gm.displayGuiScreen(GuiServer.this);
GuiServer.this.nameBox.setText(name);
GuiServer.this.addrBox.setText(addr);
GuiServer.this.portBox.setText(port);
GuiServer.this.passBox.setText(pass);
GuiServer.this.accBox.setText(acc);
GuiServer.this.encToggle.setValue(reqEnc);
GuiServer.this.serverKey = key;
GuiServer.this.serverDigest = sdigest;
GuiServer.this.idLabel.setText("Server-Pubkey: " + (key != null ? EncryptUtil.KEY_ALGO_DISPLAY + " " + GuiServer.this.serverDigest : "nicht vorhanden"));
GuiServer.this.resetButton.enabled = key != null;
GuiServer.this.copyIdButton.enabled = key != null;
GuiServer.this.copyKeyButton.enabled = !confirmed;
if(confirmed) {
GuiServer.this.keypair = null;
GuiServer.this.keyDigest = null;
GuiServer.this.keyLabel.setText("Anmelde-Pubkey: nicht vorhanden");
GuiServer.this.keyButton.setText("Neues Schlüsselpaar generieren");
GuiServer.this.passLabel.setText("Anmelde-Passwort (mind. 8 Zeichen)");
}
else {
GuiServer.this.keypair = keys;
GuiServer.this.keyDigest = digest;
GuiServer.this.keyLabel.setText("Anmelde-Pubkey: " + EncryptUtil.KEY_ALGO_DISPLAY + " " + GuiServer.this.keyDigest);
GuiServer.this.keyButton.setText("Schlüsselpaar entfernen");
GuiServer.this.passLabel.setText("Ersatz-Passwort (mind. 8 Zeichen)");
}
}
}, "Schlüsselpaar wirklich entfernen?", "Wenn das Schlüsselpaar gelöscht wird, ist es nicht mehr möglich, sich damit\nauf dem Server zu identifizieren und sich anzumelden.\nDamit könnte der Zugriff auf den Server unmöglich werden.", "Schlüsselpaar löschen", "Abbrechen"));
}
}
}, this.keypair == null ? "Neues Schlüsselpaar generieren" : "Schlüsselpaar entfernen"));
this.copyKeyButton = this.add(new ActButton(395, 102, 85, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
if(GuiServer.this.keypair != null)
Window.setClipboard(EncryptUtil.getArmoredPubkey(GuiServer.this.keypair.getPublic(), GuiServer.this.userBox.getText()));
}
}, "Kopieren"));
this.copyKeyButton.enabled = this.keypair != null;
this.keyLabel = this.add(new Label(0, 102, 480, "Anmelde-Pubkey: " + (this.keypair != null ? EncryptUtil.KEY_ALGO_DISPLAY + " " + this.keyDigest : "nicht vorhanden"), true));
this.encToggle = this.add(new Toggle(0, 190, 480, 0, false, this.server.requiresEncryption(), null, "Nur Verschlüsselte Verbindung akzeptieren"));
this.serverKey = this.server.getServerKey();
this.serverDigest = this.serverKey == null ? null : EncryptUtil.getXorSha512Hash(this.serverKey.getEncoded());
this.resetButton = this.add(new ActButton(0, 224, 391, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
if(GuiServer.this.serverKey != null) {
GuiServer.this.serverKey = null;
GuiServer.this.serverDigest = null;
GuiServer.this.idLabel.setText("Server-Pubkey: nicht vorhanden");
GuiServer.this.resetButton.enabled = false;
GuiServer.this.copyIdButton.enabled = false;
}
}
}, "Server-Identifizierung / Pubkey zurücksetzen"));
this.resetButton.enabled = this.serverKey != null;
this.copyIdButton = this.add(new ActButton(395, 224, 85, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
if(GuiServer.this.serverKey != null)
Window.setClipboard(EncryptUtil.getArmoredPubkey(GuiServer.this.serverKey, GuiServer.this.nameBox.getText()));
}
}, "Kopieren"));
this.copyIdButton.enabled = this.serverKey != null;
this.idLabel = this.add(new Label(0, 224, 480, "Server-Pubkey: " + (this.serverKey != null ? EncryptUtil.KEY_ALGO_DISPLAY + " " + this.serverDigest : "nicht vorhanden"), true));
}
this.shift();
}
public String getTitle() {
return this.server == null ? "Mit Server verbinden" : (this.server.getName().isEmpty() ? "Server hinzufügen" : "Server bearbeiten");
}
private void connect() {
if(this.gm.world != null)
return;
String name = null;
if(this.server != null) {
name = this.nameBox.getText();
if(name.isEmpty()) {
this.nameLabel.setText(TextColor.RED + "Name in der Liste");
return;
}
if(GuiConnect.INSTANCE.isNameTaken(name)) {
this.nameLabel.setText("Name in der Liste - " + TextColor.RED + "Bereits vorhanden");
return;
}
}
String addr = this.addrBox.getText();
if(addr.isEmpty()) {
this.addrLabel.setText(TextColor.RED + "Adresse / Hostname");
return;
}
int port = -1;
if(this.portBox.getText().isEmpty()) {
this.portLabel.setText(TextColor.RED + "Port");
return;
}
else {
try {
port = Integer.parseInt(this.portBox.getText());
}
catch(NumberFormatException e) {
this.rangeLabel.setText("[" + TextColor.RED + "1024..32767" + TextColor.RESET + "]");
return;
}
if(port < 1024 || port > 32767) {
this.rangeLabel.setText("[" + (port < 1024 ? TextColor.RED + "1024" + TextColor.RESET + "..32767" : "1024.." + TextColor.RED + "32767" + TextColor.RESET) + "]");
return;
}
}
String user = this.userBox.getText();
if(user.isEmpty()) {
this.userLabel.setText(TextColor.RED + "Benutzername");
return;
}
String pass = this.passBox.getText();
if(!pass.isEmpty() && pass.length() < 8) {
this.passLabel.setText((this.keypair == null ? "Anmelde" : "Ersatz") + "-Passwort (" + TextColor.RED + "mind. 8 Zeichen" + TextColor.RESET + ")");
return;
}
String acc = this.accBox.getText();
if(!acc.isEmpty() && acc.length() < 8) {
this.accLabel.setText("Zugang (" + TextColor.RED + "mind. 8 Zeichen" + TextColor.RESET + ")");
return;
}
if(this.server == null) {
this.lastAddr = addr;
this.lastPort = port;
this.lastUser = user;
this.lastPass = pass;
this.lastAcc = acc;
this.gm.setDirty();
GuiConnect.INSTANCE.connect(addr, port, user, pass, acc);
}
else {
this.server.setData(name, addr, port, user, pass, acc, this.keypair, this.serverKey, this.encToggle.getValue());
GuiConnect.INSTANCE.applyServer(this.server);
}
}
public void use(Field elem, FieldAction value) {
if(value == FieldAction.SEND) {
elem.setDeselected();
this.connect();
}
else if(value == FieldAction.FOCUS) {
if(elem == this.addrBox)
this.addrLabel.setText("Adresse / Hostname");
else if(elem == this.portBox) {
this.portLabel.setText("Port");
this.rangeLabel.setText("[1024..32767]");
}
else if(elem == this.userBox)
this.userLabel.setText("Benutzername");
else if(elem == this.passBox)
this.passLabel.setText((this.keypair == null ? "Anmelde" : "Ersatz") + "-Passwort (mind. 8 Zeichen)");
else if(elem == this.accBox)
this.accLabel.setText("Server-Passwort (mind. 8 Zeichen)");
else if(this.server != null && elem == this.nameBox)
this.nameLabel.setText("Name in der Liste");
}
}
}

View file

@ -2,35 +2,34 @@ package client.gui;
public abstract class Splashes { public abstract class Splashes {
public static final String[] SPLASHES = { public static final String[] SPLASHES = {
"Aus der TV-Werbung!", "Aus der Toiletten-Werbung!",
"Toll!",
"0% pur!", "0% pur!",
"Kann Nüsse enthalten!", "Kann Nüsse enthalten!",
"Besser als Crysis!", "Kann *.,-#+~ enthalten!",
"Mehr Polygone!", "Mehr Polygone!",
"Sexy!", "Sexy!",
"Limitierte Edition!", "Limitierte Edition!",
"Blinkende Buchstaben!", "Blinkende Buchstaben!",
"Erstellt von Notch!", "Erstellt von Satan!",
"Es ist hier!", "Er ist hier!",
"Das Beste seiner Klasse!", "Das Schlimmste seiner Klasse!",
"Es ist vollendet!", "Es ist vollendet (nicht)!",
"Mehr oder weniger frei von Drachen!", "Mehr oder weniger frei von Drachen!",
"Aufregung!", "Aufregung!",
"Weniger als -5 verkauft!", "Weniger als -5 verkauft!",
"Einzigartig!", "Einzigartig!",
"Einen Haufen Scheiße auf YouTube!", "Einen Haufen Scheiße auf YouTube!",
"Indev!", "Dev!",
"Alpha!",
"Beta!",
"Spinnen überall!", "Spinnen überall!",
"Schau es dir an!", "Schau es dir an!",
"Heilige Kuh, mann!", "Heilige Kuh, mann!",
"Es ist ein Spiel!", "Es ist ein Spiel!",
"Hergestellt in Schweden!", "Hergestellt im Schattenland!",
"Benutzt LWJGL!", "Benutzt LWJGL!",
"Retikulierende Splinen!", "Retikulierende Splinen!",
"Meine Kraft!",
"Hurraaa!", "Hurraaa!",
"Einzelspieler!",
"Tastatur ist kompatibel!", "Tastatur ist kompatibel!",
"Undokumentiert!", "Undokumentiert!",
"Barren!", "Barren!",
@ -41,17 +40,14 @@ public abstract class Splashes {
"Überlebe!", "Überlebe!",
"Verlies!", "Verlies!",
"Exklusiv!", "Exklusiv!",
"Die Knie der Biene!",
"Weg mit O.P.P.!",
"Mit Quellcode (mehr oder weniger)!", "Mit Quellcode (mehr oder weniger)!",
"Mit Klasse(n)!", "Mit Klasse(n)!",
"Wow!", "Wow!",
"Immer noch nicht auf Steam - und das ist auch gut so!", "Niemals auf Steam - und das ist auch gut so!",
"Oh, mann!", "Oh, mann!",
"Grauenvolle Community!", "Grauenvolle Community!",
"Pixel!", "Pixel!",
"Teetsuuuuoooo!", "Garfiiieeeeeeeld!",
"Kaaneeeedaaaa!",
"Jetzt ohne Schwierigkeit!", "Jetzt ohne Schwierigkeit!",
"Verbessert!", "Verbessert!",
"9% frei von Bugs!", "9% frei von Bugs!",
@ -59,31 +55,26 @@ public abstract class Splashes {
"13 Kräuter und Gewürze!", "13 Kräuter und Gewürze!",
"Fettfrei!", "Fettfrei!",
"Absolut keine Memes!", "Absolut keine Memes!",
"Kostenlose Zähne!", "Kostenlose Vampirzähne!",
"Fragen Sie Ihnen Arzt oder Apotheker!", "Fragen Sie Ihnen Arzt oder Apotheker!",
"Alle Bergleute sind willkommen!", "Alle Bergleute sind willkommen!",
"Cloud-Computing!", "Cloud-Computing!",
"Legal in Finnland!", "Frei von \"\"KI\"\"!",
"Legal in Norwegen!",
"Illegal in China!",
"Schwer zu beschreiben!", "Schwer zu beschreiben!",
"Technisch gesehen gut!", "Technisch gesehen gut!",
"Bringe den Speck nach Hause!",
"Indie!", "Indie!",
"GOTY!",
"Ceci n'est pas une title screen!",
"Euklidisch!", "Euklidisch!",
"Jetzt in 3D!", "Jetzt in 4D?!",
"Bietet Inspiration!", "Bietet Inspiration!",
"Herregud!",
"Komplexe Zellvorgänge!",
"Ja, Sir!", "Ja, Sir!",
"Von Cowboys gespielt!", "Ja, Miss!",
"Von Trollen gespielt!",
"OpenGL 1.5 oder höher!", "OpenGL 1.5 oder höher!",
"Tausende von Farben!", "Millionen von Farben!",
"Probiere es!", "Probiere es!",
"Age of Wonders ist besser!",
"Probiere die Pilzsuppe!",
"Sensationell!", "Sensationell!",
"Heiße Tamale, heiße heiße Tamale!",
"Spiele ihn runter, Klavierkatze!", "Spiele ihn runter, Klavierkatze!",
"Garantiert!", "Garantiert!",
"Makroskopisch!", "Makroskopisch!",
@ -94,27 +85,22 @@ public abstract class Splashes {
"Von Melonen geliebt!", "Von Melonen geliebt!",
"Ultimative Edition!", "Ultimative Edition!",
"Merkwürdig!", "Merkwürdig!",
"Du hast einen nagelneuen Schlüssel bekommen!",
"Wasserfest!", "Wasserfest!",
"Nicht brennbar!", "Nicht brennbar!",
"Oha, du!", "Oha, du!",
"Alles inklusive!", "Alles inklusive!",
"Sag es deinen Freunden!", "Sag es deinen Freunden!",
"NP ist nicht in P!", "NP ist nicht in P!",
"Musik von C418 (DLC)!",
"Viel zu oft live gestreamt!",
"Heimgesucht!", "Heimgesucht!",
"Polynomial!", "Polynomial!",
"Terrestrisch!", "Terrestrisch!",
"Alles ist voller Zerstörung!", "Alles ist voller Zerstörung!",
"Voll mit Sternen, Planeten und Monden!", "Voll mit Sternen, Planeten und Monden!",
"Wissenschaftlich!", "Wissenschaftlich!",
"Nicht so cool wie Spock!",
"Trage nix bei und höre weg!", "Trage nix bei und höre weg!",
"Grabe niemals nach unten, wenn du keine Erze brauchst!", "Grabe niemals nach unten, wenn du keine Erze brauchst!",
"Mache nie Pause!", "Mache nie Pause!",
"Nicht linear!", "Nicht linear!",
"Han hat zuerst geschossen!",
"Schön dich zu sehen!", "Schön dich zu sehen!",
"Eimer mit Lava!", "Eimer mit Lava!",
"Reite auf dem Schwein!", "Reite auf dem Schwein!",
@ -124,25 +110,18 @@ public abstract class Splashes {
"Holz schlagen!", "Holz schlagen!",
"Von Klippen fallen!", "Von Klippen fallen!",
"0% Zucker!", "0% Zucker!",
"150% hyperbol!", "180% Alkohol!",
"Synecdoche!",
"Lasst uns tanzne!", "Lasst uns tanzne!",
"Geheeimes Freitags-Update!",
"Referenz-Implementation!", "Referenz-Implementation!",
"Frei mit zwei.. äähhh fünf Typen mit Essen!", "Frei mit zwei.. äähhh fünf Typen mit Essen!",
"Küsse den Himmel!", "Küsse den Himmel!",
"20 GOTO 10!", "20 GOTO 10!",
"Verlet-Intregration!",
"Peter Griffin!",
"Verteile die Erde gut!", "Verteile die Erde gut!",
"Cogito ergo sum!", "8263273626252622872652 Zeilen Quellcode (287228 am 30.7.)!",
"4815162342 Zeilen Quellcode (287228 am 30.7.)!",
"Ein Skelett fiel heraus!", "Ein Skelett fiel heraus!",
"Das Werk von Notch!", "Das Werk von Luzifer!",
"Die Summe seiner Teile!", "Die Summe seiner Teile!",
"BTAF war mal gut!", "mureh srednA!",
"Ich vermisse ADOM!",
"umop-apisdn!",
"GTX750Ti!", "GTX750Ti!",
"Bringe mir Mentos und Cola!", "Bringe mir Mentos und Cola!",
"Finger-leckend!", "Finger-leckend!",
@ -162,25 +141,16 @@ public abstract class Splashes {
"Doppelt gepuffert!", "Doppelt gepuffert!",
"Fan-Fiction!", "Fan-Fiction!",
"Flaxkikare!", "Flaxkikare!",
"Jason! Jason! Jason!",
"Heißer als die Sonne!", "Heißer als die Sonne!",
"Internet-Funktionalität!", "Internet-Funktionalität!",
"Autonom!", "Autonom!",
"Engagiere!", "Engagiere!",
"Fantasie!", "Fantasie!",
"DRR! DRR! DRR!", "Mau! Mau! Mau!",
"Stoß es Wurzel runter!", "Stoß es Wurzel runter!",
"Regionale Ressourcen!", "Regionale Ressourcen!",
"Jaa, facepunch!",
"Jaa, somethingawful!",
"Jaa, /v/!",
"Jaa, tigsource!",
"Jaa, weinkraftforum!",
"Jaa, worldofweinkraft!",
"Buu, reddit!",
"Jaa, 2pp!",
"Goggle anllyticsed:DD :DDD:D!", "Goggle anllyticsed:DD :DDD:D!",
"Unterstützt jetzt äöü!", "Unterstützt jetzt äöüß!",
"Gebt uns Gordon!", "Gebt uns Gordon!",
"Gib deinem Kellner Trinkgeld!", "Gib deinem Kellner Trinkgeld!",
"Macht viel Spaß!", "Macht viel Spaß!",
@ -191,15 +161,12 @@ public abstract class Splashes {
"Allmächtig!", "Allmächtig!",
"Huch!", "Huch!",
"...!", "...!",
"Bienen, Bienen, Bienen, Bienen!", "Bienen, Mienen, Minen, W-!",
"Jag känner en bot!",
"Dieser Text ist schwer bei der Standard-Auflösung zu lesen, aber auf 1080p ist es in Ordnung!", "Dieser Text ist schwer bei der Standard-Auflösung zu lesen, aber auf 1080p ist es in Ordnung!",
"Haha, LOL!", "Haha, LOL!",
"Hampsterdance!", "Hampsterdance!",
"Schalter und Erze!", "Schalter und Erze!",
"Menger-Schwamm!", "Menger-Schwamm!",
"idspispopd!",
"Eple (originale Version)!",
"So frisch, so sauber!", "So frisch, so sauber!",
"Schnell reagierende Portale!", "Schnell reagierende Portale!",
"Probiere den Warp aus!", "Probiere den Warp aus!",
@ -207,10 +174,9 @@ public abstract class Splashes {
"Oh, ok, NPCs!", "Oh, ok, NPCs!",
"Endlich mit Leitern!", "Endlich mit Leitern!",
"Gruselig!", "Gruselig!",
"Spiele Minenkraft, schaue Topgear, bekomme Schwein!",
"Darüber gewittert!", "Darüber gewittert!",
"Spring hoch, spring hoch, und komme runter!", "Spring hoch, spring hoch, und komme runter!",
"Joel ist klasse!", "Strahlung ist klasse!",
"Ein Rätsel, in einen Mythos verwoben!", "Ein Rätsel, in einen Mythos verwoben!",
"Riesige Landeszüge voll mit TNT!", "Riesige Landeszüge voll mit TNT!",
"Willkommen zu deinem Ende! Muahahahahahaha!", "Willkommen zu deinem Ende! Muahahahahahaha!",
@ -222,23 +188,21 @@ public abstract class Splashes {
"\"Fast nie\" ist ein interessantes Konzept!", "\"Fast nie\" ist ein interessantes Konzept!",
"Eine Menge Wahrheitigkeit!", "Eine Menge Wahrheitigkeit!",
"Der TNT-Block ist ein Spion!", "Der TNT-Block ist ein Spion!",
"Turing-vollständig!", "Turing-unvollständig!",
"Es ist bahnbrechend!", "Es ist bahnbrechend!",
"Lasst unsere Schlachten beginnen!", "Lasst unsere Schlachten beginnen!",
"Der Himmel ist die Grenze - oder auch nicht!", "Der Himmel ist die Grenze - oder auch nicht!",
"Jeb hat tolle Haare!", "Dein PC hat tolle Haare, mach das Ding mal sauber!",
"Ryan hat auch tolle Haare!", "Shen hat auch tolle Haare!",
"Gelegentliches Spielen!", "Gelegentliches Spielen!",
"Unbesiegt!", "Unbesiegt!",
"Ein Bisschen wie Lemmings!", "Ein Bisschen wie Lemmings!",
"Folge dem Zug, CJ!", "Folge dem Zug, CJ!",
"Macht von Synergie Verwendung!", "Macht von Synergie Verwendung!",
"Diese Nachricht wird niemals als Splash-Text erscheinen, ist das nicht komisch?", "Diese Nachricht sollte niemals als Splash-Text erscheinen, oder etwa doch? Trololololol!",
"DungeonQuest ist unfair!",
"0815!", "0815!",
"666!", "666!",
"Geh zu den fernen Ländern und weiter!", "Geh zu den fernen Ländern und weiter!",
"Tyrion würde es lieben!",
"Probiere auch Stellaris!", "Probiere auch Stellaris!",
"Probiere auch Garry's Mod!", "Probiere auch Garry's Mod!",
"Probiere auch GZDoom!", "Probiere auch GZDoom!",
@ -252,52 +216,43 @@ public abstract class Splashes {
"Brot ist Schmerz!", "Brot ist Schmerz!",
"Lese mehr Bücher!", "Lese mehr Bücher!",
"Khaaaaaaaaan!", "Khaaaaaaaaan!",
"Weniger süchtig machend als TV Tropes!", "Weniger süchtig machend als [zensiert da NSFW]!",
"Mehr süchtig machend als Limonade!", "Mehr süchtig machend als Limonade!",
"Größer als eine Brotkiste!", "Größer als eine Brotkiste!",
"Millionen von Pfirsichen!", "Millionen von Pfirsichen!",
"Fnord!",
"Dies ist meine echte Gestalt! Muahahahaha!", "Dies ist meine echte Gestalt! Muahahahaha!",
"Habe Dre vollkommen vergessen!", "Verschwende keine Zeit mit \"\"KI\"\"!",
"Verschwende keine Zeit mit den Klonen!", "Erstellt von einer Katze!",
"Kürbiskopf!",
"Hobo humping slobo babe!",
"Erstellt von Jeb!",
"Hat kein Ende!", "Hat kein Ende!",
"Endlich vollständig!", "Endlich vollständig!",
"Voll mit Features!", "Voll mit Features!",
"Stiefel mit dem Fell!", "Stiefel mit dem Fell!",
"Stop, hammertime!", "Stop, hammertime!",
"Testificates!", "Test!",
"Nicht konventionell!", "Nicht konventionell!",
"Homeomorphisch zu einer 3-Kugel!", "Nicht kommerziell!",
"Vermeidet nicht doppelte Verneinung!", "Vermeidet nicht doppelte Verneinung!",
"Platziere ALL die Blöcke!", "Platziere ALL die Blöcke!",
"Macht Walzen!", "Macht Walzen!",
"Erfüllt Erwartungen!", "Erfüllt Erwartungen!",
"Spielen am PC seit 1873!", "Spielen am PC seit 1992!",
"Ghoughpteighbteau tchoghs!",
"Deja vu!", "Deja vu!",
"Deja vu!", "Deja vu!",
"Hab deine Nase!", "Hab deine Nase!",
"Haley liebt Elan!",
"Hat keine Angst vor der großen, schwarzen Fledermaus!", "Hat keine Angst vor der großen, schwarzen Fledermaus!",
"Benutzt nicht das U-Wort!", "Benutzt nicht das U-Wort!",
"Nicht wirklich leicht!", "Nicht wirklich leicht!",
"Bis nächsten Freitag oder so!", "Bis nächsten Freitag oder so!",
"Von den Straßen von Södermalm!", "Von den Straßen von Nibelheim!",
"150 BPM für 400000 Minuten!",
"Technologisch!", "Technologisch!",
"Funk Soul Bruder!", "Hallo Japan!",
"Pumpa kungen!",
"Hallo Japan",
"Hallo Korea!", "Hallo Korea!",
"Hallo Wales!", "Hallo Wales!",
"Hallo Polen!", "Hallo Polen!",
"Hallo China", "Hallo China!",
"Hallo Russland!", "Hallo Russland!",
"Hallo Griechenland!", "Hallo Griechenland!",
"Mein Leben für Aiur!", "Mein Leben für Aiur (warte mal..)!",
"Lenny lenny = new Lenny(\"(°^°)\");", "Lenny lenny = new Lenny(\"(°^°)\");",
"Ich sehe dein Wortschatz hat sich verbessert!", "Ich sehe dein Wortschatz hat sich verbessert!",
"Wer hat es dort hin getan?", "Wer hat es dort hin getan?",
@ -305,14 +260,14 @@ public abstract class Splashes {
"if not ok then return end", "if not ok then return end",
"Mehrfarbig!", "Mehrfarbig!",
"FUNKY LOL", "FUNKY LOL",
"SOPA bedeutet LOSER in Schwedisch!", "Copyright bedeutet LOSER in allen Sprachen!",
"Große Spitze Zähne!", "Große Spitze Zähne!",
"Mein Shizun bewacht das Tor!", "Mein Shizun bewacht das Tor!",
"Mmmph, mmph!", "Mmmph, mmph!",
"Füttere keine Avocados an Papageien!", "Füttere keine Landminen an Piranhas!",
"Schwerter für alle!", "Schwerter für alle!",
"Bitteee antworte meinem Tweet! (Nutzer wurde gebannt)", "Bitteee antworte meinem Tweet! (Nutzer wurde gebannt)",
".party()!", ".party().crash().commitWarcrimes().forTheEmperor()!",
"Nehme ihr Kissen!", "Nehme ihr Kissen!",
"Lege diesen Keks weg!", "Lege diesen Keks weg!",
"Extrem gruselig!", "Extrem gruselig!",
@ -320,26 +275,21 @@ public abstract class Splashes {
"Jetzt mit extra Sprengstoff!", "Jetzt mit extra Sprengstoff!",
"Nicht kompatibel zu Java 6!", "Nicht kompatibel zu Java 6!",
"Oha.", "Oha.",
"HURNERJSGER?",
"Was'n los, Doc?", "Was'n los, Doc?",
"Enthält jetzt 0 zufällige tägliche Katzen!", "Enthält jetzt 0 zufällige tägliche Katzen!",
"Das ist Numberwang!",
"((pls rt)) -- Der Vogel ist tot!", "((pls rt)) -- Der Vogel ist tot!",
"Willst du meinem Server beitreten?", "Willst du meinem Server beitreten?",
"Mach einen großen Zaun drum herum! Oder du wirst v-", "Mach einen großen Zaun drum herum! Oder du wirst v-",
"Lege eine Landmine drüber!", "Lege eine Landmine drüber!",
"Eines Tages, irgendwann in der Zukunft, wird mein Werk zitiert werden!", "Eines Tages, irgendwann in der Zukunft, wird mein Werk r3- ÄÄHHH kopiert werden!",
"Jetzt mit zusätzlichem Zeug!", "Jetzt mit zusätzlichem Zeug!",
"Zusätzliche Dinge!", "Zusätzliche Dinge!",
"Hurra, Atombomben für alle!", "Hurra, Atombomben für alle!",
"So süß, wie ein schöner Bon-Bon!", "So süß, wie ein schöner ****!",
"Poppende Tags!",
"Sehr einflussreich in seinem Kreis!", "Sehr einflussreich in seinem Kreis!",
"Jetzt mit Mehrspieler!", "Jetzt mit Mehrspieler!",
"Stehe aus deinem Grab auf!", "Stehe aus deinem Grab auf!",
"Warnung! Ein großes Kampfschiff \"SHEN\" nähert sich schnell!", "Warnung! Ein großes Kampfschiff \"SHEN\" nähert sich schnell!",
"Der blaue Krieger hat das Essen beschossen!",
"Renn, Feigling! Ich hunger!",
"Geschmack ohne Würze!", "Geschmack ohne Würze!",
"Seltsam, aber nicht fremd!", "Seltsam, aber nicht fremd!",
"Härter als Diamanten, Reich wie Creme!", "Härter als Diamanten, Reich wie Creme!",
@ -355,14 +305,13 @@ public abstract class Splashes {
"Bau mir einen Tisch, einen funkigen Tisch!", "Bau mir einen Tisch, einen funkigen Tisch!",
"Nehm den Aufzug in die Hölle!", "Nehm den Aufzug in die Hölle!",
"Hör auf vernünftig zu sein, das hier ist das Internet!", "Hör auf vernünftig zu sein, das hier ist das Internet!",
"/give @a tnt 67108864 7", "/give * tnt 67108864 7",
"Das ist gut für 3D Realms.", "Das ist gut für 3D Realms.",
"Jeder Computer ist ein Laptop, wenn du tapfer genug bist!", "Jeder Computer ist ein Laptop, wenn du tapfer genug bist!",
"Mach es alles, jede Sache!", "Mach es alles, jede Sache!",
"Wo ist kein Licht, da kann Spinne!", "Wo ist kein Licht, da kann Spinne!",
"GNU Terry Pratchett", "GNU Terry Pratchett",
"Jetzt Java 8!", "Jetzt Java 21!",
"MeinKraft!",
"Immer noch zu viele Bugs!", "Immer noch zu viele Bugs!",
"Wird nicht laggen!", "Wird nicht laggen!",
"Er hat es ruiniert!", "Er hat es ruiniert!",
@ -370,7 +319,6 @@ public abstract class Splashes {
"OpenGL 2.0+ (definitiv nicht unterstützt)!", "OpenGL 2.0+ (definitiv nicht unterstützt)!",
"Keine Segfaults (nicht) möglich!", "Keine Segfaults (nicht) möglich!",
"Keine Abstürze (un)möglich!", "Keine Abstürze (un)möglich!",
"Alpha!",
"Enthält Bugs!", "Enthält Bugs!",
"Enthält Mäuse!", "Enthält Mäuse!",
"Enthält Gewalt!", "Enthält Gewalt!",
@ -379,6 +327,7 @@ public abstract class Splashes {
"Du hattest eine. aufgabe.", "Du hattest eine. aufgabe.",
"Spinnen können TNT1 A 0 sein!", "Spinnen können TNT1 A 0 sein!",
"RTFM!", "RTFM!",
"Hex, nur mit mehr Ameisen!",
"Vorherrschaft des Imperiums!", "Vorherrschaft des Imperiums!",
"Vorherrschaft der Eldar!", "Vorherrschaft der Eldar!",
"Vorherrschaft der Drukhari!", "Vorherrschaft der Drukhari!",
@ -409,6 +358,11 @@ public abstract class Splashes {
"Eimer mit Wasser!", "Eimer mit Wasser!",
"Hergestellt in Deutschland!", "Hergestellt in Deutschland!",
"Hergestellt in China!", "Hergestellt in China!",
"Jetzt mit Einzelspieler!" "Jetzt ohne Einzelspieler!",
"Jetzt mit tieferen Schluchten!",
"Was bist du denn für ein hübsches Ding?",
"[TEXT ZENSIERT]",
"Mehr Energie!",
"Maximale Energie!"
}; };
} }

View file

@ -17,9 +17,9 @@ public enum Style implements Identifyable, Displayable {
this.name = name; this.name = name;
} }
@Variable(type = IntType.COLOR, name = "color_border_top", category = CVarCategory.GUI, display = "Umrahmung oben / l.") @Variable(type = IntType.COLOR, name = "color_border_top", category = CVarCategory.GUI, display = "Umrahmung A")
public int brdr_top; public int brdr_top;
@Variable(type = IntType.COLOR, name = "color_border_btm", category = CVarCategory.GUI, display = "Umrahmung unten / r.") @Variable(type = IntType.COLOR, name = "color_border_btm", category = CVarCategory.GUI, display = "Umrahmung B")
public int brdr_btm; public int brdr_btm;
@Variable(type = IntType.COLOR, name = "color_button_top", category = CVarCategory.GUI, display = "Knopf oben") @Variable(type = IntType.COLOR, name = "color_button_top", category = CVarCategory.GUI, display = "Knopf oben")

View file

@ -14,27 +14,33 @@ import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL13;
import client.Game; import client.Client;
import client.Game.FileMode; import client.Client.FileMode;
import client.SkinConverter;
import client.gui.FileCallback; import client.gui.FileCallback;
import client.gui.Font;
import client.gui.GuiLoading; import client.gui.GuiLoading;
import client.gui.element.ActButton; import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode;
import client.gui.element.Element; import client.gui.element.Element;
import client.gui.element.GuiList; import client.gui.element.GuiList;
import client.gui.element.Label; import client.gui.element.Label;
import client.gui.element.ListEntry; import client.gui.element.ListEntry;
import client.gui.element.MultiLabel;
import client.gui.element.NavButton; import client.gui.element.NavButton;
import client.gui.element.PressType;
import client.gui.element.Slider; import client.gui.element.Slider;
import client.gui.element.Textbox; import client.gui.element.SliderCallback;
import client.gui.element.Textbox.Action; import client.gui.element.FieldAction;
import client.gui.element.TransparentBox; import client.gui.element.Area;
import client.gui.element.ButtonCallback;
import client.gui.element.Field;
import client.gui.element.FieldCallback;
import client.renderer.Drawing; import client.renderer.Drawing;
import client.renderer.GlState; import client.renderer.GlState;
import client.renderer.ItemRenderer; import client.renderer.ItemRenderer;
import client.renderer.entity.RenderManager; import client.renderer.entity.RenderManager;
import client.renderer.texture.EntityTexManager; import client.renderer.texture.EntityTexManager;
import client.util.FileUtils;
import client.util.SkinConverter;
import client.vars.CVarCategory; import client.vars.CVarCategory;
import client.vars.EnumVar; import client.vars.EnumVar;
import client.vars.Variable; import client.vars.Variable;
@ -49,7 +55,7 @@ import common.entity.npc.EntityHuman;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.npc.SpeciesInfo; import common.entity.npc.SpeciesInfo;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.EntityEggInfo; import common.init.EntityInfo;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.init.SpeciesRegistry; import common.init.SpeciesRegistry;
import common.init.UniverseRegistry; import common.init.UniverseRegistry;
@ -61,7 +67,6 @@ import common.packet.CPacketMessage;
import common.packet.CPacketSkin; import common.packet.CPacketSkin;
import common.rng.Random; import common.rng.Random;
import common.util.Displayable; import common.util.Displayable;
import common.util.FileUtils;
import common.util.Identifyable; import common.util.Identifyable;
import common.util.Util; import common.util.Util;
@ -97,7 +102,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
} }
} }
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered) public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered)
{ {
String str = String str =
(this.skinFile != null ? this.skinFile.getName() : ( (this.skinFile != null ? this.skinFile.getName() : (
@ -109,7 +114,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
Drawing.drawText(str, x + 64 + 3, y, 0xff000000 | (this.charinfo == null ? Drawing.drawText(str, x + 64 + 3, y, 0xff000000 | (this.charinfo == null ?
0xffffff : this.charinfo.color1 | this.charinfo.color2)); 0xffffff : this.charinfo.color1 | this.charinfo.color2));
if(this.charinfo != null) if(this.charinfo != null)
Drawing.drawText(this.charinfo.skin, x + 64 + 3, y + 18, 0xffc0c0c0); Drawing.drawTextRight(this.charinfo.skin, x + width - 2, y + height - Font.YGLYPH, 0xffc0c0c0);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F); GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
@ -129,7 +134,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
EntityTexManager.altLayer = this.dynId; EntityTexManager.altLayer = this.dynId;
EntityTexManager.altNpcLayer = this.dynId == -1 && this.charinfo != null ? this.charinfo.skin : null; EntityTexManager.altNpcLayer = this.dynId == -1 && this.charinfo != null ? this.charinfo.skin : null;
drawEntity(x + 32, y + 60, 28.0f drawEntity(x + 32, y + 60, 28.0f
* Math.min(1.8f / GuiChar.this.gm.thePlayer.height, 1.5f / GuiChar.this.gm.thePlayer.width), -45.0f, -20.0f, GuiChar.this.gm.thePlayer); * Math.min(1.8f / GuiChar.this.gm.player.height, 1.5f / GuiChar.this.gm.player.width), -45.0f, -20.0f, GuiChar.this.gm.player);
GuiChar.this.gm.cameraUsed = flag; GuiChar.this.gm.cameraUsed = flag;
EntityTexManager.altTexture = null; EntityTexManager.altTexture = null;
EntityTexManager.altLayer = -1; EntityTexManager.altLayer = -1;
@ -237,8 +242,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
public static class FilterFunction implements EnumFunction<FilterType> { public static class FilterFunction implements EnumFunction<FilterType> {
public void apply(EnumVar cv, FilterType value) { public void apply(EnumVar cv, FilterType value) {
if(Game.getGame().open instanceof GuiChar) if(Client.CLIENT.open instanceof GuiChar)
Game.getGame().displayGuiScreen(Game.getGame().open); Client.CLIENT.displayGuiScreen(Client.CLIENT.open);
} }
} }
@ -248,7 +253,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
private ActButton templateButton; private ActButton templateButton;
private DragAdjust adjust; private DragAdjust adjust;
private ActButton dimButton; private ActButton dimButton;
private TransparentBox descLines; private MultiLabel descLines;
private ActButton cancelButton;
private float yaw = -15.0f; private float yaw = -15.0f;
private float pitch = -15.0f; private float pitch = -15.0f;
private boolean waiting = true; private boolean waiting = true;
@ -265,16 +271,16 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
{ {
super.init(width, height); super.init(width, height);
this.waiting = true; this.waiting = true;
this.setDimensions(400, height, 32, height - 32); this.setDimensions(390, height, 32, height - 32);
if(this.gm.getRenderManager().gm == null) { if(this.gm.getRenderManager().gm == null) {
this.unload(); this.unload();
this.adjust = null; this.adjust = null;
return; return;
} }
this.currentSkin = this.gm.thePlayer != null && !EntityTexManager.hasCustomSkin(this.gm.thePlayer.getId()) ? this.gm.thePlayer.getChar() : null; this.currentSkin = this.gm.player != null && !EntityTexManager.hasCustomSkin(this.gm.player.getId()) ? this.gm.player.getChar() : null;
this.load(this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel(), this.gm.thePlayer != null ? this.gm.thePlayer.getSpecies() : SpeciesRegistry.CLASSES.get(EntityHuman.class)); this.load(this.gm.player == null ? ModelType.HUMANOID : this.gm.player.getModel(), this.gm.player != null ? this.gm.player.getSpecies() : SpeciesRegistry.CLASSES.get(EntityHuman.class));
this.add(new ActButton(4, 4, 194, 24, new ActButton.Callback() { this.add(new ActButton(2, 12, 193, 0, new ButtonCallback() {
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", TEXTURE_FOLDER, new FileCallback() { GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", TEXTURE_FOLDER, new FileCallback() {
public void selected(File file) { public void selected(File file) {
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, false)) if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, false))
@ -283,8 +289,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
}); });
} }
}, "Importieren: Standard")); }, "Importieren: Standard"));
this.add(new ActButton(202, 4, 194, 24, new ActButton.Callback() { this.add(new ActButton(197, 12, 193, 0, new ButtonCallback() {
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", TEXTURE_FOLDER, new FileCallback() { GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", TEXTURE_FOLDER, new FileCallback() {
public void selected(File file) { public void selected(File file) {
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, true)) if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, true))
@ -293,14 +299,14 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
}); });
} }
}, "Importieren: Schlank")); }, "Importieren: Schlank"));
this.addSelector("char_filter_species", 400, 4, 300, 24); this.addSelector("char_filter_species", 392, 12, 250, 0);
this.add(new ActButton(4, height - 28, 194, 24, new ActButton.Callback() { this.add(new ActButton(2, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
GuiChar.this.gm.displayGuiScreen(GuiChar.this); GuiChar.this.gm.displayGuiScreen(GuiChar.this);
} }
}, "Neu laden")); }, "Neu laden"));
this.templateButton = this.add(new ActButton(202, height - 28, 194, 24, new ActButton.Callback() { this.templateButton = this.add(new ActButton(197, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
SkinEntry skin = GuiChar.this.getSelected(); SkinEntry skin = GuiChar.this.getSelected();
if(skin != null && skin.getLocation() != null) { if(skin != null && skin.getLocation() != null) {
String loc = skin.getLocation(); String loc = skin.getLocation();
@ -316,9 +322,9 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
} }
catch(Exception e) { catch(Exception e) {
if(e instanceof FileNotFoundException) if(e instanceof FileNotFoundException)
Log.JNI.warn("Textur ist nicht zum Kopieren vorhanden: " + EntityNPC.getSkinTexture(loc)); Log.IO.warn("Textur ist nicht zum Kopieren vorhanden: " + EntityNPC.getSkinTexture(loc));
else else
Log.JNI.error(e, "Konnte Textur nicht kopieren"); Log.IO.error(e, "Konnte Textur nicht kopieren");
} }
finally { finally {
if(in != null) { if(in != null) {
@ -333,74 +339,81 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
} }
} }
}, "Vorlage kopieren")); }, "Vorlage kopieren"));
if(width >= 784 + 460 && height >= 128 + 640)
this.adjust = this.add(new DragAdjust(width / 2 - 230, height - 64 - 640, 460, 640)); this.adjust = this.add(new DragAdjust(width / 2 - 230, height - 64 - 640, 460, 640));
else
this.adjust = this.add(new DragAdjust(390 - 115 - 4, height - 32 - 160 - 4, 115, 160));
this.add(new Label(width - 396, 36, 392, 20, "Spezies: " + (this.gm.thePlayer == null ? "<?>" : this.gm.thePlayer.getSpecies().name), true)); this.add(new Label(width - 390, 48, 388, "Spezies: " + (this.gm.player == null ? "<?>" : this.gm.player.getSpecies().name), true));
this.add(new NavButton(width - 396, 56, 392, 24, GuiSpecies.INSTANCE, "Spezies ändern")); this.add(new NavButton(width - 390, 48, 388, 0, GuiSpecies.INSTANCE, "Spezies ändern"));
this.add(new Label(width - 396, 36 + 92, 392, 20, "Klasse: " + (this.gm.thePlayer == null || this.gm.thePlayer.getSpecies().classEnum == null || this.gm.thePlayer.getNpcClass() == null || this.gm.thePlayer.getNpcClass().toString().isEmpty() ? "<Keine>" : this.gm.thePlayer.getNpcClass().toString()), true)) this.add(new Label(width - 390, 82, 388, "Klasse: " + (this.gm.player == null || this.gm.player.getSpecies().classEnum == null || this.gm.player.getNpcClass() == null || this.gm.player.getNpcClass().toString().isEmpty() ? "<Keine>" : this.gm.player.getNpcClass().toString()), true))
.enabled = this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null; .enabled = this.gm.player != null && this.gm.player.getSpecies().classEnum != null;
this.add(new NavButton(width - 396, 56 + 92, 392, 24, GuiClass.INSTANCE, "Klasse ändern")) this.add(new NavButton(width - 390, 82, 388, 0, GuiClass.INSTANCE, "Klasse ändern"))
.enabled = this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null; .enabled = this.gm.player != null && this.gm.player.getSpecies().classEnum != null;
final ActButton[] alignBtns = new ActButton[Alignment.values().length]; final ActButton[] alignBtns = new ActButton[Alignment.values().length];
for (int z = 0; z < Alignment.values().length; z++) for (int z = 0; z < Alignment.values().length; z++)
{ {
final Alignment align = Alignment.values()[z]; final Alignment align = Alignment.values()[z];
alignBtns[z] = this.add(new ActButton(width - 396 + (z % 3) * 132, height - 32 - 28 * 3 + 28 * (z / 3), 128, 24, new ActButton.Callback() { alignBtns[z] = this.add(new ActButton(width - 390 + (z % 3) * 130, height - 32 - 20 * 3 + 20 * (z / 3), 128, 0, new ButtonCallback() {
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
if(GuiChar.this.gm.thePlayer != null) { if(GuiChar.this.gm.player != null) {
GuiChar.this.waiting = false; GuiChar.this.waiting = false;
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, align.ordinal())); GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, align.ordinal()));
for(ActButton btn : alignBtns) { for(ActButton btn : alignBtns) {
btn.enabled = btn != elem; btn.enabled = btn != elem;
} }
} }
} }
}, align.color + align.display)); }, align.color + align.display));
alignBtns[z].enabled = this.gm.thePlayer == null || this.gm.thePlayer.getAlignment() != align; alignBtns[z].enabled = this.gm.player == null || this.gm.player.getAlignment() != align;
} }
this.add(new Slider(width / 2 - 200, height - 28, 400, 24, 1, this.gm.thePlayer == null ? 120 : this.gm.thePlayer.getMinSize(), this.gm.thePlayer == null ? 320 : this.gm.thePlayer.getMaxSize(), this.gm.thePlayer == null ? 180 : this.gm.thePlayer.getDefaultSize(), this.gm.thePlayer == null ? 180 : this.gm.thePlayer.getCurrentSize(), new Slider.Callback() { this.add(new Slider(width - 390, 136, 388, 0, 1, this.gm.player == null ? 120 : this.gm.player.getMinSize(), this.gm.player == null ? 320 : this.gm.player.getMaxSize(), this.gm.player == null ? 180 : this.gm.player.getDefaultSize(), this.gm.player == null ? 180 : this.gm.player.getCurrentSize(), new SliderCallback() {
public void use(Slider elem, int value) { public void use(Slider elem, int value) {
if(GuiChar.this.gm.thePlayer != null) { if(GuiChar.this.gm.player != null) {
GuiChar.this.waiting = false; GuiChar.this.waiting = false;
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, value)); GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, value));
} }
} }
}, "Spieler-Größe", "cm")).enabled = this.gm.thePlayer == null || this.gm.thePlayer.getMinSize() != this.gm.thePlayer.getMaxSize(); }, "Spieler-Größe", "cm")).enabled = this.gm.player == null || this.gm.player.getMinSize() != this.gm.player.getMaxSize();
this.add(new Label(width / 2 - 200, 36, 400, 20, "Name", true)); this.add(new Label(width - 390, 116, 388, "Name", true));
this.add(new Label(width - 396, height - 384, 392, 20, "Beschreibung", true)); this.add(new Label(width - 390, 170, 388, "Beschreibung", true));
final Textbox descField = this.add(new Textbox(width - 396, height - 364, 392, 130, IPlayer.MAX_INFO_LENGTH, new Textbox.Callback() { final Area descField = this.add(new Area(width - 390, 170, 388, height - 328, IPlayer.MAX_INFO_LENGTH, ""));
public void use(Textbox elem, Action value) { this.add(new ActButton(width - 195, height - 30, 193, 0, new ButtonCallback() {
} public void use(ActButton elem, PressType action) {
}, "")); if(GuiChar.this.gm.player != null) {
this.add(new ActButton(width - 198, height - 28, 194, 24, new ActButton.Callback() {
public void use(ActButton elem, Mode action) {
if(GuiChar.this.gm.thePlayer != null) {
GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ...")); GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ..."));
Dimension dim = UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension); Dimension dim = UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension);
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText())); GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId())); GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId()));
} }
} }
}, "Charakter erstellen")); }, "Charakter erstellen"));
this.add(new Textbox(width / 2 - 200, 36 + 20, 400, 24, IPlayer.MAX_NICK_LENGTH, true, new Textbox.Callback() { this.cancelButton = this.add(new ActButton(width - 390, height - 30, 193, 0, new ButtonCallback() {
public void use(Textbox elem, Action value) { public void use(ActButton elem, PressType action) {
if(value == Action.SEND || value == Action.UNFOCUS) { if(GuiChar.this.gm.player != null)
GuiChar.this.gm.displayGuiScreen(GuiCharacters.INSTANCE);
}
}, "Abbrechen"));
this.setCharsAvailable();
this.add(new Field(width - 390, 116, 388, 0, IPlayer.MAX_NICK_LENGTH, new FieldCallback() {
public void use(Field elem, FieldAction value) {
if(value == FieldAction.SEND || value == FieldAction.UNFOCUS) {
String name = elem.getText(); String name = elem.getText();
if(name.isEmpty()) if(name.isEmpty())
elem.setText(GuiChar.this.gm.thePlayer == null ? "..." : GuiChar.this.gm.thePlayer.getCustomNameTag()); elem.setText(GuiChar.this.gm.player == null ? "..." : GuiChar.this.gm.player.getCustomNameTag());
else if(GuiChar.this.gm.thePlayer != null) { else if(GuiChar.this.gm.player != null) {
GuiChar.this.waiting = false; GuiChar.this.waiting = false;
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name)); GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name));
} }
} }
} }
}, IPlayer.VALID_NICK, this.gm.thePlayer == null ? "" : this.gm.thePlayer.getCustomNameTag())); }, IPlayer.VALID_NICK, this.gm.player == null ? "" : this.gm.player.getCustomNameTag()));
this.templateButton.enabled = false; this.templateButton.enabled = false;
this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size()); this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size());
EntityEggInfo egg = EntityRegistry.SPAWN_EGGS.get(this.gm.thePlayer == null ? EntityRegistry.getEntityString(EntityHuman.class) : EntityRegistry.getEntityString(this.gm.thePlayer)); EntityInfo egg = EntityRegistry.SPAWN_EGGS.get(this.gm.player == null ? EntityRegistry.getEntityString(EntityHuman.class) : EntityRegistry.getEntityString(this.gm.player));
if(egg != null && egg.origin != null) { if(egg != null && egg.origin() != null) {
Dimension dim = UniverseRegistry.getDimension(egg.origin); Dimension dim = UniverseRegistry.getDimension(egg.origin());
if(dim != null) { if(dim != null) {
for(int z = 0; z < UniverseRegistry.getBaseDimensions().size(); z++) { for(int z = 0; z < UniverseRegistry.getBaseDimensions().size(); z++) {
if(UniverseRegistry.getBaseDimensions().get(z).getDimensionId() == dim.getDimensionId()) { if(UniverseRegistry.getBaseDimensions().get(z).getDimensionId() == dim.getDimensionId()) {
@ -410,12 +423,12 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
} }
} }
} }
this.dimButton = this.add(new ActButton(width - 396, height - 220, 392, 24, new ActButton.Callback() { this.dimButton = this.add(new ActButton(width - 390, height - 156, 388, 0, new ButtonCallback() {
public void use(ActButton elem, Mode mode) { public void use(ActButton elem, PressType mode) {
if(mode == Mode.TERTIARY) { if(mode == PressType.TERTIARY) {
GuiChar.this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size()); GuiChar.this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size());
} }
else if(mode == Mode.SECONDARY) { else if(mode == PressType.SECONDARY) {
if(--GuiChar.this.dimension < 0) if(--GuiChar.this.dimension < 0)
GuiChar.this.dimension = UniverseRegistry.getBaseDimensions().size() - 1; GuiChar.this.dimension = UniverseRegistry.getBaseDimensions().size() - 1;
} }
@ -426,7 +439,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
GuiChar.this.setDimButton(); GuiChar.this.setDimButton();
} }
}, "")); }, ""));
this.descLines = this.add(new TransparentBox(width - 396, height - 220 + 24, 392, 66, "", false)); this.descLines = this.add(new MultiLabel(width - 390, height - 156 + Element.BASE_HEIGHT, 388, 42, "", true));
this.setDimButton(); this.setDimButton();
} }
@ -446,10 +459,12 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
public void drawOverlays() public void drawOverlays()
{ {
if(this.adjust != null) { if(this.adjust != null) {
float factor = this.gm.thePlayer.width > 2.15f ? 2.15f / this.gm.thePlayer.width : 1.0f; float factor = this.gm.player.width > 2.15f ? 2.15f / this.gm.player.width : 1.0f;
factor = this.gm.thePlayer.height > 3.0f && 3.0f / this.gm.thePlayer.height < factor ? 3.0f / this.gm.thePlayer.height : factor; factor = this.gm.player.height > 3.0f && 3.0f / this.gm.player.height < factor ? 3.0f / this.gm.player.height : factor;
drawEntity(400 + (this.gm.fb_x - 400 - 400) / 2, this.gm.fb_y - 160, 160.0f * factor if(this.gm.fb_x >= 784 + 460 && this.gm.fb_y >= 128 + 640)
, this.yaw, this.pitch, this.gm.thePlayer); drawEntity(400 + (this.gm.fb_x - 400 - 400) / 2, this.gm.fb_y - 160, 160.0f * factor, this.yaw, this.pitch, this.gm.player);
else
drawEntity(390 - 4 - 115 / 2, this.gm.fb_y - 60, 40.0f * factor, this.yaw, this.pitch, this.gm.player);
} }
} }
@ -469,6 +484,11 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
return "Charakter anpassen"; return "Charakter anpassen";
} }
public void setCharsAvailable() {
if(this.cancelButton != null)
this.cancelButton.enabled = !this.gm.characterList.isEmpty();
}
public static BufferedImage loadSkin(File file) public static BufferedImage loadSkin(File file)
{ {
BufferedImage img = null; BufferedImage img = null;
@ -537,11 +557,6 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
this.elements.clear(); this.elements.clear();
} }
public int getListWidth()
{
return 400 - 20;
}
public int getSlotHeight() public int getSlotHeight()
{ {
return 64 + 4; return 64 + 4;
@ -613,7 +628,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
ent.headYaw = ent.rotYaw; ent.headYaw = ent.rotYaw;
ent.prevHeadYaw = ent.rotYaw; ent.prevHeadYaw = ent.rotYaw;
GL11.glTranslatef(0.0F, -(ent.height / 2), 0.0F); GL11.glTranslatef(0.0F, -(ent.height / 2), 0.0F);
RenderManager rendermanager = Game.getGame().getRenderManager(); RenderManager rendermanager = Client.CLIENT.getRenderManager();
rendermanager.setPlayerViewY(180.0F); rendermanager.setPlayerViewY(180.0F);
rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 1.0F); rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 1.0F);
// GL11.glTranslatef(0.0F, 0.0F, 0.0F); // GL11.glTranslatef(0.0F, 0.0F, 0.0F);

View file

@ -1,19 +1,23 @@
package client.gui.character; package client.gui.character;
import client.gui.Font;
import client.gui.GuiConfirm; import client.gui.GuiConfirm;
import client.gui.GuiMenu; import client.gui.GuiMenu;
import client.gui.element.ActButton; import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode; import client.gui.element.Area;
import client.gui.element.ButtonCallback;
import client.gui.element.GuiList; import client.gui.element.GuiList;
import client.gui.element.ListEntry; import client.gui.element.ListEntry;
import client.gui.element.NavButton; import client.gui.element.NavButton;
import client.gui.element.TransparentBox; import client.gui.element.PressType;
import client.renderer.Drawing; import client.renderer.Drawing;
import common.color.TextColor; import common.color.TextColor;
import common.entity.npc.PlayerCharacter; import common.entity.npc.PlayerCharacter;
import common.packet.CPacketAction; import common.packet.CPacketAction;
import common.packet.CPacketAction.Action;
import common.util.ExtMath;
public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> implements ActButton.Callback public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> implements ButtonCallback
{ {
protected class CharacterEntry implements ListEntry protected class CharacterEntry implements ListEntry
{ {
@ -26,31 +30,31 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
this.initial = initial; this.initial = initial;
} }
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered) public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered)
{ {
if(this.initial) if(this.initial)
Drawing.drawRect(x, y, 1, 36, 0xffaf0000); Drawing.drawRect(x, y, 1, 36, 0xffaf0000);
String str = this.character == null ? TextColor.BLUE + "[" + TextColor.CYAN + "+" + TextColor.BLUE + "]" : String str = this.character == null ? TextColor.BLUE + "[" + TextColor.CYAN + "+" + TextColor.BLUE + "]" :
String.format(TextColor.GREEN + "Level " + TextColor.DGREEN + "%d " + TextColor.YELLOW + "%s " + TextColor.VIOLET + "%s" + TextColor.GRAY + " [%s%s" + TextColor.GRAY + "]", String.format(TextColor.GREEN + "Level " + TextColor.DGREEN + "%d " + TextColor.YELLOW + "%s " + TextColor.VIOLET + "%s",
character.level, character.type, character.name, character.align.color, character.align.display); character.level(), character.type(), character.name());
String pos = this.character == null ? TextColor.BROWN + "Neuen Charakter erstellen" : String pos = this.character == null ? TextColor.BROWN + "Neuen Charakter erstellen" :
String.format(TextColor.NEON + "%s " + TextColor.GRAY + "bei " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.ACID + "%d", String.format(TextColor.NEON + "%s " + TextColor.GRAY + "bei " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.ACID + "%d",
character.dim, character.pos.getX(), character.pos.getY(), character.pos.getZ()); character.dim(), character.pos().getX(), character.pos().getY(), character.pos().getZ());
Drawing.drawText(str, x + 3, y, 0xffffffff); Drawing.drawText(str, x + 3, y, 0xffffffff);
Drawing.drawText(pos, x + 3, y + 16, 0xffffffff); Drawing.drawText(pos, x + 3, y + height - Font.YGLYPH, 0xffffffff);
} }
public void select(boolean dclick, int mx, int my) public void select(boolean dclick, int mx, int my)
{ {
if(dclick) if(dclick)
GuiCharacters.this.use(GuiCharacters.this.actionButtom, Mode.PRIMARY); GuiCharacters.this.use(GuiCharacters.this.actionButtom, PressType.PRIMARY);
GuiCharacters.this.updateButtons(); GuiCharacters.this.updateButtons();
} }
} }
public static final GuiCharacters INSTANCE = new GuiCharacters(); public static final GuiCharacters INSTANCE = new GuiCharacters();
private TransparentBox descField; private Area descField;
private ActButton actionButtom; private ActButton actionButtom;
private ActButton deleteButtom; private ActButton deleteButtom;
@ -59,39 +63,33 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
private void updateButtons() { private void updateButtons() {
CharacterEntry entry = this.getSelected(); CharacterEntry entry = this.getSelected();
this.descField.setText(entry == null ? "" : (entry.character == null ? "*neuer Charakter*" : (entry.character.info == null ? "*keine Beschreibung vorhanden*" : this.getSelected().character.info))); this.descField.setText(entry == null ? "" : (entry.character == null ? "*neuer Charakter*" : String.format(TextColor.GRAY + "[%s%s" + TextColor.GRAY + "]\n" + TextColor.RESET + "%s", entry.character.align().color, entry.character.align().display, entry.character.info() == null ? "*keine Beschreibung vorhanden*" : this.getSelected().character.info())));
this.actionButtom.setText(entry != null && entry.character == null ? "Charakter erstellen" : "Charakter spielen"); this.actionButtom.setText(entry != null && entry.character == null ? "Charakter erstellen" : "Charakter spielen");
this.actionButtom.enabled = entry != null && !entry.initial; this.actionButtom.enabled = entry != null && !entry.initial;
this.deleteButtom.enabled = entry != null && entry.character != null && !entry.initial; this.deleteButtom.enabled = !this.gm.charEditor && entry != null && entry.character != null && !entry.initial;
} }
public void init(int width, int height) public void init(int width, int height)
{ {
super.init(width, height); super.init(width, height);
this.setDimensions(600, height, 32, height - 32); this.setDimensions(width - 300, height, 32, height - 32);
this.elements.clear(); this.elements.clear();
if(this.gm.getNetHandler() != null) { int selected = this.gm.selectedCharacter;
int initialSelection = this.gm.getNetHandler().getSelectedCharacter(); for(PlayerCharacter character : this.gm.characterList) {
for(PlayerCharacter character : this.gm.getNetHandler().getCharacterList()) { this.elements.add(new CharacterEntry(selected == this.elements.size() ? new PlayerCharacter(character.name(), character.info(), character.align(), this.gm.player.worldObj.dimension.getFormattedName(false), this.gm.player.getPosition(), character.type(), this.gm.player.experienceLevel) : character, selected == this.elements.size()));
this.elements.add(new CharacterEntry(initialSelection == this.elements.size() ? new PlayerCharacter(character.name, character.info, character.align, this.gm.thePlayer.worldObj.dimension.getFormattedName(false), this.gm.thePlayer.getPosition(), character.type, this.gm.thePlayer.experienceLevel) : character, initialSelection == this.elements.size()));
} }
if(!this.gm.charEditor)
this.elements.add(new CharacterEntry(null, false)); this.elements.add(new CharacterEntry(null, false));
this.setSelected(initialSelection); this.setSelected(ExtMath.clampi(selected, -1, this.elements.size() - 1));
} this.descField = this.add(new Area(width - 300, 32, 300, height - 64, ""));
this.descField = this.add(new TransparentBox(width - 390, 62, 380, height - 124, "", false)); this.deleteButtom = this.add(new ActButton(width / 2 - 302, height - 30, 200, 0, this, "Charakter löschen"));
this.deleteButtom = this.add(new ActButton(width / 2 - 304, height - 28, 200, 24, this, "Charakter löschen")); this.actionButtom = this.add(new ActButton(width / 2 - 100, height - 30, 200, 0, this, ""));
this.actionButtom = this.add(new ActButton(width / 2 - 100, height - 28, 200, 24, this, "")); this.add(new NavButton(width / 2 + 102, height - 30, 200, 0, this.gm.charEditor ? GuiChar.INSTANCE : GuiMenu.INSTANCE, this.gm.charEditor ? "Zurück" : "Abbrechen"));
this.add(new NavButton(width / 2 + 104, height - 28, 200, 24, GuiMenu.INSTANCE, "Abbrechen"));
this.updateButtons(); this.updateButtons();
} }
public String getTitle() { public String getTitle() {
return "Charakter anpassen"; return "Charakter auswählen";
}
public int getListWidth()
{
return 560;
} }
public int getSlotHeight() public int getSlotHeight()
@ -99,14 +97,14 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
return 36 + 4; return 36 + 4;
} }
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
CharacterEntry entry = GuiCharacters.this.getSelected(); CharacterEntry entry = GuiCharacters.this.getSelected();
if(entry != null && GuiCharacters.this.gm.getNetHandler() != null) { if(entry != null && GuiCharacters.this.gm.getNetHandler() != null) {
if(elem == this.actionButtom) { if(elem == this.actionButtom) {
if(entry.character == null) if(entry.character == null)
this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.OPEN_EDITOR)); this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.OPEN_EDITOR));
else else
this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.SELECT_CHARACTER, this.selectedElement)); this.gm.getNetHandler().addToSendQueue(new CPacketAction(GuiCharacters.this.gm.charEditor ? Action.CANCEL_EDITOR : CPacketAction.Action.SELECT_CHARACTER, this.selectedElement));
} }
else if(elem == this.deleteButtom && entry.character != null) { else if(elem == this.deleteButtom && entry.character != null) {
this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() { this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() {
@ -115,7 +113,7 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
GuiCharacters.this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.DELETE_CHARACTER, GuiCharacters.this.selectedElement)); GuiCharacters.this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.DELETE_CHARACTER, GuiCharacters.this.selectedElement));
GuiCharacters.this.gm.displayGuiScreen(GuiCharacters.this); GuiCharacters.this.gm.displayGuiScreen(GuiCharacters.this);
} }
}, "Möchtest du diesen Charakter wirklich löschen?", "Der Fortschritt, die Gegenstände und die Historie von \"" + entry.character.name + "\" werden für imer verloren sein!", "Löschen", "Abbrechen")); }, "Möchtest du diesen Charakter wirklich löschen?", "Der Fortschritt, die Gegenstände und die Historie\nvon \"" + entry.character.name() + "\" werden für immer verloren sein!", "Löschen", "Abbrechen"));
} }
} }
} }

View file

@ -1,14 +1,15 @@
package client.gui.character; package client.gui.character;
import client.gui.element.ActButton; import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode; import client.gui.element.ButtonCallback;
import client.gui.element.GuiList; import client.gui.element.GuiList;
import client.gui.element.ListEntry; import client.gui.element.ListEntry;
import client.gui.element.NavButton; import client.gui.element.NavButton;
import client.gui.element.PressType;
import client.renderer.Drawing; import client.renderer.Drawing;
import common.packet.CPacketAction; import common.packet.CPacketAction;
public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ActButton.Callback public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ButtonCallback
{ {
protected class ClassEntry implements ListEntry protected class ClassEntry implements ListEntry
{ {
@ -19,17 +20,17 @@ public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ActButton.
this.clazz = clazz; this.clazz = clazz;
} }
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered) public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered)
{ {
if(GuiClass.this.gm.thePlayer != null && this.clazz == GuiClass.this.gm.thePlayer.getNpcClass()) if(GuiClass.this.gm.player != null && this.clazz == GuiClass.this.gm.player.getNpcClass())
Drawing.drawRect(x, y, 1, 44, 0xffaf0000); Drawing.drawRect(x, y, 1, 44, 0xffaf0000);
Drawing.drawText(this.clazz.toString().isEmpty() ? "<Keine>" : this.clazz.toString(), x + 3, y, 0xffffffff); Drawing.drawText(this.clazz.toString().isEmpty() ? "<Keine>" : this.clazz.toString(), x + 3, y, 0xffffffff);
} }
public void select(boolean dclick, int mx, int my) public void select(boolean dclick, int mx, int my)
{ {
if((GuiClass.this.selectButton.enabled = GuiClass.this.gm.thePlayer == null || this.clazz != GuiClass.this.gm.thePlayer.getNpcClass()) && dclick) if((GuiClass.this.selectButton.enabled = GuiClass.this.gm.player == null || this.clazz != GuiClass.this.gm.player.getNpcClass()) && dclick)
GuiClass.this.use(GuiClass.this.selectButton, Mode.PRIMARY); GuiClass.this.use(GuiClass.this.selectButton, PressType.PRIMARY);
} }
} }
@ -43,34 +44,29 @@ public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ActButton.
public void init(int width, int height) public void init(int width, int height)
{ {
super.init(width, height); super.init(width, height);
this.setDimensions(400, height, 32, height - 32); this.setDimensions(width, height, 32, height - 32);
this.elements.clear(); this.elements.clear();
if(this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null) if(this.gm.player != null && this.gm.player.getSpecies().classEnum != null)
for(Enum clazz : this.gm.thePlayer.getSpecies().classEnum.getEnumConstants()) { for(Enum clazz : this.gm.player.getSpecies().classEnum.getEnumConstants()) {
this.elements.add(new ClassEntry(clazz)); this.elements.add(new ClassEntry(clazz));
} }
this.add(new NavButton(width - 198 * 2, height - 28, 194, 24, GuiChar.INSTANCE, "Zurück")); this.add(new NavButton(width / 2 - 195, height - 30, 194, 0, GuiChar.INSTANCE, "Zurück"));
this.selectButton = this.add(new ActButton(width - 198, height - 28, 194, 24, this, "Klasse ändern")); this.selectButton = this.add(new ActButton(width / 2 + 1, height - 30, 194, 0, this, "Klasse ändern"));
} }
public String getTitle() { public String getTitle() {
return "Klasse wählen"; return "Klasse wählen";
} }
public int getListWidth()
{
return 400 - 20;
}
public int getSlotHeight() public int getSlotHeight()
{ {
return 44 + 4; return 44 + 4;
} }
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
ClassEntry entry = this.getSelected(); ClassEntry entry = this.getSelected();
if(entry != null && GuiClass.this.gm.thePlayer != null) { if(entry != null && GuiClass.this.gm.player != null) {
GuiClass.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_CLASS, entry.clazz.ordinal())); GuiClass.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_CLASS, entry.clazz.ordinal()));
this.gm.displayGuiScreen(GuiChar.INSTANCE); this.gm.displayGuiScreen(GuiChar.INSTANCE);
} }
} }

View file

@ -1,17 +1,18 @@
package client.gui.character; package client.gui.character;
import client.gui.element.ActButton; import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode; import client.gui.element.ButtonCallback;
import client.gui.element.GuiList; import client.gui.element.GuiList;
import client.gui.element.ListEntry; import client.gui.element.ListEntry;
import client.gui.element.NavButton; import client.gui.element.NavButton;
import client.gui.element.PressType;
import client.renderer.Drawing; import client.renderer.Drawing;
import common.entity.npc.SpeciesInfo; import common.entity.npc.SpeciesInfo;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.init.SpeciesRegistry; import common.init.SpeciesRegistry;
import common.packet.CPacketAction; import common.packet.CPacketAction;
public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ActButton.Callback public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ButtonCallback
{ {
protected class SpeciesEntry implements ListEntry protected class SpeciesEntry implements ListEntry
{ {
@ -22,9 +23,9 @@ public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ActB
this.species = species; this.species = species;
} }
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered) public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered)
{ {
if(GuiSpecies.this.gm.thePlayer != null && this.species == GuiSpecies.this.gm.thePlayer.getSpecies()) if(GuiSpecies.this.gm.player != null && this.species == GuiSpecies.this.gm.player.getSpecies())
Drawing.drawRect(x, y, 1, 44, 0xffaf0000); Drawing.drawRect(x, y, 1, 44, 0xffaf0000);
Drawing.drawText(this.species.name, x + 3, y, 0xff000000 | this.species.color1 | this.species.color2); Drawing.drawText(this.species.name, x + 3, y, 0xff000000 | this.species.color1 | this.species.color2);
if(this.species.classEnum != null) if(this.species.classEnum != null)
@ -33,8 +34,8 @@ public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ActB
public void select(boolean dclick, int mx, int my) public void select(boolean dclick, int mx, int my)
{ {
if((GuiSpecies.this.selectButton.enabled = GuiSpecies.this.gm.thePlayer == null || this.species != GuiSpecies.this.gm.thePlayer.getSpecies()) && dclick) if((GuiSpecies.this.selectButton.enabled = GuiSpecies.this.gm.player == null || this.species != GuiSpecies.this.gm.player.getSpecies()) && dclick)
GuiSpecies.this.use(GuiSpecies.this.selectButton, Mode.PRIMARY); GuiSpecies.this.use(GuiSpecies.this.selectButton, PressType.PRIMARY);
} }
} }
@ -48,32 +49,27 @@ public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ActB
public void init(int width, int height) public void init(int width, int height)
{ {
super.init(width, height); super.init(width, height);
this.setDimensions(400, height, 32, height - 32); this.setDimensions(width, height, 32, height - 32);
this.elements.clear(); this.elements.clear();
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) { for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
this.elements.add(new SpeciesEntry(species)); this.elements.add(new SpeciesEntry(species));
} }
this.add(new NavButton(width - 198 * 2, height - 28, 194, 24, GuiChar.INSTANCE, "Zurück")); this.add(new NavButton(width / 2 - 195, height - 30, 194, 0, GuiChar.INSTANCE, "Zurück"));
this.selectButton = this.add(new ActButton(width - 198, height - 28, 194, 24, this, "Spezies ändern")); this.selectButton = this.add(new ActButton(width / 2 + 1, height - 30, 194, 0, this, "Spezies ändern"));
} }
public String getTitle() { public String getTitle() {
return "Spezies wählen"; return "Spezies wählen";
} }
public int getListWidth()
{
return 400 - 20;
}
public int getSlotHeight() public int getSlotHeight()
{ {
return 44 + 4; return 44 + 4;
} }
public void use(ActButton elem, Mode action) { public void use(ActButton elem, PressType action) {
SpeciesEntry entry = this.getSelected(); SpeciesEntry entry = this.getSelected();
if(entry != null && GuiSpecies.this.gm.thePlayer != null) if(entry != null && GuiSpecies.this.gm.player != null)
GuiSpecies.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_SPECIES, EntityRegistry.getEntityID(entry.species.clazz))); GuiSpecies.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_SPECIES, EntityRegistry.getEntityID(entry.species.clazz)));
} }
} }

View file

@ -1,6 +1,6 @@
package client.gui.container; package client.gui.container;
import client.Game; import client.Client;
import common.inventory.ContainerChest; import common.inventory.ContainerChest;
import common.inventory.IInventory; import common.inventory.IInventory;
@ -19,7 +19,7 @@ public class GuiChest extends GuiContainer
public GuiChest(IInventory upperInv, IInventory lowerInv) public GuiChest(IInventory upperInv, IInventory lowerInv)
{ {
super(new ContainerChest(upperInv, lowerInv, Game.getGame().thePlayer)); super(new ContainerChest(upperInv, lowerInv, Client.CLIENT.player));
this.upperChestInventory = upperInv; this.upperChestInventory = upperInv;
this.lowerChestInventory = lowerInv; this.lowerChestInventory = lowerInv;
// this.allowUserInput = false; // this.allowUserInput = false;

View file

@ -6,6 +6,7 @@ import java.util.Set;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL13;
import client.gui.Font;
import client.gui.Gui; import client.gui.Gui;
import client.gui.element.InventoryButton; import client.gui.element.InventoryButton;
import client.renderer.Drawing; import client.renderer.Drawing;
@ -42,7 +43,7 @@ public abstract class GuiContainer extends Gui
private static final List<ItemStack> ITEM_LIST = Lists.<ItemStack>newArrayList(); private static final List<ItemStack> ITEM_LIST = Lists.<ItemStack>newArrayList();
private static CheatTab selectedTab = CheatTab.tabBlocks; private static CheatTab selectedTab = CheatTab.BLOCKS;
// /** The location of the inventory background texture */ // /** The location of the inventory background texture */
// protected static final String inventoryBackground = "textures/gui/inventory.png"; // protected static final String inventoryBackground = "textures/gui/inventory.png";
@ -213,7 +214,7 @@ public abstract class GuiContainer extends Gui
*/ */
public void initGui() public void initGui()
{ {
this.gm.thePlayer.openContainer = this.inventorySlots; this.gm.player.openContainer = this.inventorySlots;
// this.guiLeft = (this.width - this.xSize) / 2; // this.guiLeft = (this.width - this.xSize) / 2;
// this.guiTop = (this.height - this.ySize) / 2; // this.guiTop = (this.height - this.ySize) / 2;
// this.addButtons(); // this.addButtons();
@ -360,7 +361,7 @@ public abstract class GuiContainer extends Gui
ItemRenderer.disableStandardItemLighting(); ItemRenderer.disableStandardItemLighting();
// this.drawGuiContainerForegroundLayer(mouseX, mouseY); // this.drawGuiContainerForegroundLayer(mouseX, mouseY);
ItemRenderer.enableGUIStandardItemLighting(); ItemRenderer.enableGUIStandardItemLighting();
InventoryPlayer inventoryplayer = this.gm.thePlayer.inventory; InventoryPlayer inventoryplayer = this.gm.player.inventory;
ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack; ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack;
if(this.gm.itemCheat) if(this.gm.itemCheat)
itemstack = itemstack == null ? this.cheatStack : itemstack; itemstack = itemstack == null ? this.cheatStack : itemstack;
@ -374,20 +375,20 @@ public abstract class GuiContainer extends Gui
if (this.draggedStack != null && this.isRightMouseClick) if (this.draggedStack != null && this.isRightMouseClick)
{ {
itemstack = itemstack.copy(); itemstack = itemstack.copy();
itemstack.stackSize = ExtMath.ceilf((float)itemstack.stackSize / 2.0F); itemstack.size = ExtMath.ceilf((float)itemstack.size / 2.0F);
} }
else if (this.dragSplitting && this.dragSplittingSlots.size() > 1) else if (this.dragSplitting && this.dragSplittingSlots.size() > 1)
{ {
itemstack = itemstack.copy(); itemstack = itemstack.copy();
itemstack.stackSize = this.dragSplittingRemnant; itemstack.size = this.dragSplittingRemnant;
if (itemstack.stackSize == 0) if (itemstack.size == 0)
{ {
s = "" + TextColor.YELLOW + "0"; s = "" + TextColor.YELLOW + "0";
} }
} }
else if(itemstack == this.cheatStack) { else if(itemstack == this.cheatStack) {
s = TextColor.DGREEN + "+" + TextColor.GREEN + ItemStack.formatAmount(itemstack.stackSize); s = TextColor.DGREEN + "+" + TextColor.GREEN + ItemStack.formatAmount(itemstack.size);
} }
this.drawItemStack(itemstack, mouseX - j2, mouseY - k2, s); this.drawItemStack(itemstack, mouseX - j2, mouseY - k2, s);
@ -451,7 +452,7 @@ public abstract class GuiContainer extends Gui
} }
protected void renderToolTip(ItemStack stack, int x, int y) { protected void renderToolTip(ItemStack stack, int x, int y) {
List<String> list = stack.getTooltip(this.gm.thePlayer); List<String> list = stack.getTooltip(this.gm.player);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for(int i = 0; i < list.size(); ++i) { for(int i = 0; i < list.size(); ++i) {
if(i != 0) if(i != 0)
@ -512,13 +513,13 @@ public abstract class GuiContainer extends Gui
ItemStack itemstack = slotIn.getStack(); ItemStack itemstack = slotIn.getStack();
boolean flag = false; boolean flag = false;
boolean flag1 = slotIn == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick; boolean flag1 = slotIn == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick;
ItemStack itemstack1 = this.gm.thePlayer.inventory.getItemStack(); ItemStack itemstack1 = this.gm.player.inventory.getItemStack();
String s = null; String s = null;
if (slotIn == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null) if (slotIn == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null)
{ {
itemstack = itemstack.copy(); itemstack = itemstack.copy();
itemstack.stackSize /= 2; itemstack.size /= 2;
} }
else if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && itemstack1 != null) else if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && itemstack1 != null)
{ {
@ -531,18 +532,18 @@ public abstract class GuiContainer extends Gui
{ {
itemstack = itemstack1.copy(); itemstack = itemstack1.copy();
flag = true; flag = true;
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slotIn.getStack() == null ? 0 : slotIn.getStack().stackSize); Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slotIn.getStack() == null ? 0 : slotIn.getStack().size);
if (itemstack.stackSize > itemstack.getMaxStackSize()) if (itemstack.size > itemstack.getMaxStackSize())
{ {
s = TextColor.YELLOW + ItemStack.formatAmount(itemstack.getMaxStackSize()); s = TextColor.YELLOW + ItemStack.formatAmount(itemstack.getMaxStackSize());
itemstack.stackSize = itemstack.getMaxStackSize(); itemstack.size = itemstack.getMaxStackSize();
} }
if (itemstack.stackSize > slotIn.getItemStackLimit(itemstack)) if (itemstack.size > slotIn.getItemStackLimit(itemstack))
{ {
s = TextColor.YELLOW + ItemStack.formatAmount(slotIn.getItemStackLimit(itemstack)); s = TextColor.YELLOW + ItemStack.formatAmount(slotIn.getItemStackLimit(itemstack));
itemstack.stackSize = slotIn.getItemStackLimit(itemstack); itemstack.size = slotIn.getItemStackLimit(itemstack);
} }
} }
else else
@ -589,29 +590,29 @@ public abstract class GuiContainer extends Gui
private void updateDragSplitting() private void updateDragSplitting()
{ {
ItemStack itemstack = this.gm.thePlayer.inventory.getItemStack(); ItemStack itemstack = this.gm.player.inventory.getItemStack();
if (itemstack != null && this.dragSplitting) if (itemstack != null && this.dragSplitting)
{ {
this.dragSplittingRemnant = itemstack.stackSize; this.dragSplittingRemnant = itemstack.size;
for (Slot slot : this.dragSplittingSlots) for (Slot slot : this.dragSplittingSlots)
{ {
ItemStack itemstack1 = itemstack.copy(); ItemStack itemstack1 = itemstack.copy();
int i = slot.getStack() == null ? 0 : slot.getStack().stackSize; int i = slot.getStack() == null ? 0 : slot.getStack().size;
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i); Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);
if (itemstack1.stackSize > itemstack1.getMaxStackSize()) if (itemstack1.size > itemstack1.getMaxStackSize())
{ {
itemstack1.stackSize = itemstack1.getMaxStackSize(); itemstack1.size = itemstack1.getMaxStackSize();
} }
if (itemstack1.stackSize > slot.getItemStackLimit(itemstack1)) if (itemstack1.size > slot.getItemStackLimit(itemstack1))
{ {
itemstack1.stackSize = slot.getItemStackLimit(itemstack1); itemstack1.size = slot.getItemStackLimit(itemstack1);
} }
this.dragSplittingRemnant -= itemstack1.stackSize - i; this.dragSplittingRemnant -= itemstack1.size - i;
} }
} }
} }
@ -643,8 +644,8 @@ public abstract class GuiContainer extends Gui
return; return;
if(this.cheatStack != null) { if(this.cheatStack != null) {
Slot slot = this.getSlotAtPosition(mouseX, mouseY); Slot slot = this.getSlotAtPosition(mouseX, mouseY);
if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.thePlayer != null && slot.inventory == this.gm.thePlayer.inventory) if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.player != null && slot.inventory == this.gm.player.inventory)
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(this.cheatStack, slot.getIndex(), mouseButton == 0 && this.cheatStack.stackSize > 1)); this.gm.player.client.addToSendQueue(new CPacketCheat(this.cheatStack, slot.getIndex(), mouseButton == 0 && this.cheatStack.size > 1));
if(mouseButton != 1 && !this.gm.ctrl()) if(mouseButton != 1 && !this.gm.ctrl())
this.cheatStack = null; this.cheatStack = null;
return; return;
@ -652,7 +653,7 @@ public abstract class GuiContainer extends Gui
if((mouseButton == 0 || mouseButton == 1 || mouseButton == 2) && this.clickSide(mouseX, mouseY, -1, this.gm.shift() || mouseButton == 1, this.gm.ctrl() || mouseButton == 2)) if((mouseButton == 0 || mouseButton == 1 || mouseButton == 2) && this.clickSide(mouseX, mouseY, -1, this.gm.shift() || mouseButton == 1, this.gm.ctrl() || mouseButton == 2))
return; return;
if(mouseButton == 0) { if(mouseButton == 0) {
if(this.gm.itemCheat && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null) { if(this.gm.itemCheat && this.gm.player != null && this.gm.player.inventory.getItemStack() == null) {
for (CheatTab tab : CheatTab.values()) for (CheatTab tab : CheatTab.values())
{ {
if (this.isInsideTab(tab, mouseX, mouseY)) if (this.isInsideTab(tab, mouseX, mouseY))
@ -711,7 +712,7 @@ public abstract class GuiContainer extends Gui
// else // else
if (!this.dragSplitting) if (!this.dragSplitting)
{ {
if (this.gm.thePlayer.inventory.getItemStack() == null) if (this.gm.player.inventory.getItemStack() == null)
{ {
// if (mouseButton == this.gm.bindTertiary.getKeyCode() + 100) // if (mouseButton == this.gm.bindTertiary.getKeyCode() + 100)
// { // {
@ -774,7 +775,7 @@ public abstract class GuiContainer extends Gui
if(this.gm == null || this.cheatStack != null) if(this.gm == null || this.cheatStack != null)
return; return;
Slot slot = this.getSlotAtPosition(mouseX, mouseY); Slot slot = this.getSlotAtPosition(mouseX, mouseY);
ItemStack itemstack = this.gm.thePlayer.inventory.getItemStack(); ItemStack itemstack = this.gm.player.inventory.getItemStack();
// if (this.clickedSlot != null && this.gm.touchscreen) // if (this.clickedSlot != null && this.gm.touchscreen)
// { // {
@ -811,7 +812,7 @@ public abstract class GuiContainer extends Gui
// } // }
// } // }
// else // else
if (this.dragSplitting && slot != null && itemstack != null && itemstack.stackSize > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot)) if (this.dragSplitting && slot != null && itemstack != null && itemstack.size > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
{ {
this.dragSplittingSlots.add(slot); this.dragSplittingSlots.add(slot);
this.updateDragSplitting(); this.updateDragSplitting();
@ -849,7 +850,7 @@ public abstract class GuiContainer extends Gui
{ {
for (Slot slot2 : this.inventorySlots.inventorySlots) for (Slot slot2 : this.inventorySlots.inventorySlots)
{ {
if (slot2 != null && slot2.canTakeStack(this.gm.thePlayer) && slot2.getHasStack() && slot2.inventory == slot.inventory && Container.canAddItemToSlot(slot2, this.shiftClickedSlot, true)) if (slot2 != null && slot2.canTakeStack(this.gm.player) && slot2.getHasStack() && slot2.inventory == slot.inventory && Container.canAddItemToSlot(slot2, this.shiftClickedSlot, true))
{ {
this.handleMouseClick(slot2, slot2.slotNumber, state, 1); this.handleMouseClick(slot2, slot2.slotNumber, state, 1);
} }
@ -935,7 +936,7 @@ public abstract class GuiContainer extends Gui
this.handleMouseClick((Slot)null, -999, Container.getDragCode(2, this.dragSplittingLimit), 5); this.handleMouseClick((Slot)null, -999, Container.getDragCode(2, this.dragSplittingLimit), 5);
} }
else if (this.gm.thePlayer.inventory.getItemStack() != null) else if (this.gm.player.inventory.getItemStack() != null)
{ {
// if (state == this.gm.bindTertiary.getKeyCode() + 100) // if (state == this.gm.bindTertiary.getKeyCode() + 100)
// { // {
@ -955,7 +956,7 @@ public abstract class GuiContainer extends Gui
} }
} }
if (this.gm.thePlayer.inventory.getItemStack() == null) if (this.gm.player.inventory.getItemStack() == null)
{ {
this.lastClickTime = 0L; this.lastClickTime = 0L;
} }
@ -994,11 +995,11 @@ public abstract class GuiContainer extends Gui
slotId = slotIn.slotNumber; slotId = slotIn.slotNumber;
} }
this.gm.controller.windowClick(this.inventorySlots.windowId, slotId, clickedButton, clickType, this.gm.thePlayer); this.gm.controller.windowClick(this.inventorySlots.windowId, slotId, clickedButton, clickType, this.gm.player);
} }
public void dropItem() { public void dropItem() {
if (this.gm != null && this.gm.thePlayer != null && this.theSlot != null && this.theSlot.getHasStack()) if (this.gm != null && this.gm.player != null && this.theSlot != null && this.theSlot.getHasStack())
{ {
// if (keyCode == this.gm.bindTertiary.getKeyCode()) // if (keyCode == this.gm.bindTertiary.getKeyCode())
// { // {
@ -1034,7 +1035,7 @@ public abstract class GuiContainer extends Gui
*/ */
public void useHotbar(int slot) public void useHotbar(int slot)
{ {
if (!this.clickSide((this.gm.mouse_x - this.container_x) / 2, (this.gm.mouse_y - this.container_y) / 2, slot, this.gm.shift(), this.gm.ctrl()) && this.gm != null && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.cheatStack == null && this.theSlot != null) if (!this.clickSide((this.gm.mouse_x - this.container_x) / 2, (this.gm.mouse_y - this.container_y) / 2, slot, this.gm.shift(), this.gm.ctrl()) && this.gm != null && this.gm.player != null && this.gm.player.inventory.getItemStack() == null && this.cheatStack == null && this.theSlot != null)
{ {
// for (int i = 0; i < 9; ++i) // for (int i = 0; i < 9; ++i)
// { // {
@ -1054,9 +1055,9 @@ public abstract class GuiContainer extends Gui
*/ */
public void onGuiClosed() public void onGuiClosed()
{ {
if (this.gm != null && this.gm.thePlayer != null) if (this.gm != null && this.gm.player != null)
{ {
this.inventorySlots.onContainerClosed(this.gm.thePlayer); this.inventorySlots.onContainerClosed(this.gm.player);
} }
} }
@ -1075,9 +1076,9 @@ public abstract class GuiContainer extends Gui
{ {
// super.updateScreen(); // super.updateScreen();
if (this.gm != null && this.gm.thePlayer != null && (!this.gm.thePlayer.isEntityAlive() || this.gm.thePlayer.dead)) if (this.gm != null && this.gm.player != null && (!this.gm.player.isEntityAlive() || this.gm.player.dead))
{ {
this.gm.thePlayer.closeScreen(); this.gm.displayGuiScreen(null);
} }
} }
@ -1090,13 +1091,13 @@ public abstract class GuiContainer extends Gui
{ {
if (stack != null) if (stack != null)
{ {
if (stack.stackSize != 1 || text != null) if (stack.size != 1 || text != null)
{ {
String s = text == null ? ItemStack.formatAmount(stack.stackSize) : text; String s = text == null ? ItemStack.formatAmount(stack.size) : text;
if (text == null && stack.stackSize < 1) if (text == null && stack.size < 1)
{ {
s = TextColor.RED + ItemStack.formatAmount(stack.stackSize); s = TextColor.RED + ItemStack.formatAmount(stack.size);
} }
// this.drawString(s, , ); // this.drawString(s, , );
// Vec2i size = Drawing.txt_size(0, 0, 0, 0, 65536, 65536, s); // Vec2i size = Drawing.txt_size(0, 0, 0, 0, 65536, 65536, s);
@ -1104,7 +1105,7 @@ public abstract class GuiContainer extends Gui
// int y = ; // int y = ;
// x = x * 2 + this.container_x; // x = x * 2 + this.container_x;
// y = y * 2 + this.container_y; // y = y * 2 + this.container_y;
Drawing.drawTextRight(s, xPosition + 32, yPosition + 17, 0xffffffff); Drawing.drawTextRight(s, xPosition + 32, yPosition + 33 - Font.YGLYPH, 0xffffffff);
} }
if (stack.isItemDamaged()) if (stack.isItemDamaged())
@ -1151,7 +1152,7 @@ public abstract class GuiContainer extends Gui
protected void drawTab(CheatTab tab) protected void drawTab(CheatTab tab)
{ {
this.itemRender.zLevel = 100.0F; this.itemRender.zLevel = 100.0F;
ItemStack itemstack = tab.getIconItemStack(); ItemStack itemstack = tab.getIcon();
GlState.enableDepth(); GlState.enableDepth();
this.itemRender.renderItemAndEffectIntoGUI(itemstack, this.xSize + 2 + 18 * tab.getHorizontal() + 1, 9 * 18 + 4 + 20 * tab.getVertical() + 1); this.itemRender.renderItemAndEffectIntoGUI(itemstack, this.xSize + 2 + 18 * tab.getHorizontal() + 1, 9 * 18 + 4 + 20 * tab.getVertical() + 1);
this.itemRender.zLevel = 0.0F; this.itemRender.zLevel = 0.0F;
@ -1176,13 +1177,13 @@ public abstract class GuiContainer extends Gui
selectedTab = tab; selectedTab = tab;
this.dragSplittingSlots.clear(); this.dragSplittingSlots.clear();
ITEM_LIST.clear(); ITEM_LIST.clear();
tab.displayAllReleventItems(ITEM_LIST); tab.filter(ITEM_LIST);
this.currentScroll = 0.0F; this.currentScroll = 0.0F;
} }
private boolean clickSide(int mouseX, int mouseY, int slot, boolean instant, boolean full) { private boolean clickSide(int mouseX, int mouseY, int slot, boolean instant, boolean full) {
if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * 12, 18 * 9, mouseX, mouseY) && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.cheatStack == null) { if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * 12, 18 * 9, mouseX, mouseY) && this.gm.player != null && this.gm.player.inventory.getItemStack() == null && this.cheatStack == null) {
int i = (ITEM_LIST.size() + 12 - 1) / 12 - 9; int i = (ITEM_LIST.size() + 12 - 1) / 12 - 9;
int j = (int)((double)(this.currentScroll * (float)i) + 0.5D); int j = (int)((double)(this.currentScroll * (float)i) + 0.5D);
@ -1197,11 +1198,11 @@ public abstract class GuiContainer extends Gui
if(i1 >= 0 && i1 < ITEM_LIST.size()) { if(i1 >= 0 && i1 < ITEM_LIST.size()) {
if(slot >= 0 || instant) { if(slot >= 0 || instant) {
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, full)); this.gm.player.client.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, full));
} }
else { else {
this.cheatStack = ITEM_LIST.get(i1).copy(); this.cheatStack = ITEM_LIST.get(i1).copy();
this.cheatStack.stackSize = full ? this.cheatStack.getMaxStackSize() : 1; this.cheatStack.size = full ? this.cheatStack.getMaxStackSize() : 1;
} }
return true; return true;
} }

View file

@ -0,0 +1,22 @@
package client.gui.container;
import common.block.tech.BlockWorkbench;
import common.inventory.ContainerWorkbench;
import common.inventory.InventoryPlayer;
import common.util.BlockPos;
import common.world.World;
public class GuiCrafting extends GuiContainer {
private final BlockWorkbench type;
public GuiCrafting(InventoryPlayer playerInv, World worldIn, BlockWorkbench type) {
super(new ContainerWorkbench(playerInv, worldIn, BlockPos.ORIGIN, type));
this.type = type;
this.ySize = 112 + 18 * this.type.getSize();
}
public void drawGuiContainerForegroundLayer() {
this.drawString("Handwerk (" + this.type.getDisplay() + ")", 26, 6);
this.drawString("Inventar", 8, this.ySize - 96 + 2);
}
}

View file

@ -5,7 +5,7 @@ import common.enchantment.Enchantment;
import common.inventory.ContainerEnchantment; import common.inventory.ContainerEnchantment;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.rng.Random; import common.rng.Random;
import common.tileentity.IWorldNameable; import common.util.Pair;
import common.world.World; import common.world.World;
public class GuiEnchant extends GuiContainer public class GuiEnchant extends GuiContainer
@ -19,7 +19,7 @@ public class GuiEnchant extends GuiContainer
private final Random nameRand = new Random(); private final Random nameRand = new Random();
private final Random random = new Random(); private final Random random = new Random();
private final ContainerEnchantment container; private final ContainerEnchantment container;
private final IWorldNameable table; private final String title;
// public int field_147073_u; // public int field_147073_u;
// public float field_147071_v; // public float field_147071_v;
@ -30,12 +30,12 @@ public class GuiEnchant extends GuiContainer
// public float field_147076_A; // public float field_147076_A;
// ItemStack field_147077_B; // ItemStack field_147077_B;
public GuiEnchant(InventoryPlayer inventory, World worldIn, IWorldNameable table) public GuiEnchant(InventoryPlayer inventory, World worldIn, String title)
{ {
super(new ContainerEnchantment(inventory, worldIn)); super(new ContainerEnchantment(inventory, worldIn));
this.playerInventory = inventory; this.playerInventory = inventory;
this.container = (ContainerEnchantment)this.inventorySlots; this.container = (ContainerEnchantment)this.inventorySlots;
this.table = table; this.title = title;
} }
/** /**
@ -43,7 +43,7 @@ public class GuiEnchant extends GuiContainer
*/ */
public void drawGuiContainerForegroundLayer() public void drawGuiContainerForegroundLayer()
{ {
this.drawString(this.table.getCommandName(), 12, 5); this.drawString(this.title, 12, 5);
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2); this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
} }
@ -70,7 +70,7 @@ public class GuiEnchant extends GuiContainer
int l = mouseX - 60; int l = mouseX - 60;
int i1 = mouseY - (14 + 19 * k); int i1 = mouseY - (14 + 19 * k);
if (l >= 0 && i1 >= 0 && l < 108 && i1 < 19 && this.container.enchantItem(this.gm.thePlayer, k)) if (l >= 0 && i1 >= 0 && l < 108 && i1 < 19 && this.container.enchantItem(this.gm.player, k))
{ {
this.gm.controller.sendEnchantPacket(this.container.windowId, k); this.gm.controller.sendEnchantPacket(this.container.windowId, k);
} }
@ -89,14 +89,14 @@ public class GuiEnchant extends GuiContainer
*/ */
public void drawGuiContainerBackgroundLayer() public void drawGuiContainerBackgroundLayer()
{ {
this.nameRand.setSeed((long)this.container.xpSeed); this.nameRand.setSeed((long)this.container.seed);
for (int l = 0; l < 3; ++l) for (int l = 0; l < 3; ++l)
{ {
int i1 = 60; int i1 = 60;
int j1 = i1 + 20; int j1 = i1 + 20;
String s = this.getRandomName(); String s = this.getRandomName();
int l1 = this.container.enchantLevels[l]; int l1 = this.container.mana[l];
if (l1 == 0) if (l1 == 0)
{ {
@ -107,7 +107,7 @@ public class GuiEnchant extends GuiContainer
String s1 = "" + l1; String s1 = "" + l1;
int i2 = 6839882; int i2 = 6839882;
if (/* (k < l + 1 || */ this.gm.thePlayer.experienceLevel < l1) // && !this.gm.thePlayer.creative) if (/* (k < l + 1 || */ this.gm.player.getManaPoints() < l1) // && !this.gm.thePlayer.creative)
{ {
this.rect(i1, 14 + 19 * l, 108, 19, 0x400000); this.rect(i1, 14 + 19 * l, 108, 19, 0x400000);
this.rect(i1 + 1, 15 + 19 * l, 16, 16, 0x200000); this.rect(i1 + 1, 15 + 19 * l, 16, 16, 0x200000);
@ -150,19 +150,16 @@ public class GuiEnchant extends GuiContainer
for (int j = 0; j < 3; ++j) for (int j = 0; j < 3; ++j)
{ {
int k = this.container.enchantLevels[j]; int k = this.container.mana[j];
int l = this.container.enchantmentIds[j]; Pair<Enchantment, Integer> l = this.container.ench[j];
int i1 = j + 1; int i1 = j + 1;
if (this.isPointInRegion(60, 14 + 19 * j, 108, 17, mouseX, mouseY) && k > 0 && l >= 0) if (this.isPointInRegion(60, 14 + 19 * j, 108, 17, mouseX, mouseY) && k > 0 && l != null)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (l >= 0 && Enchantment.getEnchantmentById(l & 255) != null) String s = l.first().getFormattedName(l.second());
{
String s = Enchantment.getEnchantmentById(l & 255).getFormattedName((l & 65280) >> 8);
sb.append(TextColor.WHITE + s + " . . . ?"); sb.append(TextColor.WHITE + s + " . . . ?");
}
// if (!flag) // if (!flag)
// { // {
@ -171,9 +168,9 @@ public class GuiEnchant extends GuiContainer
// sb.append("\n"); // sb.append("\n");
// } // }
if (this.gm.thePlayer.experienceLevel < k) if (this.gm.player.getManaPoints() < k)
{ {
sb.append((sb.length() != 0 ? "\n" : "") + TextColor.RED + String.format("Erfahrungsstufe %d erforderlich", this.container.enchantLevels[j])); sb.append((sb.length() != 0 ? "\n" : "") + TextColor.RED + String.format("%d Mana erforderlich", this.container.mana[j]));
} }
else else
{ {
@ -199,11 +196,11 @@ public class GuiEnchant extends GuiContainer
if (i1 == 1) if (i1 == 1)
{ {
s1 = "1 Erfahrungsstufe"; s1 = "1 Manapunkt";
} }
else else
{ {
s1 = String.format("%d Erfahrungsstufen", i1); s1 = String.format("%d Manapunkte", i1);
} }
sb.append((sb.length() != 0 ? "\n" : "") + TextColor.LGRAY.toString() + "" + s1); sb.append((sb.length() != 0 ? "\n" : "") + TextColor.LGRAY.toString() + "" + s1);

View file

@ -1,45 +1,26 @@
package client.gui.container; package client.gui.container;
import client.Game; import client.Client;
import common.entity.animal.EntityHorse; import common.entity.Entity;
import common.inventory.ContainerHorseInventory; import common.inventory.ContainerEntityInventory;
import common.inventory.IInventory; import common.inventory.IInventory;
public class GuiHorse extends GuiContainer public class GuiEntity extends GuiContainer
{ {
// private static final String horseGuiTextures = "textures/gui/horse.png";
/** The player inventory bound to this GUI. */
private IInventory playerInventory; private IInventory playerInventory;
private IInventory entityInventory;
/** The horse inventory bound to this GUI. */ public GuiEntity(IInventory playerInv, IInventory entityInv, Entity entity)
private IInventory horseInventory;
// /** The EntityHorse whose inventory is currently being accessed. */
// private EntityHorse horseEntity;
// /** The mouse x-position recorded during the last rendered frame. */
// private float mousePosx;
//
// /** The mouse y-position recorded during the last renderered frame. */
// private float mousePosY;
public GuiHorse(IInventory playerInv, IInventory horseInv, EntityHorse horse)
{ {
super(new ContainerHorseInventory(playerInv, horseInv, horse, Game.getGame().thePlayer)); super(new ContainerEntityInventory(playerInv, entityInv, entity, Client.CLIENT.player));
this.playerInventory = playerInv; this.playerInventory = playerInv;
this.horseInventory = horseInv; this.entityInventory = entityInv;
// this.horseEntity = horse;
// this.allowUserInput = false;
} }
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
*/
public void drawGuiContainerForegroundLayer() public void drawGuiContainerForegroundLayer()
{ {
this.drawString(this.horseInventory.getCommandName(), 8, 6); this.drawString(this.entityInventory.getCommandName(), 8, 6);
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2); this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
} }

View file

@ -1,6 +1,6 @@
package client.gui.container; package client.gui.container;
import client.Game; import client.Client;
import common.inventory.ContainerHopper; import common.inventory.ContainerHopper;
import common.inventory.IInventory; import common.inventory.IInventory;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
@ -19,7 +19,7 @@ public class GuiHopper extends GuiContainer
public GuiHopper(InventoryPlayer playerInv, IInventory hopperInv) public GuiHopper(InventoryPlayer playerInv, IInventory hopperInv)
{ {
super(new ContainerHopper(playerInv, hopperInv, Game.getGame().thePlayer)); super(new ContainerHopper(playerInv, hopperInv, Client.CLIENT.player));
this.playerInventory = playerInv; this.playerInventory = playerInv;
this.hopperInventory = hopperInv; this.hopperInventory = hopperInv;
// this.allowUserInput = false; // this.allowUserInput = false;

View file

@ -81,9 +81,9 @@ public class GuiMerchant extends GuiContainer
if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) { if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) {
int k = this.selectedMerchantRecipe; int k = this.selectedMerchantRecipe;
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k); MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
ItemStack itemstack = merchantrecipe.getItemToBuy(); ItemStack itemstack = merchantrecipe.first();
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy(); ItemStack itemstack1 = merchantrecipe.second();
ItemStack itemstack2 = merchantrecipe.getItemToSell(); ItemStack itemstack2 = merchantrecipe.result();
this.renderItemOverlayIntoGUI(itemstack, 36, 24, null); this.renderItemOverlayIntoGUI(itemstack, 36, 24, null);
if(itemstack1 != null) if(itemstack1 != null)
this.renderItemOverlayIntoGUI(itemstack1, 62, 24, null); this.renderItemOverlayIntoGUI(itemstack1, 62, 24, null);
@ -180,9 +180,9 @@ public class GuiMerchant extends GuiContainer
// int j = (this.height - this.ySize) / 2; // int j = (this.height - this.ySize) / 2;
int k = this.selectedMerchantRecipe; int k = this.selectedMerchantRecipe;
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k); MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
ItemStack itemstack = merchantrecipe.getItemToBuy(); ItemStack itemstack = merchantrecipe.first();
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy(); ItemStack itemstack1 = merchantrecipe.second();
ItemStack itemstack2 = merchantrecipe.getItemToSell(); ItemStack itemstack2 = merchantrecipe.result();
GL11.glPushMatrix(); GL11.glPushMatrix();
ItemRenderer.enableGUIStandardItemLighting(); ItemRenderer.enableGUIStandardItemLighting();
GlState.disableLighting(); GlState.disableLighting();

View file

@ -2,7 +2,7 @@ package client.gui.container;
import java.util.List; import java.util.List;
import client.Game; import client.Client;
import common.inventory.Container; import common.inventory.Container;
import common.inventory.ContainerRepair; import common.inventory.ContainerRepair;
import common.inventory.ICrafting; import common.inventory.ICrafting;
@ -21,7 +21,7 @@ public class GuiRepair extends GuiContainer implements ICrafting
public GuiRepair(InventoryPlayer inventoryIn, World worldIn) public GuiRepair(InventoryPlayer inventoryIn, World worldIn)
{ {
super(new ContainerRepair(inventoryIn, worldIn, Game.getGame().thePlayer)); super(new ContainerRepair(inventoryIn, worldIn, Client.CLIENT.player));
this.playerInventory = inventoryIn; this.playerInventory = inventoryIn;
this.anvil = (ContainerRepair)this.inventorySlots; this.anvil = (ContainerRepair)this.inventorySlots;
} }
@ -68,7 +68,7 @@ public class GuiRepair extends GuiContainer implements ICrafting
{ {
int i = 8453920; int i = 8453920;
boolean flag = true; boolean flag = true;
String s = String.format("Erfahrungskosten: %d", this.anvil.maximumCost); String s = String.format("Manakosten: %d", this.anvil.maximumCost);
if (this.anvil.maximumCost >= 40) // && !this.gm.thePlayer.creative) if (this.anvil.maximumCost >= 40) // && !this.gm.thePlayer.creative)
{ {

View file

@ -0,0 +1,32 @@
package client.gui.container;
import client.Client;
import common.inventory.ContainerTile;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.tileentity.TileEntityDevice;
public class GuiTile extends GuiContainer
{
private final IInventory playerInv;
private final IInventory tileInv;
private final TileEntityDevice tile;
public GuiTile(InventoryPlayer player, IInventory inv, TileEntityDevice tile)
{
super(new ContainerTile(player, tile, inv, Client.CLIENT.player));
this.playerInv = player;
this.tileInv = tile;
this.ySize = 153;
this.tile = tile;
}
public void drawGuiContainerForegroundLayer()
{
this.drawString(this.tile.getStatus().color + this.tileInv.getCommandName() + " - " + this.tile.getStatus().name, 8, 6);
this.drawString(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.drawString(String.format("Temperatur: %d °", this.tile.getTemperature()), 8, 18);
this.drawString(this.tile.formatDisplay((ContainerTile)this.inventorySlots), 8, 28);
}
}

Some files were not shown because too many files have changed in this diff Show more