diff --git a/assets/tinker/textures/blocks/glass/clear/glass.png b/assets/tinker/textures/blocks/glass/clear/glass.png new file mode 100644 index 00000000..d19a2acb Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_1_d.png b/assets/tinker/textures/blocks/glass/clear/glass_1_d.png new file mode 100644 index 00000000..5dec6de4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_1_l.png b/assets/tinker/textures/blocks/glass/clear/glass_1_l.png new file mode 100644 index 00000000..077aa122 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_1_r.png b/assets/tinker/textures/blocks/glass/clear/glass_1_r.png new file mode 100644 index 00000000..0e856116 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_1_u.png b/assets/tinker/textures/blocks/glass/clear/glass_1_u.png new file mode 100644 index 00000000..5dd6bc0d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_2_dl.png b/assets/tinker/textures/blocks/glass/clear/glass_2_dl.png new file mode 100644 index 00000000..c3dc8478 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_2_dr.png b/assets/tinker/textures/blocks/glass/clear/glass_2_dr.png new file mode 100644 index 00000000..bd95cc03 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_2_h.png b/assets/tinker/textures/blocks/glass/clear/glass_2_h.png new file mode 100644 index 00000000..3f96317e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_2_ul.png b/assets/tinker/textures/blocks/glass/clear/glass_2_ul.png new file mode 100644 index 00000000..0fc8b250 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_2_ur.png b/assets/tinker/textures/blocks/glass/clear/glass_2_ur.png new file mode 100644 index 00000000..78f01305 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_2_v.png b/assets/tinker/textures/blocks/glass/clear/glass_2_v.png new file mode 100644 index 00000000..32b79772 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_3_d.png b/assets/tinker/textures/blocks/glass/clear/glass_3_d.png new file mode 100644 index 00000000..437408a1 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_3_l.png b/assets/tinker/textures/blocks/glass/clear/glass_3_l.png new file mode 100644 index 00000000..2751be8f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_3_r.png b/assets/tinker/textures/blocks/glass/clear/glass_3_r.png new file mode 100644 index 00000000..bf343351 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_3_u.png b/assets/tinker/textures/blocks/glass/clear/glass_3_u.png new file mode 100644 index 00000000..c572ca6a Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/clear/glass_4.png b/assets/tinker/textures/blocks/glass/clear/glass_4.png new file mode 100644 index 00000000..86e8064b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/clear/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass.png b/assets/tinker/textures/blocks/glass/soul_clear/glass.png new file mode 100644 index 00000000..4aa7b3ff Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_1_d.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_1_d.png new file mode 100644 index 00000000..53e237d9 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_1_l.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_1_l.png new file mode 100644 index 00000000..1d23b871 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_1_r.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_1_r.png new file mode 100644 index 00000000..e5458cec Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_1_u.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_1_u.png new file mode 100644 index 00000000..6f8f67bb Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_2_dl.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_dl.png new file mode 100644 index 00000000..6e146e00 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_2_dr.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_dr.png new file mode 100644 index 00000000..127db342 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_2_h.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_h.png new file mode 100644 index 00000000..ad2aefc0 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_2_ul.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_ul.png new file mode 100644 index 00000000..86d0d593 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_2_ur.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_ur.png new file mode 100644 index 00000000..f62cc1ae Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_2_v.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_v.png new file mode 100644 index 00000000..f294245d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_3_d.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_3_d.png new file mode 100644 index 00000000..425d2513 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_3_l.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_3_l.png new file mode 100644 index 00000000..9c97772b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_3_r.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_3_r.png new file mode 100644 index 00000000..42b4b712 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_3_u.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_3_u.png new file mode 100644 index 00000000..8fa09e9d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/soul_clear/glass_4.png b/assets/tinker/textures/blocks/glass/soul_clear/glass_4.png new file mode 100644 index 00000000..86e8064b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/soul_clear/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass.png b/assets/tinker/textures/blocks/glass/stained/black/glass.png new file mode 100644 index 00000000..2bfc485e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/black/glass_1_d.png new file mode 100644 index 00000000..51834b3c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/black/glass_1_l.png new file mode 100644 index 00000000..e0cc25d5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/black/glass_1_r.png new file mode 100644 index 00000000..7096acb9 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/black/glass_1_u.png new file mode 100644 index 00000000..02271f06 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/black/glass_2_dl.png new file mode 100644 index 00000000..f6145d8d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/black/glass_2_dr.png new file mode 100644 index 00000000..af7a5a7f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/black/glass_2_h.png new file mode 100644 index 00000000..8e845802 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/black/glass_2_ul.png new file mode 100644 index 00000000..5e157dfd Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/black/glass_2_ur.png new file mode 100644 index 00000000..912e1923 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/black/glass_2_v.png new file mode 100644 index 00000000..174fdf7a Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/black/glass_3_d.png new file mode 100644 index 00000000..554e613f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/black/glass_3_l.png new file mode 100644 index 00000000..11209f5e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/black/glass_3_r.png new file mode 100644 index 00000000..454035fb Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/black/glass_3_u.png new file mode 100644 index 00000000..afa59e37 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/black/glass_4.png b/assets/tinker/textures/blocks/glass/stained/black/glass_4.png new file mode 100644 index 00000000..4aca4a22 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/black/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass.png b/assets/tinker/textures/blocks/glass/stained/blue/glass.png new file mode 100644 index 00000000..9116a36d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_1_d.png new file mode 100644 index 00000000..4dba927e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_1_l.png new file mode 100644 index 00000000..13c04872 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_1_r.png new file mode 100644 index 00000000..0628bb63 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_1_u.png new file mode 100644 index 00000000..7c557864 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_dl.png new file mode 100644 index 00000000..9ea68093 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_dr.png new file mode 100644 index 00000000..896a452f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_h.png new file mode 100644 index 00000000..62f48ca4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_ul.png new file mode 100644 index 00000000..514d0ec7 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_ur.png new file mode 100644 index 00000000..a1b9e7ee Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_v.png new file mode 100644 index 00000000..d28b2b35 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_3_d.png new file mode 100644 index 00000000..6f09e6a3 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_3_l.png new file mode 100644 index 00000000..24b885a2 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_3_r.png new file mode 100644 index 00000000..80a70bd4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_3_u.png new file mode 100644 index 00000000..1ca72fc6 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/blue/glass_4.png b/assets/tinker/textures/blocks/glass/stained/blue/glass_4.png new file mode 100644 index 00000000..cd8fb9d5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/blue/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass.png b/assets/tinker/textures/blocks/glass/stained/brown/glass.png new file mode 100644 index 00000000..66bb5d3b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_1_d.png new file mode 100644 index 00000000..932fc322 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_1_l.png new file mode 100644 index 00000000..4626b76e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_1_r.png new file mode 100644 index 00000000..e8be00eb Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_1_u.png new file mode 100644 index 00000000..7f91e053 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_dl.png new file mode 100644 index 00000000..4b8044ee Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_dr.png new file mode 100644 index 00000000..7019bc31 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_h.png new file mode 100644 index 00000000..be5cd766 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_ul.png new file mode 100644 index 00000000..c4dfea9b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_ur.png new file mode 100644 index 00000000..4e0931c4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_v.png new file mode 100644 index 00000000..f4be2e2b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_3_d.png new file mode 100644 index 00000000..0d276995 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_3_l.png new file mode 100644 index 00000000..1e24a332 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_3_r.png new file mode 100644 index 00000000..5aad18d8 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_3_u.png new file mode 100644 index 00000000..20a11a1c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/brown/glass_4.png b/assets/tinker/textures/blocks/glass/stained/brown/glass_4.png new file mode 100644 index 00000000..b3d317a7 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/brown/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass.png new file mode 100644 index 00000000..924fb8a8 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_d.png new file mode 100644 index 00000000..282802a6 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_l.png new file mode 100644 index 00000000..fb3fb87b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_r.png new file mode 100644 index 00000000..58899d7d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_u.png new file mode 100644 index 00000000..c045559d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_dl.png new file mode 100644 index 00000000..13993b9f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_dr.png new file mode 100644 index 00000000..b1007c99 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_h.png new file mode 100644 index 00000000..6c1e76af Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_ul.png new file mode 100644 index 00000000..82332e62 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_ur.png new file mode 100644 index 00000000..43b0c9d6 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_v.png new file mode 100644 index 00000000..ae05e56f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_d.png new file mode 100644 index 00000000..25e7cea9 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_l.png new file mode 100644 index 00000000..252dcb36 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_r.png new file mode 100644 index 00000000..d338c0ee Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_u.png new file mode 100644 index 00000000..dbd57896 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/cyan/glass_4.png b/assets/tinker/textures/blocks/glass/stained/cyan/glass_4.png new file mode 100644 index 00000000..a2160882 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/cyan/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass.png b/assets/tinker/textures/blocks/glass/stained/gray/glass.png new file mode 100644 index 00000000..828eca1c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_1_d.png new file mode 100644 index 00000000..a36221ff Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_1_l.png new file mode 100644 index 00000000..4caaddb7 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_1_r.png new file mode 100644 index 00000000..2a2282bb Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_1_u.png new file mode 100644 index 00000000..86b96fe9 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_dl.png new file mode 100644 index 00000000..207033d3 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_dr.png new file mode 100644 index 00000000..d892f344 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_h.png new file mode 100644 index 00000000..39843475 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_ul.png new file mode 100644 index 00000000..c4f1d338 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_ur.png new file mode 100644 index 00000000..115488cd Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_v.png new file mode 100644 index 00000000..e8c4a23c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_3_d.png new file mode 100644 index 00000000..d0e11e09 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_3_l.png new file mode 100644 index 00000000..79d4e8ad Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_3_r.png new file mode 100644 index 00000000..5915a6dd Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_3_u.png new file mode 100644 index 00000000..08d24efc Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/gray/glass_4.png b/assets/tinker/textures/blocks/glass/stained/gray/glass_4.png new file mode 100644 index 00000000..0c6d06d4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/gray/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass.png b/assets/tinker/textures/blocks/glass/stained/green/glass.png new file mode 100644 index 00000000..9cc66071 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/green/glass_1_d.png new file mode 100644 index 00000000..88e32fc2 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/green/glass_1_l.png new file mode 100644 index 00000000..91cba7e6 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/green/glass_1_r.png new file mode 100644 index 00000000..ff06b16e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/green/glass_1_u.png new file mode 100644 index 00000000..5b6d880c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/green/glass_2_dl.png new file mode 100644 index 00000000..ce1553b6 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/green/glass_2_dr.png new file mode 100644 index 00000000..54ed8569 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/green/glass_2_h.png new file mode 100644 index 00000000..5363339f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/green/glass_2_ul.png new file mode 100644 index 00000000..3fde71a5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/green/glass_2_ur.png new file mode 100644 index 00000000..f4076072 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/green/glass_2_v.png new file mode 100644 index 00000000..efb419b9 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/green/glass_3_d.png new file mode 100644 index 00000000..08a1815f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/green/glass_3_l.png new file mode 100644 index 00000000..0ad4f56c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/green/glass_3_r.png new file mode 100644 index 00000000..77e8d091 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/green/glass_3_u.png new file mode 100644 index 00000000..dcb63c93 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/green/glass_4.png b/assets/tinker/textures/blocks/glass/stained/green/glass_4.png new file mode 100644 index 00000000..82a6dfe2 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/green/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass.png new file mode 100644 index 00000000..ab875d1b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_d.png new file mode 100644 index 00000000..226c6a6d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_l.png new file mode 100644 index 00000000..7b675271 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_r.png new file mode 100644 index 00000000..6feb91ff Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_u.png new file mode 100644 index 00000000..314da07c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_dl.png new file mode 100644 index 00000000..aa8d3028 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_dr.png new file mode 100644 index 00000000..38f450f2 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_h.png new file mode 100644 index 00000000..6a172b42 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_ul.png new file mode 100644 index 00000000..6c2057a5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_ur.png new file mode 100644 index 00000000..825ea57b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_v.png new file mode 100644 index 00000000..658dc221 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_d.png new file mode 100644 index 00000000..eafb911c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_l.png new file mode 100644 index 00000000..18c9c64b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_r.png new file mode 100644 index 00000000..eac910d5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_u.png new file mode 100644 index 00000000..1dc3f036 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_blue/glass_4.png b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_4.png new file mode 100644 index 00000000..36d7f920 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_blue/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass.png new file mode 100644 index 00000000..ac95a47f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_d.png new file mode 100644 index 00000000..75e66bd5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_l.png new file mode 100644 index 00000000..3af84acb Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_r.png new file mode 100644 index 00000000..4ed4a4c4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_u.png new file mode 100644 index 00000000..233b4234 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_dl.png new file mode 100644 index 00000000..073de069 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_dr.png new file mode 100644 index 00000000..94ba0982 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_h.png new file mode 100644 index 00000000..59158cf3 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_ul.png new file mode 100644 index 00000000..2a723dff Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_ur.png new file mode 100644 index 00000000..d37b4e89 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_v.png new file mode 100644 index 00000000..0a677c9e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_d.png new file mode 100644 index 00000000..b744df82 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_l.png new file mode 100644 index 00000000..83e0b777 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_r.png new file mode 100644 index 00000000..d2515255 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_u.png new file mode 100644 index 00000000..988dade5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/light_gray/glass_4.png b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_4.png new file mode 100644 index 00000000..6101f150 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/light_gray/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass.png b/assets/tinker/textures/blocks/glass/stained/lime/glass.png new file mode 100644 index 00000000..a32346e4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_1_d.png new file mode 100644 index 00000000..683c3d15 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_1_l.png new file mode 100644 index 00000000..2f39604f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_1_r.png new file mode 100644 index 00000000..70cbc11a Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_1_u.png new file mode 100644 index 00000000..19beca01 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_dl.png new file mode 100644 index 00000000..f66d25f0 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_dr.png new file mode 100644 index 00000000..bea5fc2c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_h.png new file mode 100644 index 00000000..a884d4c4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_ul.png new file mode 100644 index 00000000..42f8acb8 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_ur.png new file mode 100644 index 00000000..d1897364 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_v.png new file mode 100644 index 00000000..65c77fb4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_3_d.png new file mode 100644 index 00000000..6324c6fd Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_3_l.png new file mode 100644 index 00000000..e07a768a Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_3_r.png new file mode 100644 index 00000000..e4bf8054 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_3_u.png new file mode 100644 index 00000000..c501379d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/lime/glass_4.png b/assets/tinker/textures/blocks/glass/stained/lime/glass_4.png new file mode 100644 index 00000000..376ed8bf Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/lime/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass.png new file mode 100644 index 00000000..1e57694c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_d.png new file mode 100644 index 00000000..cf9da475 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_l.png new file mode 100644 index 00000000..388856f5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_r.png new file mode 100644 index 00000000..a81b9a3a Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_u.png new file mode 100644 index 00000000..ac79d7f5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_dl.png new file mode 100644 index 00000000..0fcb2fe6 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_dr.png new file mode 100644 index 00000000..569ddf67 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_h.png new file mode 100644 index 00000000..91e3c762 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_ul.png new file mode 100644 index 00000000..e5aa04ca Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_ur.png new file mode 100644 index 00000000..7f46973d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_v.png new file mode 100644 index 00000000..50501f89 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_d.png new file mode 100644 index 00000000..7998cd28 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_l.png new file mode 100644 index 00000000..1dfbf63b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_r.png new file mode 100644 index 00000000..341e64a1 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_u.png new file mode 100644 index 00000000..e9e4126d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/magenta/glass_4.png b/assets/tinker/textures/blocks/glass/stained/magenta/glass_4.png new file mode 100644 index 00000000..33786330 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/magenta/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass.png b/assets/tinker/textures/blocks/glass/stained/orange/glass.png new file mode 100644 index 00000000..97b30ea1 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_1_d.png new file mode 100644 index 00000000..78a96d3d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_1_l.png new file mode 100644 index 00000000..2813e261 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_1_r.png new file mode 100644 index 00000000..eca01a4a Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_1_u.png new file mode 100644 index 00000000..5a492582 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_dl.png new file mode 100644 index 00000000..86b18951 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_dr.png new file mode 100644 index 00000000..6cc80f3d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_h.png new file mode 100644 index 00000000..3dfca38b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_ul.png new file mode 100644 index 00000000..96e80a03 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_ur.png new file mode 100644 index 00000000..4b0c91da Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_v.png new file mode 100644 index 00000000..b96c8650 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_3_d.png new file mode 100644 index 00000000..38f52c12 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_3_l.png new file mode 100644 index 00000000..7b1f3016 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_3_r.png new file mode 100644 index 00000000..ab336a40 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_3_u.png new file mode 100644 index 00000000..d4742720 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/orange/glass_4.png b/assets/tinker/textures/blocks/glass/stained/orange/glass_4.png new file mode 100644 index 00000000..7b7cc745 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/orange/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass.png b/assets/tinker/textures/blocks/glass/stained/pink/glass.png new file mode 100644 index 00000000..ca12296d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_1_d.png new file mode 100644 index 00000000..07d1d87b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_1_l.png new file mode 100644 index 00000000..f0c21536 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_1_r.png new file mode 100644 index 00000000..72684b76 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_1_u.png new file mode 100644 index 00000000..b5bcbfb1 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_dl.png new file mode 100644 index 00000000..0d3fedeb Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_dr.png new file mode 100644 index 00000000..6797f9ed Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_h.png new file mode 100644 index 00000000..193b0343 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_ul.png new file mode 100644 index 00000000..af0ccc20 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_ur.png new file mode 100644 index 00000000..c84979f8 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_v.png new file mode 100644 index 00000000..39883a8e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_3_d.png new file mode 100644 index 00000000..13e67cb8 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_3_l.png new file mode 100644 index 00000000..78afde4a Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_3_r.png new file mode 100644 index 00000000..0afe67e9 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_3_u.png new file mode 100644 index 00000000..6926906f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/pink/glass_4.png b/assets/tinker/textures/blocks/glass/stained/pink/glass_4.png new file mode 100644 index 00000000..2fc8f490 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/pink/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass.png b/assets/tinker/textures/blocks/glass/stained/purple/glass.png new file mode 100644 index 00000000..a923aac6 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_1_d.png new file mode 100644 index 00000000..f213d516 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_1_l.png new file mode 100644 index 00000000..05354b89 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_1_r.png new file mode 100644 index 00000000..3f5cbc4b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_1_u.png new file mode 100644 index 00000000..a674b38f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_dl.png new file mode 100644 index 00000000..162f6bfe Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_dr.png new file mode 100644 index 00000000..e6a1b214 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_h.png new file mode 100644 index 00000000..6b1a9b9a Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_ul.png new file mode 100644 index 00000000..0f986ff2 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_ur.png new file mode 100644 index 00000000..a661ec2d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_v.png new file mode 100644 index 00000000..be341cc7 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_3_d.png new file mode 100644 index 00000000..046b71d5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_3_l.png new file mode 100644 index 00000000..ff21907f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_3_r.png new file mode 100644 index 00000000..1442b5f9 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_3_u.png new file mode 100644 index 00000000..bfa706fd Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/purple/glass_4.png b/assets/tinker/textures/blocks/glass/stained/purple/glass_4.png new file mode 100644 index 00000000..8a62e941 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/purple/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass.png b/assets/tinker/textures/blocks/glass/stained/red/glass.png new file mode 100644 index 00000000..cb2306e1 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/red/glass_1_d.png new file mode 100644 index 00000000..e316697f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/red/glass_1_l.png new file mode 100644 index 00000000..d3a820eb Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/red/glass_1_r.png new file mode 100644 index 00000000..c009e733 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/red/glass_1_u.png new file mode 100644 index 00000000..7dafbdf8 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/red/glass_2_dl.png new file mode 100644 index 00000000..af15d5d0 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/red/glass_2_dr.png new file mode 100644 index 00000000..7c5e70e5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/red/glass_2_h.png new file mode 100644 index 00000000..8fc79b9f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/red/glass_2_ul.png new file mode 100644 index 00000000..da9f4f86 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/red/glass_2_ur.png new file mode 100644 index 00000000..82ed0ce4 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/red/glass_2_v.png new file mode 100644 index 00000000..57e5a19e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/red/glass_3_d.png new file mode 100644 index 00000000..48e4f542 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/red/glass_3_l.png new file mode 100644 index 00000000..a987dec0 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/red/glass_3_r.png new file mode 100644 index 00000000..2d9acc6b Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/red/glass_3_u.png new file mode 100644 index 00000000..8b4591bd Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/red/glass_4.png b/assets/tinker/textures/blocks/glass/stained/red/glass_4.png new file mode 100644 index 00000000..db57cf67 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/red/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass.png b/assets/tinker/textures/blocks/glass/stained/white/glass.png new file mode 100644 index 00000000..2ef7a496 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/white/glass_1_d.png new file mode 100644 index 00000000..59ec9b57 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/white/glass_1_l.png new file mode 100644 index 00000000..c1fcd38d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/white/glass_1_r.png new file mode 100644 index 00000000..bd98c8cd Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/white/glass_1_u.png new file mode 100644 index 00000000..f40cecdb Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/white/glass_2_dl.png new file mode 100644 index 00000000..3c1c4be3 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/white/glass_2_dr.png new file mode 100644 index 00000000..59115f0f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/white/glass_2_h.png new file mode 100644 index 00000000..d6f9f7fc Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/white/glass_2_ul.png new file mode 100644 index 00000000..57811583 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/white/glass_2_ur.png new file mode 100644 index 00000000..6fc7f67f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/white/glass_2_v.png new file mode 100644 index 00000000..4e3fa4f6 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/white/glass_3_d.png new file mode 100644 index 00000000..31913a33 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/white/glass_3_l.png new file mode 100644 index 00000000..dcf80234 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/white/glass_3_r.png new file mode 100644 index 00000000..2473ad90 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/white/glass_3_u.png new file mode 100644 index 00000000..fa8857c5 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/white/glass_4.png b/assets/tinker/textures/blocks/glass/stained/white/glass_4.png new file mode 100644 index 00000000..ca6bc049 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/white/glass_4.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass.png new file mode 100644 index 00000000..a0b7440c Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_d.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_d.png new file mode 100644 index 00000000..3970a59e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_l.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_l.png new file mode 100644 index 00000000..e7b0d4a9 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_r.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_r.png new file mode 100644 index 00000000..11ea672e Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_u.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_u.png new file mode 100644 index 00000000..9bb46774 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_1_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_dl.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_dl.png new file mode 100644 index 00000000..2f857534 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_dl.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_dr.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_dr.png new file mode 100644 index 00000000..01cef7aa Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_dr.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_h.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_h.png new file mode 100644 index 00000000..8142ab63 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_h.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_ul.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_ul.png new file mode 100644 index 00000000..1e813a4f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_ul.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_ur.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_ur.png new file mode 100644 index 00000000..442bec07 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_ur.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_v.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_v.png new file mode 100644 index 00000000..9b68873a Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_2_v.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_d.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_d.png new file mode 100644 index 00000000..baf01ecf Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_d.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_l.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_l.png new file mode 100644 index 00000000..cb911b96 Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_l.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_r.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_r.png new file mode 100644 index 00000000..da3d734f Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_r.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_u.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_u.png new file mode 100644 index 00000000..5cd5235d Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_3_u.png differ diff --git a/assets/tinker/textures/blocks/glass/stained/yellow/glass_4.png b/assets/tinker/textures/blocks/glass/stained/yellow/glass_4.png new file mode 100644 index 00000000..72b4afef Binary files /dev/null and b/assets/tinker/textures/blocks/glass/stained/yellow/glass_4.png differ diff --git a/assets/tinker/textures/blocks/liquid_alubrass.png.mcmeta b/assets/tinker/textures/blocks/liquid_alubrass.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_alubrass.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_alubrass_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_alubrass_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_alubrass_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_aluminum.png.mcmeta b/assets/tinker/textures/blocks/liquid_aluminum.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_aluminum.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_aluminum_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_aluminum_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_aluminum_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_alumite.png.mcmeta b/assets/tinker/textures/blocks/liquid_alumite.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_alumite.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_alumite_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_alumite_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_alumite_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_ardite.png.mcmeta b/assets/tinker/textures/blocks/liquid_ardite.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_ardite.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_ardite_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_ardite_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_ardite_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_bronze.png.mcmeta b/assets/tinker/textures/blocks/liquid_bronze.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_bronze.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_bronze_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_bronze_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_bronze_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_cobalt.png.mcmeta b/assets/tinker/textures/blocks/liquid_cobalt.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_cobalt.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_cobalt_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_cobalt_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_cobalt_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_copper.png.mcmeta b/assets/tinker/textures/blocks/liquid_copper.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_copper.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_copper_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_copper_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_copper_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_cow.png.mcmeta b/assets/tinker/textures/blocks/liquid_cow.png.mcmeta new file mode 100644 index 00000000..4f0718ac --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_cow.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_cow_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_cow_flow.png.mcmeta new file mode 100644 index 00000000..0645f48c --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_cow_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} diff --git a/assets/tinker/textures/blocks/liquid_electrum.png b/assets/tinker/textures/blocks/liquid_electrum.png new file mode 100644 index 00000000..817345f6 Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_electrum.png differ diff --git a/assets/tinker/textures/blocks/liquid_electrum.png.mcmeta b/assets/tinker/textures/blocks/liquid_electrum.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_electrum.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_electrum_flow.mcmeta b/assets/tinker/textures/blocks/liquid_electrum_flow.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_electrum_flow.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_electrum_flow.png b/assets/tinker/textures/blocks/liquid_electrum_flow.png new file mode 100644 index 00000000..aa63b513 Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_electrum_flow.png differ diff --git a/assets/tinker/textures/blocks/liquid_ferrous.png b/assets/tinker/textures/blocks/liquid_ferrous.png new file mode 100644 index 00000000..7d917ffd Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_ferrous.png differ diff --git a/assets/tinker/textures/blocks/liquid_ferrous.png.mcmeta b/assets/tinker/textures/blocks/liquid_ferrous.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_ferrous.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_ferrous_flow.png b/assets/tinker/textures/blocks/liquid_ferrous_flow.png new file mode 100644 index 00000000..1f641b56 Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_ferrous_flow.png differ diff --git a/assets/tinker/textures/blocks/liquid_ferrous_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_ferrous_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_ferrous_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_glass.png.mcmeta b/assets/tinker/textures/blocks/liquid_glass.png.mcmeta new file mode 100644 index 00000000..4f0718ac --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_glass.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_glass_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_glass_flow.png.mcmeta new file mode 100644 index 00000000..0645f48c --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_glass_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} diff --git a/assets/tinker/textures/blocks/liquid_gold.png.mcmeta b/assets/tinker/textures/blocks/liquid_gold.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_gold.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_gold_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_gold_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_gold_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_invar.png b/assets/tinker/textures/blocks/liquid_invar.png new file mode 100644 index 00000000..2984f30e Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_invar.png differ diff --git a/assets/tinker/textures/blocks/liquid_invar.png.mcmeta b/assets/tinker/textures/blocks/liquid_invar.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_invar.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_invar_flow.png b/assets/tinker/textures/blocks/liquid_invar_flow.png new file mode 100644 index 00000000..68321fab Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_invar_flow.png differ diff --git a/assets/tinker/textures/blocks/liquid_invar_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_invar_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_invar_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_iron.png.mcmeta b/assets/tinker/textures/blocks/liquid_iron.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_iron.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_iron_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_iron_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_iron_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_lead.png b/assets/tinker/textures/blocks/liquid_lead.png new file mode 100644 index 00000000..448d1757 Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_lead.png differ diff --git a/assets/tinker/textures/blocks/liquid_lead.png.mcmeta b/assets/tinker/textures/blocks/liquid_lead.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_lead.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_lead_flow.png b/assets/tinker/textures/blocks/liquid_lead_flow.png new file mode 100644 index 00000000..7ec2852e Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_lead_flow.png differ diff --git a/assets/tinker/textures/blocks/liquid_lead_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_lead_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_lead_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_manyullyn.png.mcmeta b/assets/tinker/textures/blocks/liquid_manyullyn.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_manyullyn.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_manyullyn_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_manyullyn_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_manyullyn_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_obsidian.png.mcmeta b/assets/tinker/textures/blocks/liquid_obsidian.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_obsidian.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_obsidian_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_obsidian_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_obsidian_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_shiny.png b/assets/tinker/textures/blocks/liquid_shiny.png new file mode 100644 index 00000000..9c1ab339 Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_shiny.png differ diff --git a/assets/tinker/textures/blocks/liquid_shiny.png.mcmeta b/assets/tinker/textures/blocks/liquid_shiny.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_shiny.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_shiny_flow.png b/assets/tinker/textures/blocks/liquid_shiny_flow.png new file mode 100644 index 00000000..4b564dae Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_shiny_flow.png differ diff --git a/assets/tinker/textures/blocks/liquid_shiny_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_shiny_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_shiny_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_silver.png b/assets/tinker/textures/blocks/liquid_silver.png new file mode 100644 index 00000000..f669a50a Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_silver.png differ diff --git a/assets/tinker/textures/blocks/liquid_silver.png.mcmeta b/assets/tinker/textures/blocks/liquid_silver.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_silver.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_silver_flow.png b/assets/tinker/textures/blocks/liquid_silver_flow.png new file mode 100644 index 00000000..7ac66ba5 Binary files /dev/null and b/assets/tinker/textures/blocks/liquid_silver_flow.png differ diff --git a/assets/tinker/textures/blocks/liquid_silver_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_silver_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_silver_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_steel.png.mcmeta b/assets/tinker/textures/blocks/liquid_steel.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_steel.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_steel_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_steel_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_steel_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_stone.png.mcmeta b/assets/tinker/textures/blocks/liquid_stone.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_stone.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_stone_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_stone_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_stone_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_tin.png.mcmeta b/assets/tinker/textures/blocks/liquid_tin.png.mcmeta new file mode 100644 index 00000000..7ceb3639 --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_tin.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_tin_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_tin_flow.png.mcmeta new file mode 100644 index 00000000..8e55e43b --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_tin_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/assets/tinker/textures/blocks/liquid_villager.png b/assets/tinker/textures/blocks/liquid_villager.png index ad8f7d8a..a9d1b9bf 100644 Binary files a/assets/tinker/textures/blocks/liquid_villager.png and b/assets/tinker/textures/blocks/liquid_villager.png differ diff --git a/assets/tinker/textures/blocks/liquid_villager.png.mcmeta b/assets/tinker/textures/blocks/liquid_villager.png.mcmeta new file mode 100644 index 00000000..4f0718ac --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_villager.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/assets/tinker/textures/blocks/liquid_villager_flow.png b/assets/tinker/textures/blocks/liquid_villager_flow.png index fbc59103..01752191 100644 Binary files a/assets/tinker/textures/blocks/liquid_villager_flow.png and b/assets/tinker/textures/blocks/liquid_villager_flow.png differ diff --git a/assets/tinker/textures/blocks/liquid_villager_flow.png.mcmeta b/assets/tinker/textures/blocks/liquid_villager_flow.png.mcmeta new file mode 100644 index 00000000..0645f48c --- /dev/null +++ b/assets/tinker/textures/blocks/liquid_villager_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} diff --git a/tconstruct/TConstruct.java b/tconstruct/TConstruct.java new file mode 100644 index 00000000..e1d14638 --- /dev/null +++ b/tconstruct/TConstruct.java @@ -0,0 +1,155 @@ +package tconstruct; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.MinecraftForge; +import tconstruct.common.TContent; +import tconstruct.common.TProxyCommon; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.Detailing; +import tconstruct.library.crafting.LiquidCasting; +import tconstruct.library.util.TabTools; +import tconstruct.skill.SkillRegistry; +import tconstruct.util.PHConstruct; +import tconstruct.util.TCraftingHandler; +import tconstruct.util.TEventHandler; +import tconstruct.util.player.TPlayerHandler; +import tconstruct.worldgen.TBaseWorldGenerator; +import tconstruct.worldgen.TerrainGenEventHandler; +import tconstruct.worldgen.village.TVillageTrades; +import tconstruct.worldgen.village.VillageSmelteryHandler; +import tconstruct.worldgen.village.VillageToolStationHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Init; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.Mod.PostInit; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.VillagerRegistry; + +/** TConstruct, the tool mod. + * Craft your tools with style, then modify until the original is gone! + * @author: mDiyo + * @dependencies: IC2 API, MFR API + */ + +@Mod(modid = "TConstruct", name = "TConstruct", version = "1.6.2_1.4.3", dependencies = "required-after:Forge@[7.7.1.687,)") +@NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = tconstruct.util.network.TPacketHandler.class) +public class TConstruct +{ + /** The value of one ingot in millibuckets */ + public static final int ingotLiquidValue = 144; + public static final int liquidUpdateAmount = 6; + + /* Instance of this mod, used for grabbing prototype fields */ + @Instance("TConstruct") + public static TConstruct instance; + /* Proxies for sides, used for graphics processing */ + @SidedProxy(clientSide = "tconstruct.client.TProxyClient", serverSide = "tconstruct.common.TProxyCommon") + public static TProxyCommon proxy; + + public TConstruct() + { + if (Loader.isModLoaded("Natura")) + { + System.out.println("[TConstruct] Natura, what are we going to do tomorrow night?"); + System.out.println("[Natura] TConstruct, we're going to take over the world!"); + /*System.out.println("[TConstruct] They're Pinky, they're Pinky and"); + System.out.println("[Natura] the Brain Brain Brain Brain Brain~");*/ + } + else + { + System.out.println("[TConstruct] Preparing to take over the world"); + } + } + + @EventHandler + public void preInit (FMLPreInitializationEvent event) + { + PHConstruct.initProps(event.getModConfigurationDirectory()); + TConstructRegistry.materialTab = new TabTools("TConstructMaterials"); + TConstructRegistry.toolTab = new TabTools("TConstructTools"); + TConstructRegistry.blockTab = new TabTools("TConstructBlocks"); + + tableCasting = new LiquidCasting(); + basinCasting = new LiquidCasting(); + chiselDetailing = new Detailing(); + + content = new TContent(); + + events = new TEventHandler(); + events.unfuxOreDictionary(); + MinecraftForge.EVENT_BUS.register(events); + content.oreRegistry(); + + proxy.registerRenderer(); + proxy.registerTickHandler(); + proxy.addNames(); + proxy.readManuals(); + proxy.registerKeys(); + + GameRegistry.registerWorldGenerator(new TBaseWorldGenerator()); + MinecraftForge.TERRAIN_GEN_BUS.register(new TerrainGenEventHandler()); + GameRegistry.registerFuelHandler(content); + GameRegistry.registerCraftingHandler(new TCraftingHandler()); + NetworkRegistry.instance().registerGuiHandler(instance, proxy); + + VillagerRegistry.instance().registerVillagerSkin(78943, new ResourceLocation("/mods/tinker/textures/mob/villagertools.png")); + VillagerRegistry.instance().registerVillageTradeHandler(78943, new TVillageTrades()); + if (PHConstruct.addToVillages) + { + VillagerRegistry.instance().registerVillageCreationHandler(new VillageToolStationHandler()); + VillagerRegistry.instance().registerVillageCreationHandler(new VillageSmelteryHandler()); + } + + /*DimensionManager.registerProviderType(-7, TinkerWorldProvider.class, true); + DimensionManager.registerDimension(-7, -7);*/ + playerTracker = new TPlayerHandler(); + GameRegistry.registerPlayerTracker(playerTracker); + MinecraftForge.EVENT_BUS.register(playerTracker); + } + + @EventHandler + public void init (FMLInitializationEvent event) + { + content.intermodCommunication(); + } + + @EventHandler + public void postInit (FMLPostInitializationEvent evt) + { + content.modIntegration(); + content.createEntities(); + /*SkillRegistry.registerSkill("Wall Building", new WallBuilding()); + SkillRegistry.registerSkill("Jump", new Jump());*/ + } + + public static LiquidCasting getTableCasting () + { + return tableCasting; + } + + public static LiquidCasting getBasinCasting () + { + return basinCasting; + } + + public static Detailing getChiselDetailing () + { + return chiselDetailing; + } + + public static TContent content; + public static TEventHandler events; + public static TPlayerHandler playerTracker; + public static LiquidCasting tableCasting; + public static LiquidCasting basinCasting; + public static Detailing chiselDetailing; + public static SkillRegistry skillRegistry; +} diff --git a/tconstruct/blocks/Aggregator.java b/tconstruct/blocks/Aggregator.java new file mode 100644 index 00000000..bf9616e1 --- /dev/null +++ b/tconstruct/blocks/Aggregator.java @@ -0,0 +1,136 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.GlowstoneAggregator; +import tconstruct.common.TProxyCommon; +import tconstruct.crystal.TheftValueTracker; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.InventoryBlock; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Aggregator extends InventoryBlock +{ + public String[] textureNames = { "glowstone_top", "glowstone_top_inactive", "glowstone_side", "glowstone_bottom" }; + public Icon[] icons; + + public Aggregator(int id) + { + super(id, Material.iron); + setHardness(2.0f); + this.setCreativeTab(TConstructRegistry.blockTab); + setLightValue(1.0f); + } + + @Override + public int damageDropped (int meta) + { + return meta; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:machines/aggregator_" + textureNames[i]); + } + } + + @Override + public Icon getBlockTexture (IBlockAccess iblockaccess, int x, int y, int z, int side) + { + if (side == 1) + { + GlowstoneAggregator logic = (GlowstoneAggregator) iblockaccess.getBlockTileEntity(x, y, z); + if (logic.getActive()) + return icons[0]; + else + return icons[1]; + } + return this.getIcon(side, iblockaccess.getBlockMetadata(x, y, z)); + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon (int side, int meta) + { + if (side == 0) + return icons[3]; + if (side == 1) + return icons[1]; + return icons[2]; + //return icons[meta]; + } + + @Override + public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) + { + super.onBlockPlacedBy(world, x, y, z, entityliving, stack); + if (!world.isRemote) + TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, 4); + } + + @Override + public void breakBlock (World world, int x, int y, int z, int par5, int par6) + { + super.breakBlock(world, x, y, z, par5, par6); + TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -4); + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + list.add(new ItemStack(id, 1, 0)); + /*for (int iter = 0; iter < icons.length; iter++) + { + list.add(new ItemStack(id, 1, iter)); + }*/ + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + return new GlowstoneAggregator(); + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + return TProxyCommon.glowstoneAggregatorGui; + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } + + @Override + public String[] getTextureNames () + { + return textureNames; + } + + public void updateCrystalValue (World world, int x, int y, int z) + { + GlowstoneAggregator logic = (GlowstoneAggregator) world.getBlockTileEntity(x, y, z); + logic.updateCrystalValue(); + } +} diff --git a/tconstruct/blocks/DryingRack.java b/tconstruct/blocks/DryingRack.java new file mode 100644 index 00000000..51baa980 --- /dev/null +++ b/tconstruct/blocks/DryingRack.java @@ -0,0 +1,363 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.DryingRackLogic; +import tconstruct.client.block.DryingRackRender; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.InventoryBlock; +import tconstruct.library.tools.AbilityHelper; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class DryingRack extends InventoryBlock +{ + + public DryingRack(int id) + { + super(id, Material.rock); + this.setCreativeTab(TConstructRegistry.blockTab); + setHardness(12); + setStepSound(soundMetalFootstep); + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + /*switch (metadata) + { + case 0: + case 1: + return new FaucetLogic(); + case 2: + return new CastingBasinLogic(); + default: + return null; + }*/ + return new DryingRackLogic(); + } + + @Override + public int getRenderBlockPass () + { + return 1; + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + return null; + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } + + public int onBlockPlaced (World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) + { + if (side > 1) + return side; + return meta; + } + + public void onBlockPlacedBy (World world, int x, int y, int z, EntityLiving living, ItemStack stack) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) + { + int l = MathHelper.floor_double((double) (living.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int direction = l % 2; + if (direction == 1) + world.setBlockMetadataWithNotify(x, y, z, 1, 2); + } + } + + /* Activation */ + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ) + { + return activateDryingRack(world, x, y, z, player); + } + + boolean activateDryingRack (World world, int x, int y, int z, EntityPlayer player) + { + if (!world.isRemote) + { + DryingRackLogic logic = (DryingRackLogic) world.getBlockTileEntity(x, y, z); + + if (!logic.isStackInSlot(0)) + { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null) + { + stack = player.inventory.decrStackSize(player.inventory.currentItem, 1); + logic.setInventorySlotContents(0, stack); + } + } + else + { + if (logic.isStackInSlot(0)) + { + ItemStack decrStack = logic.decrStackSize(0, 1); + if (decrStack != null) + addItemToInventory(player, world, x, y, z, decrStack); + } + } + + world.markBlockForUpdate(x, y, z); + } + return true; + } + + public void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack stack) + { + AbilityHelper.spawnItemAtPlayer(player, stack); + } + + public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + float xMin = 0F; + float yMin = 0F; + float zMin = 0F; + float xMax = 1F; + float yMax = 1F; + float zMax = 1F; + switch (metadata) + { + case 0: + zMin = 0.375F; + yMax = 0.25F; + zMax = 0.625F; + break; + case 1: + xMin = 0.375F; + yMax = 0.25F; + xMax = 0.625F; + break; + case 2: + zMin = 0.75F; + yMin = 0.75F; + break; + case 3: + zMax = 0.25F; + yMin = 0.75F; + break; + case 4: + xMin = 0.75F; + yMin = 0.75F; + break; + case 5: + xMax = 0.25F; + yMin = 0.75F; + break; + } + return AxisAlignedBB.getAABBPool().getAABB((double) x + xMin, (double) y + yMin, (double) z + zMin, (double) x + xMax, (double) y + yMax, (double) z + zMax); + } + + public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + float xMin = 0F; + float yMin = 0F; + float zMin = 0F; + float xMax = 1F; + float yMax = 1F; + float zMax = 1F; + switch (metadata) + { + case 0: + zMin = 0.375F; + yMax = 0.25F; + zMax = 0.625F; + break; + case 1: + xMin = 0.375F; + yMax = 0.25F; + xMax = 0.625F; + break; + case 2: + zMin = 0.75F; + yMin = 0.75F; + break; + case 3: + zMax = 0.25F; + yMin = 0.75F; + break; + case 4: + xMin = 0.75F; + yMin = 0.75F; + break; + case 5: + xMax = 0.25F; + yMin = 0.75F; + break; + } + this.setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax); + } + + public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) + { + this.setBlockBoundsBasedOnState(world, x, y, z); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + } + + /* Rendering */ + @Override + public int getRenderType () + { + return DryingRackRender.model; + } + + @Override + public String[] getTextureNames () + { + String[] textureNames = { "castingtable_top", "castingtable_side", "castingtable_bottom", "faucet", "blockcast_top", "blockcast_side", "blockcast_bottom" }; + + return textureNames; + } + + @Override + public Icon getIcon (int side, int meta) + { + return Block.planks.getIcon(side, 0); + } + + public int getTextureIndex (int side) + { + if (side == 0) + return 2; + if (side == 1) + return 0; + + return 1; + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public boolean isOpaqueCube () + { + return false; + } + + /*@Override + public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + return true; + }*/ + + /*@Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 3; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + }*/ + + /*@Override + public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta != 1) + { + this.setBlockBounds(0, 0, 0, 1, 1, 1); + } + else + { + FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z); + float xMin = 0.25F; + float xMax = 0.75F; + float zMin = 0.25F; + float zMax = 0.75F; + + switch (logic.getRenderDirection()) + { + case 2: + zMin = 0.625F; + zMax = 1.0F; + break; + case 3: + zMax = 0.375F; + zMin = 0F; + break; + case 4: + xMin = 0.625F; + xMax = 1.0F; + break; + case 5: + xMax = 0.375F; + xMin = 0F; + break; + } + + this.setBlockBounds(xMin, 0.25F, zMin, xMax, 0.625F, zMax); + } + }*/ + + /*@Override + public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta != 1) + { + return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1, z + 1); + } + else + { + FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z); + if (logic != null) + { + float xMin = 0.25F; + float xMax = 0.75F; + float zMin = 0.25F; + float zMax = 0.75F; + + switch (logic.getRenderDirection()) + { + case 2: + zMin = 0.625F; + zMax = 1.0F; + break; + case 3: + zMax = 0.375F; + zMin = 0F; + break; + case 4: + xMin = 0.625F; + xMax = 1.0F; + break; + case 5: + xMax = 0.375F; + xMin = 0F; + break; + } + + return AxisAlignedBB.getAABBPool().getAABB((double) ((float) x + xMin), (double) y + 0.25, (double) ((float) z + zMin), (double) ((float) x + xMax), (double) y + 0.625, (double) ((float) z + zMax)); + } + } + + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + }*/ + + /* Redstone */ +} diff --git a/tconstruct/blocks/EquipBlock.java b/tconstruct/blocks/EquipBlock.java new file mode 100644 index 00000000..1955226b --- /dev/null +++ b/tconstruct/blocks/EquipBlock.java @@ -0,0 +1,108 @@ +package tconstruct.blocks; + +import java.util.Random; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.FrypanLogic; +import tconstruct.client.block.FrypanRender; +import tconstruct.library.blocks.InventoryBlock; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class EquipBlock extends InventoryBlock +{ + + public EquipBlock(int id, Material material) + { + super(id, material); + this.setHardness(0.3f); + this.setBlockBounds(0, 0, 0, 1, 0.25f, 1); + //this.setCreativeTab(ToolConstruct.materialTab); + } + + @Override + public String[] getTextureNames () + { + return new String[] { "toolstation_top" }; + } + + public Icon getIcon (int side, int meta) + { + return Block.blockIron.getIcon(side, meta); + } + + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister par1IconRegister) + { + //this.blockIcon = par1iconRegister.registerIcon(Block.blockIron.getUnlocalizedName()); + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public boolean isOpaqueCube () + { + return false; + } + + @Override + public int getRenderType () + { + return FrypanRender.frypanModelID; + } + + @Override + public int idDropped (int par1, Random par2Random, int par3) + { + return 0; + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + return new FrypanLogic(); + } + + public void randomDisplayTick (World world, int x, int y, int z, Random random) + { + if (isActive(world, x, y, z)) + { + float f = (float) x + 0.5F; + float f1 = (float) y + 0.25F + (random.nextFloat() * 6F) / 16F; + float f2 = (float) z + 0.5F; + float f4 = random.nextFloat() * 0.6F - 0.3F; + world.spawnParticle("smoke", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + } + } + + public int getLightValue (IBlockAccess world, int x, int y, int z) + { + return !isActive(world, x, y, z) ? 0 : 9; + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + return TConstruct.proxy.frypanGuiID; + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } +} diff --git a/tconstruct/blocks/GlassBlock.java b/tconstruct/blocks/GlassBlock.java new file mode 100644 index 00000000..aeb3366b --- /dev/null +++ b/tconstruct/blocks/GlassBlock.java @@ -0,0 +1,77 @@ +package tconstruct.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class GlassBlock extends TConstructBlock +{ + static String blockTextures[] = { "glass_clear", "soulglass", "soulglass_clear" }; + + public GlassBlock(int id) + { + super(id, Material.glass, 3f, blockTextures); + } + + public boolean isOpaqueCube () + { + return false; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + int i1 = par1IBlockAccess.getBlockId(par2, par3, par4); + return i1 == this.blockID ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5); + } + + @Override + public float getBlockHardness (World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + switch (meta) + { + case 0: + return 0.3F; + case 1: + return 50.0F; + case 2: + return 50.0F; + default: + return blockHardness; + } + } + + public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) + { + int meta = world.getBlockMetadata(x, y, z); + switch (meta) + { + case 0: + return 1.5F; + case 1: + return 2000F; + case 2: + return 2000F; + default: + return getExplosionResistance(entity); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:glass/" + textureNames[i]); + } + } +} diff --git a/tconstruct/blocks/GlassBlockConnected.java b/tconstruct/blocks/GlassBlockConnected.java new file mode 100644 index 00000000..aa6e13cb --- /dev/null +++ b/tconstruct/blocks/GlassBlockConnected.java @@ -0,0 +1,619 @@ +package tconstruct.blocks; + +import tconstruct.library.TConstructRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +/** @author fuj1n + * + */ + +public class GlassBlockConnected extends Block +{ + private Icon[] icons = new Icon[16]; + private boolean shouldRenderSelectionBox = true; + protected String folder; + private int renderPass; + + public GlassBlockConnected(int par1, String location, boolean hasAlpha) + { + super(par1, Material.glass); + this.setStepSound(soundGlassFootstep); + folder = location; + renderPass = hasAlpha ? 1 : 0; + this.setCreativeTab(TConstructRegistry.blockTab); + } + + @Override + public boolean isOpaqueCube () + { + return false; + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public int getRenderBlockPass () + { + return renderPass; + } + + /** + * This is checked to see if the texture should connect to this block + * @param par2 x + * @param par3 y + * @param par4 z + * @param par5 ID this block is asking to connect to (may be 0 if there is no block) + * @param par6 Metadata of the block this block is trying to connect to + * @return true if should connect + */ + public boolean shouldConnectToBlock (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, int par6) + { + return par5 == this.blockID; + } + + @Override + public Icon getBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons); + } + + public Icon getConnectedBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, Icon[] icons) + { + boolean isOpenUp = false, isOpenDown = false, isOpenLeft = false, isOpenRight = false; + + switch (par5) + { + case 0: + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4))) + { + isOpenDown = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4))) + { + isOpenUp = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1))) + { + isOpenLeft = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1))) + { + isOpenRight = true; + } + + if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight) + { + return icons[15]; + } + else if (isOpenUp && isOpenDown && isOpenLeft) + { + return icons[11]; + } + else if (isOpenUp && isOpenDown && isOpenRight) + { + return icons[12]; + } + else if (isOpenUp && isOpenLeft && isOpenRight) + { + return icons[13]; + } + else if (isOpenDown && isOpenLeft && isOpenRight) + { + return icons[14]; + } + else if (isOpenDown && isOpenUp) + { + return icons[5]; + } + else if (isOpenLeft && isOpenRight) + { + return icons[6]; + } + else if (isOpenDown && isOpenLeft) + { + return icons[8]; + } + else if (isOpenDown && isOpenRight) + { + return icons[10]; + } + else if (isOpenUp && isOpenLeft) + { + return icons[7]; + } + else if (isOpenUp && isOpenRight) + { + return icons[9]; + } + else if (isOpenDown) + { + return icons[3]; + } + else if (isOpenUp) + { + return icons[4]; + } + else if (isOpenLeft) + { + return icons[2]; + } + else if (isOpenRight) + { + return icons[1]; + } + break; + case 1: + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4))) + { + isOpenDown = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4))) + { + isOpenUp = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1))) + { + isOpenLeft = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1))) + { + isOpenRight = true; + } + + if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight) + { + return icons[15]; + } + else if (isOpenUp && isOpenDown && isOpenLeft) + { + return icons[11]; + } + else if (isOpenUp && isOpenDown && isOpenRight) + { + return icons[12]; + } + else if (isOpenUp && isOpenLeft && isOpenRight) + { + return icons[13]; + } + else if (isOpenDown && isOpenLeft && isOpenRight) + { + return icons[14]; + } + else if (isOpenDown && isOpenUp) + { + return icons[5]; + } + else if (isOpenLeft && isOpenRight) + { + return icons[6]; + } + else if (isOpenDown && isOpenLeft) + { + return icons[8]; + } + else if (isOpenDown && isOpenRight) + { + return icons[10]; + } + else if (isOpenUp && isOpenLeft) + { + return icons[7]; + } + else if (isOpenUp && isOpenRight) + { + return icons[9]; + } + else if (isOpenDown) + { + return icons[3]; + } + else if (isOpenUp) + { + return icons[4]; + } + else if (isOpenLeft) + { + return icons[2]; + } + else if (isOpenRight) + { + return icons[1]; + } + break; + case 2: + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4))) + { + isOpenDown = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4))) + { + isOpenUp = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4))) + { + isOpenLeft = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4))) + { + isOpenRight = true; + } + + if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight) + { + return icons[15]; + } + else if (isOpenUp && isOpenDown && isOpenLeft) + { + return icons[13]; + } + else if (isOpenUp && isOpenDown && isOpenRight) + { + return icons[14]; + } + else if (isOpenUp && isOpenLeft && isOpenRight) + { + return icons[11]; + } + else if (isOpenDown && isOpenLeft && isOpenRight) + { + return icons[12]; + } + else if (isOpenDown && isOpenUp) + { + return icons[6]; + } + else if (isOpenLeft && isOpenRight) + { + return icons[5]; + } + else if (isOpenDown && isOpenLeft) + { + return icons[9]; + } + else if (isOpenDown && isOpenRight) + { + return icons[10]; + } + else if (isOpenUp && isOpenLeft) + { + return icons[7]; + } + else if (isOpenUp && isOpenRight) + { + return icons[8]; + } + else if (isOpenDown) + { + return icons[1]; + } + else if (isOpenUp) + { + return icons[2]; + } + else if (isOpenLeft) + { + return icons[4]; + } + else if (isOpenRight) + { + return icons[3]; + } + break; + case 3: + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4))) + { + isOpenDown = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4))) + { + isOpenUp = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4))) + { + isOpenLeft = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4))) + { + isOpenRight = true; + } + + if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight) + { + return icons[15]; + } + else if (isOpenUp && isOpenDown && isOpenLeft) + { + return icons[14]; + } + else if (isOpenUp && isOpenDown && isOpenRight) + { + return icons[13]; + } + else if (isOpenUp && isOpenLeft && isOpenRight) + { + return icons[11]; + } + else if (isOpenDown && isOpenLeft && isOpenRight) + { + return icons[12]; + } + else if (isOpenDown && isOpenUp) + { + return icons[6]; + } + else if (isOpenLeft && isOpenRight) + { + return icons[5]; + } + else if (isOpenDown && isOpenLeft) + { + return icons[10]; + } + else if (isOpenDown && isOpenRight) + { + return icons[9]; + } + else if (isOpenUp && isOpenLeft) + { + return icons[8]; + } + else if (isOpenUp && isOpenRight) + { + return icons[7]; + } + else if (isOpenDown) + { + return icons[1]; + } + else if (isOpenUp) + { + return icons[2]; + } + else if (isOpenLeft) + { + return icons[3]; + } + else if (isOpenRight) + { + return icons[4]; + } + break; + case 4: + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4))) + { + isOpenDown = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4))) + { + isOpenUp = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1))) + { + isOpenLeft = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1))) + { + isOpenRight = true; + } + + if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight) + { + return icons[15]; + } + else if (isOpenUp && isOpenDown && isOpenLeft) + { + return icons[14]; + } + else if (isOpenUp && isOpenDown && isOpenRight) + { + return icons[13]; + } + else if (isOpenUp && isOpenLeft && isOpenRight) + { + return icons[11]; + } + else if (isOpenDown && isOpenLeft && isOpenRight) + { + return icons[12]; + } + else if (isOpenDown && isOpenUp) + { + return icons[6]; + } + else if (isOpenLeft && isOpenRight) + { + return icons[5]; + } + else if (isOpenDown && isOpenLeft) + { + return icons[10]; + } + else if (isOpenDown && isOpenRight) + { + return icons[9]; + } + else if (isOpenUp && isOpenLeft) + { + return icons[8]; + } + else if (isOpenUp && isOpenRight) + { + return icons[7]; + } + else if (isOpenDown) + { + return icons[1]; + } + else if (isOpenUp) + { + return icons[2]; + } + else if (isOpenLeft) + { + return icons[3]; + } + else if (isOpenRight) + { + return icons[4]; + } + break; + case 5: + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4))) + { + isOpenDown = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4))) + { + isOpenUp = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1))) + { + isOpenLeft = true; + } + + if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1))) + { + isOpenRight = true; + } + + if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight) + { + return icons[15]; + } + else if (isOpenUp && isOpenDown && isOpenLeft) + { + return icons[13]; + } + else if (isOpenUp && isOpenDown && isOpenRight) + { + return icons[14]; + } + else if (isOpenUp && isOpenLeft && isOpenRight) + { + return icons[11]; + } + else if (isOpenDown && isOpenLeft && isOpenRight) + { + return icons[12]; + } + else if (isOpenDown && isOpenUp) + { + return icons[6]; + } + else if (isOpenLeft && isOpenRight) + { + return icons[5]; + } + else if (isOpenDown && isOpenLeft) + { + return icons[9]; + } + else if (isOpenDown && isOpenRight) + { + return icons[10]; + } + else if (isOpenUp && isOpenLeft) + { + return icons[7]; + } + else if (isOpenUp && isOpenRight) + { + return icons[8]; + } + else if (isOpenDown) + { + return icons[1]; + } + else if (isOpenUp) + { + return icons[2]; + } + else if (isOpenLeft) + { + return icons[4]; + } + else if (isOpenRight) + { + return icons[3]; + } + break; + } + + return icons[0]; + } + + @Override + public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + int i1 = par1IBlockAccess.getBlockId(par2, par3, par4); + return i1 == this.blockID ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5); + } + + @Override + public Icon getIcon (int par1, int par2) + { + return icons[0]; + } + + @Override + public AxisAlignedBB getSelectedBoundingBoxFromPool (World par1World, int par2, int par3, int par4) + { + if (shouldRenderSelectionBox) + { + return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4); + } + else + { + return AxisAlignedBB.getAABBPool().getAABB(0D, 0D, 0D, 0D, 0D, 0D); + } + } + + @Override + public void registerIcons (IconRegister par1IconRegister) + { + icons[0] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass"); + icons[1] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_d"); + icons[2] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_u"); + icons[3] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_l"); + icons[4] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_r"); + icons[5] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_h"); + icons[6] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_v"); + icons[7] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_dl"); + icons[8] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_dr"); + icons[9] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_ul"); + icons[10] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_ur"); + icons[11] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_d"); + icons[12] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_u"); + icons[13] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_l"); + icons[14] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_r"); + icons[15] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_4"); + } +} diff --git a/tconstruct/blocks/GlassBlockConnectedMeta.java b/tconstruct/blocks/GlassBlockConnectedMeta.java new file mode 100644 index 00000000..773cd355 --- /dev/null +++ b/tconstruct/blocks/GlassBlockConnectedMeta.java @@ -0,0 +1,93 @@ +package tconstruct.blocks; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; + +/** @author fuj1n + * + */ + +public class GlassBlockConnectedMeta extends GlassBlockConnected +{ + public String[] textures; + public Icon[][] icons; + boolean ignoreMetaForConnectedGlass = true; + + public GlassBlockConnectedMeta(int par1, String location, boolean hasAlpha, String... textures) + { + super(par1, location, hasAlpha); + this.textures = textures; + this.icons = new Icon[textures.length][16]; + } + + @Override + public Icon getBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4); + if (meta < icons.length) + { + return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons[meta]); + } + else + { + return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons[0]); + } + } + + @Override + public boolean shouldConnectToBlock (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, int par6) + { + return par5 == this.blockID && (par6 == par1IBlockAccess.getBlockMetadata(par2, par3, par4) || ignoreMetaForConnectedGlass); + } + + @Override + public Icon getIcon (int par1, int par2) + { + return icons[par2][0]; + } + + @Override + public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int i = 0; i < textures.length; i++) + { + par3List.add(new ItemStack(par1, 1, i)); + } + } + + @Override + public void registerIcons (IconRegister par1IconRegister) + { + for (int i = 0; i < textures.length; i++) + { + icons[i][0] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass"); + icons[i][1] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_d"); + icons[i][2] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_u"); + icons[i][3] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_l"); + icons[i][4] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_r"); + icons[i][5] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_h"); + icons[i][6] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_v"); + icons[i][7] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_dl"); + icons[i][8] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_dr"); + icons[i][9] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_ul"); + icons[i][10] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_ur"); + icons[i][11] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_d"); + icons[i][12] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_u"); + icons[i][13] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_l"); + icons[i][14] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_r"); + icons[i][15] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_4"); + } + } + + @Override + public int damageDropped (int par1) + { + return par1; + } + +} diff --git a/tconstruct/blocks/GlassBlockStained.java b/tconstruct/blocks/GlassBlockStained.java new file mode 100644 index 00000000..25bd9db5 --- /dev/null +++ b/tconstruct/blocks/GlassBlockStained.java @@ -0,0 +1,50 @@ +package tconstruct.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class GlassBlockStained extends TConstructBlock +{ + static String blockTextures[] = { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "gray", "lightgray", "cyan", "purple", "blue", "brown", "green", "red", "black" }; + String textureName; + + public GlassBlockStained(int id, String tex) + { + super(id, Material.glass, 3f, blockTextures); + this.textureName = tex; + } + + @Override + public int getRenderBlockPass () + { + return 1; + } + + public boolean isOpaqueCube () + { + return false; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side) + { + int blockID = world.getBlockId(x, y, z); + return blockID == this.blockID ? false : super.shouldSideBeRendered(world, x, y, z, side); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:glass/" + textureName + textureNames[i]); + } + } +} diff --git a/tconstruct/blocks/GlassPane.java b/tconstruct/blocks/GlassPane.java new file mode 100644 index 00000000..ca7ab07d --- /dev/null +++ b/tconstruct/blocks/GlassPane.java @@ -0,0 +1,18 @@ +package tconstruct.blocks; + +import tconstruct.library.TConstructRegistry; +import net.minecraft.block.material.Material; + +public class GlassPane extends PaneBase +{ + static String blockTextures[] = { "glass_clear", "soulglass", "soulglass_clear" }; + + public GlassPane(int id) + { + super(id, Material.glass, "glass/", blockTextures); + this.setHardness(0.3F); + this.setStepSound(soundGlassFootstep); + this.setUnlocalizedName("tconstruct.glasspane"); + this.setCreativeTab(TConstructRegistry.blockTab); + } +} diff --git a/tconstruct/blocks/GlassPaneConnected.java b/tconstruct/blocks/GlassPaneConnected.java new file mode 100644 index 00000000..25873ca5 --- /dev/null +++ b/tconstruct/blocks/GlassPaneConnected.java @@ -0,0 +1,72 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.client.block.PaneConnectedRender; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; + +public class GlassPaneConnected extends GlassBlockConnected +{ + + private Icon theIcon; + + public GlassPaneConnected(int par1, String location, boolean hasAlpha) + { + super(par1, location, hasAlpha); + } + + @Override + public int getRenderType () + { + return PaneConnectedRender.model; + } + + @Override + public void addCollisionBoxesToList (World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) + { + Block.thinGlass.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); + } + + @Override + public void setBlockBoundsForItemRender () + { + Block.thinGlass.setBlockBoundsForItemRender(); + } + + @Override + public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4) + { + Block.thinGlass.setBlockBoundsBasedOnState(par1IBlockAccess, par2, par3, par4); + } + + public Icon getSideTextureIndex () + { + return this.theIcon; + } + + public final boolean canThisPaneConnectToThisBlockID (int par1) + { + return Block.opaqueCubeLookup[par1] || par1 == this.blockID || par1 == Block.glass.blockID; + } + + public void registerIcons (IconRegister par1IconRegister) + { + super.registerIcons(par1IconRegister); + this.theIcon = par1IconRegister.registerIcon("tinkersconstruct:glass/" + folder + "/glass_side"); + } + + public boolean canPaneConnectTo (IBlockAccess access, int x, int y, int z, ForgeDirection dir) + { + return canThisPaneConnectToThisBlockID(access.getBlockId(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) + || access.isBlockSolidOnSide(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false); + } + +} diff --git a/tconstruct/blocks/GlassPaneStained.java b/tconstruct/blocks/GlassPaneStained.java new file mode 100644 index 00000000..ab33c0df --- /dev/null +++ b/tconstruct/blocks/GlassPaneStained.java @@ -0,0 +1,34 @@ +package tconstruct.blocks; + +import tconstruct.library.TConstructRegistry; +import net.minecraft.block.material.Material; + +public class GlassPaneStained extends PaneBase +{ + static String blockTextures[] = { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "gray", "lightgray", "cyan", "purple", "blue", "brown", "green", "red", "black" }; + + public GlassPaneStained(int id) + { + super(id, Material.glass, "glass/", assembleBlockTextures()); + this.setHardness(0.3F); + this.setStepSound(soundGlassFootstep); + this.setUnlocalizedName("tconstruct.glasspanestained"); + this.setCreativeTab(TConstructRegistry.blockTab); + } + + private static String[] assembleBlockTextures () + { + String[] textures = new String[blockTextures.length]; + for (int i = 0; i < blockTextures.length; i++) + { + textures[i] = "stainedglass_" + blockTextures[i]; + } + return textures; + } + + @Override + public int getRenderBlockPass () + { + return 1; + } +} diff --git a/tconstruct/blocks/GolemCoreBlock.java b/tconstruct/blocks/GolemCoreBlock.java new file mode 100644 index 00000000..26a0b956 --- /dev/null +++ b/tconstruct/blocks/GolemCoreBlock.java @@ -0,0 +1,115 @@ +package tconstruct.blocks; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.GolemCoreLogic; +import tconstruct.client.block.GolemCoreRender; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.InventoryBlock; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class GolemCoreBlock extends InventoryBlock +{ + public GolemCoreBlock(int id) + { + super(id, Material.rock); + this.setCreativeTab(TConstructRegistry.blockTab); + } + + public boolean isOpaqueCube () + { + return false; + } + + public boolean renderAsNormalBlock () + { + return false; + } + + public int getRenderType () + { + return GolemCoreRender.model; + } + + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) + { + if (!world.isRemote) + { + GolemCoreLogic logic = (GolemCoreLogic) world.getBlockTileEntity(x, y, z); + + if (!logic.isStackInSlot(0)) + { + ItemStack stack = player.getCurrentEquippedItem(); + stack = player.inventory.decrStackSize(player.inventory.currentItem, 1); + logic.setInventorySlotContents(0, stack); + } + else + { + ItemStack stack = logic.decrStackSize(0, 1); + if (stack != null) + addItemToInventory(player, world, x, y, z, stack); + } + + world.markBlockForUpdate(x, y, z); + } + return true; + } + + protected void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack stack) + { + if (!world.isRemote) + { + EntityItem entityitem = new EntityItem(world, (double) x + 0.5D, (double) y + 0.9325D, (double) z + 0.5D, stack); + world.spawnEntityInWorld(entityitem); + entityitem.onCollideWithPlayer(player); + } + } + + public int damageDropped (int meta) + { + return meta; + } + + @Override + public Icon getIcon (int side, int meta) + { + return icons[0]; + } + + @Override + public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + return true; + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + return new GolemCoreLogic(); + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + return null; //Not sure if gui block or not, probably not + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } + + @Override + public String[] getTextureNames () + { + return new String[] { "golemcore" }; + } +} diff --git a/tconstruct/blocks/GolemHeadBlock.java b/tconstruct/blocks/GolemHeadBlock.java new file mode 100644 index 00000000..e18e4bae --- /dev/null +++ b/tconstruct/blocks/GolemHeadBlock.java @@ -0,0 +1,1014 @@ +package tconstruct.blocks; + +import tconstruct.blocks.logic.GolemCoreLogic; +import tconstruct.common.TContent; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class GolemHeadBlock extends Block +{ + /*public static int headSideTex = ModLoader.addOverride("/terrain.png", "/GGE/golemheadside.png"); + public static int headTopTex = ModLoader.addOverride("/terrain.png", "/GGE/golemheadtop&bottom.png"); + public static int face;*/ + + public GolemHeadBlock(int id) + { + super(id, Material.ground); + //setTickRandomly(true); + } + + public Icon[] icons; + public String[] textureNames = new String[] { "golemhead_face", "golemhead_side", "golemhead_top" }; + + @Override + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]); + } + } + + @Override + public void onNeighborBlockChange (World world, int x, int y, int z, int blockID) + { + if (buildGolem(world, x, y, z, world.getBlockMetadata(x, y, z))) + { + //mod_Golems.trigger("headachievement"); + } + } + + /*public int getIcon(int i, int j) + { + if (i == 1) + { + return headTopTex; + } + if (i == 0) + { + return headTopTex; + } + int k = face; + if (j == 2 && i == 2) + { + return k; + } + if (j == 3 && i == 5) + { + return k; + } + if (j == 0 && i == 3) + { + return k; + } + if (j == 1 && i == 4) + { + return k; + } + else + { + return headSideTex; + } + }*/ + + /*public int getBlockTextureFromSide(int i) + { + int j = face; + if (i == 1) + { + return blockIndexInTexture; + } + if (i == 0) + { + return blockIndexInTexture; + } + if (i == 3) + { + return j; + } + else + { + return blockIndexInTexture + 16; + } + }*/ + + @Override + public void onBlockPlacedBy (World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack par6ItemStack) + { + int l = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 2.5D) & 3; + world.setBlockMetadataWithNotify(i, j, k, l, 3); + if (!buildGolem(world, i, j, k, l)) + { + for (int i1 = 0; (double) i1 < Math.random() * 5D + 3D; i1++) + { + world.spawnParticle("largesmoke", (double) i + Math.random(), (double) j + 1.2D + Math.random() / 2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + } + } + /*else + { + mod_Golems.trigger("headachievement"); + }*/ + } + + private boolean idIsInvalid (int i) + { + return Block.blocksList[i] != null && (!Block.blocksList[i].renderAsNormalBlock() && i != TContent.golemCore.blockID || i == 43 || i == 44 || i == Block.chest.blockID); + } + + private boolean buildGolem (World world, int x, int y, int z, int metadata) + { + /*int pedestalHeight = 0; + for (int yPos = 1; yPos <= 3; yPos++) + { + if (world.getBlockId(x, y - yPos, z) == TContent.golemPedestal.blockID) + { + pedestalHeight = yPos; + } + } + + if (pedestalHeight == 0) + { + return false; + } + for (int height = pedestalHeight; height >= 0; height--) + { + if (world.getBlockId(x, y - height, z) == 0) + { + return false; + } + } + + int l1 = 0; + int i2 = 0; + ItemStack itemstack = null; + GolemCoreLogic coreLogic = null; + int golemBlockIDs[][] = new int[3][3]; + int golemBlockMetas[][] = new int[3][3]; + for (int arrX = 0; arrX < 3; arrX++) + { + for (int arrY = 0; arrY < 3; arrY++) + { + golemBlockIDs[arrX][arrY] = 0; + } + } + + for (int iterX = -1; iterX <= 1; iterX++) + { + for (int iterY = 0; iterY < 3; iterY++) + { + if (iterY + (3 - pedestalHeight) >= 3 || iterY + (3 - pedestalHeight) == 0 && iterX != 0) + { + continue; + } + if (metadata == 0) + { + int bID = world.getBlockId(x - iterX, y - iterY, z); + if (idIsInvalid(bID)) + { + bID = 0; + return false; + } + if (bID == blockID) + { + i2++; + } + golemBlockIDs[iterX + 1][iterY + (3 - pedestalHeight)] = bID; + golemBlockMetas[iterX + 1][iterY + (3 - pedestalHeight)] = bID == blockID ? 0 : world.getBlockMetadata(x - iterX, y - iterY, z); + } + if (metadata == 1) + { + int l3 = world.getBlockId(x, y - iterY, z - iterX); + if (idIsInvalid(l3)) + { + l3 = 0; + return false; + } + if (l3 == blockID) + { + i2++; + } + golemBlockIDs[iterX + 1][iterY + (3 - pedestalHeight)] = l3; + golemBlockMetas[iterX + 1][iterY + (3 - pedestalHeight)] = l3 == blockID ? 0 : world.getBlockMetadata(x, y - iterY, z - iterX); + } + if (metadata == 2) + { + int i4 = world.getBlockId(x + iterX, y - iterY, z); + if (idIsInvalid(i4)) + { + i4 = 0; + return false; + } + if (i4 == blockID) + { + i2++; + } + golemBlockIDs[iterX + 1][iterY + (3 - pedestalHeight)] = i4; + golemBlockMetas[iterX + 1][iterY + (3 - pedestalHeight)] = i4 == blockID ? 0 : world.getBlockMetadata(x + iterX, y - iterY, z); + } + if (metadata == 3) + { + int bID = world.getBlockId(x, y - iterY, z + iterX); + if (idIsInvalid(bID)) + { + bID = 0; + return false; + } + if (bID == blockID) + { + i2++; + } + golemBlockIDs[iterX + 1][iterY + (3 - pedestalHeight)] = bID; + golemBlockMetas[iterX + 1][iterY + (3 - pedestalHeight)] = bID == blockID ? 0 : world.getBlockMetadata(x, y - iterY, z + iterX); + } + if (i2 > 1) + { + return false; + } + if (golemBlockIDs[iterX + 1][iterY + (3 - pedestalHeight)] != 0 && Block.blocksList[golemBlockIDs[iterX + 1][iterY]] != null + && !Block.blocksList[golemBlockIDs[iterX + 1][iterY]].renderAsNormalBlock() && (iterX + 1 == 0 || iterX + 1 == 2) && iterY == 2 + && golemBlockIDs[iterX + 1][iterY] != TContent.golemCore.blockID) + { + return false; + } + if (golemBlockIDs[iterX + 1][iterY + (3 - pedestalHeight)] == TContent.golemCore.blockID) + { + l1++; + if (metadata == 0) + { + coreLogic = (GolemCoreLogic) world.getBlockTileEntity(x - iterX, y - iterY, z); + } + if (metadata == 1) + { + coreLogic = (GolemCoreLogic) world.getBlockTileEntity(x, y - iterY, z - iterX); + } + if (metadata == 2) + { + coreLogic = (GolemCoreLogic) world.getBlockTileEntity(x + iterX, y - iterY, z); + } + if (metadata == 3) + { + coreLogic = (GolemCoreLogic) world.getBlockTileEntity(x, y - iterY, z + iterX); + } + itemstack = coreLogic.getKey(); + } + if (l1 > 1) + { + return false; + } + } + } + + boolean flag = false; + for (int j3 = 0; j3 < 3; j3++) + { + for (int k4 = 0; k4 < 3; k4++) + { + if (golemBlockIDs[k4][j3] == this.blockID) + { + flag = true; + } + } + } + + if (!flag) + { + return false; + } + if (golemBlockIDs[0][2] != 0 && Block.blocksList[golemBlockIDs[0][2]].renderAsNormalBlock() || golemBlockIDs[2][2] != 0 && Block.blocksList[golemBlockIDs[2][2]].renderAsNormalBlock()) + { + return false; + } + if (l1 > 0 + && (golemBlockIDs[0][0] == TContent.golemCore.blockID || golemBlockIDs[0][1] == TContent.golemCore.blockID || golemBlockIDs[2][0] == TContent.golemCore.blockID || golemBlockIDs[2][1] == TContent.golemCore.blockID)) + { + return false; + } + TileEntity tileentity = world.getBlockTileEntity(x, y - pedestalHeight, z); + if (!(tileentity instanceof TileEntityGolemPedestal)) + { + return false; + } + TileEntityGolemPedestal tileentitygolempedestal = (TileEntityGolemPedestal) tileentity; + if (tileentitygolempedestal.subtractSoul(l1 == 1 ? 8 : 1) && world.getBlockId(x, y - pedestalHeight, z) == TContent.golemPedestal.blockID) + { + EntityGenericGolem entitygenericgolem = new EntityGenericGolem(world); + EntityPlayerSP entityplayersp = ModLoader.getMinecraftInstance().thePlayer; + double d = ((EntityPlayer) (entityplayersp)).posX - (double) (float) ((double) x + 0.5D); + double d1 = ((EntityPlayer) (entityplayersp)).posZ - (double) (float) ((double) z + 0.5D); + entitygenericgolem.setBody(golemBlockIDs, golemBlockMetas, y, pedestalHeight); + entitygenericgolem.setPositionAndRotation((double) x + 0.5D, (y - pedestalHeight) + 1, (double) z + 0.5D, (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F, 0.0F); + if (l1 > 0) + { + entitygenericgolem.setCore(itemstack); + } + if (coreLogic != null) + { + //((GolemCoreBlock) mod_Golems.golemCore).killDisplayItem(world, coreLogic.xCoord, coreLogic.yCoord, coreLogic.zCoord); + //coreLogic.key = null; + } + if (!buildInterrupt(world, x, y, z, metadata, golemBlockIDs, golemBlockMetas, pedestalHeight, coreLogic != null, itemstack, coreLogic) && world.spawnEntityInWorld(entitygenericgolem)) + { + delBlocks(world, x, y, z, metadata, golemBlockIDs, pedestalHeight); + world.spawnParticle("hugeexplosion", (double) x + Math.random(), (double) y + 1.2D, (double) z + Math.random(), 0.0D, 0.0D, 0.0D); + return true; + } + else + { + return false; + } + } + else + { + return false; + }*/ + return false; + } + + public boolean buildInterrupt (World world, int i, int j, int k, int l, int ai[][], int ai1[][], int i1, boolean flag, ItemStack itemstack, GolemCoreLogic tileentitygolemcore) + { + /*EntityPlayerSP entityplayersp = ModLoader.getMinecraftInstance().thePlayer; + double d = ((EntityPlayer) (entityplayersp)).posX - (double) (float) ((double) i + 0.5D); + double d1 = ((EntityPlayer) (entityplayersp)).posZ - (double) (float) ((double) k + 0.5D); + int j1 = world.difficultySetting; + int k1 = 0; + for (int l1 = 0; l1 < 3; l1++) + { + for (int i2 = 0; i2 < 3; i2++) + { + if (ai[l1][i2] != 0) + { + k1++; + } + } + } + + boolean flag1 = ai[0][1] != 0 || ai[2][1] != 0; + if (isAll(ai, ai1, Block.tnt.blockID, -1) || i1 == 3 && ai[1][1] == Block.tnt.blockID && ai[1][2] == Block.cloth.blockID && ai1[1][2] == 5 && !flag1 && j1 >= 1) + { + EntityCreeper entitycreeper = new EntityCreeper(world); + entitycreeper.setPositionAndRotation((double) i + 0.5D, (j - i1) + 1, (double) k + 0.5D, (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F, 0.0F); + world.spawnEntityInWorld(entitycreeper); + delBlocks(world, i, j, k, l, ai, i1); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + mod_Golems.trigger("creeper"); + return true; + } + if (isAll(ai, ai1, Block.netherrack.blockID, -1) && i1 == 3 && j1 >= 1) + { + EntityBlaze entityblaze = new EntityBlaze(world); + entityblaze.setPositionAndRotation((double) i + 0.5D, (j - i1) + 1, (double) k + 0.5D, (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F, 0.0F); + world.spawnEntityInWorld(entityblaze); + delBlocks(world, i, j, k, l, ai, i1); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + mod_Golems.trigger("blaze"); + return true; + } + if (isAll(ai, ai1, Block.obsidian.blockID, -1) && i1 == 3 && countBlock(ai, ai1, Block.obsidian.blockID, -1) == 2 && j1 >= 1) + { + EntityEnderman entityenderman = new EntityEnderman(world); + entityenderman.setPositionAndRotation((double) i + 0.5D, (j - i1) + 1, (double) k + 0.5D, (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F, 0.0F); + world.spawnEntityInWorld(entityenderman); + delBlocks(world, i, j, k, l, ai, i1); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + mod_Golems.trigger("enderman"); + return true; + } + if (hasBlock(ai, ai1, Block.tnt.blockID, -1) && hasBlock(ai, ai1, Block.netherrack.blockID, -1)) + { + boolean flag2 = false; + Entity aentity[][] = new Entity[3][3]; + for (int j2 = 0; j2 < 3; j2++) + { + for (int l2 = 0; l2 < 3; l2++) + { + aentity[j2][l2] = null; + if (ai[j2][l2] == Block.tnt.blockID) + { + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world); + entitytntprimed.fuse = 80; + aentity[j2][l2] = entitytntprimed; + } + } + } + + replEntity(world, i, j, k, l, ai, aentity, i1); + i1 = updateBody(ai, ai1); + EntityGenericGolem entitygenericgolem = new EntityGenericGolem(world); + entitygenericgolem.setBody(ai, ai1, l, i1); + entitygenericgolem.setPositionAndRotation((double) i + 0.5D, (j - i1) + 1, (double) k + 0.5D, (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F, 0.0F); + if (flag) + { + entitygenericgolem.setCore(itemstack); + } + world.spawnEntityInWorld(entitygenericgolem); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + mod_Golems.trigger("boom"); + return true; + } + if (i1 == 3 && !flag1 && ai[1][2] == Block.blockIron.blockID && ai[1][1] == Block.blockIron.blockID) + { + List list = world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getAABBPool().getAABB(i, j, k, (double) i + 1.0D, (double) j + 1.0D, (double) k + 1.0D).expand(4D, 16D, 4D)); + Entity entity; + for (Iterator iterator = list.iterator(); iterator.hasNext(); world.addWeatherEffect(new EntityLightningBolt(world, entity.posX, entity.posY, entity.posZ))) + { + Object obj = iterator.next(); + entity = (Entity) obj; + } + + mod_Golems.trigger("zap"); + } + else + { + if (isAll(ai, ai1, Block.cloth.blockID, 0) && countBlock(ai, ai1, Block.cloth.blockID, 0) == 4) + { + EntitySheep entitysheep = new EntitySheep(world); + entitysheep.setPositionAndRotation((double) i + 0.5D, (j - i1) + 1, (double) k + 0.5D, (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F, 0.0F); + world.spawnEntityInWorld(entitysheep); + delBlocks(world, i, j, k, l, ai, i1); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + mod_Golems.trigger("sheep"); + return true; + } + if (countBlock(ai, ai1, Block.furnaceIdle.blockID, -1) >= (int) (Math.random() * 2D + 2D)) + { + ItemStack aitemstack[][] = new ItemStack[3][3]; + aitemstack[0][1] = new ItemStack(Block.lavaMoving, 1); + aitemstack[2][1] = new ItemStack(Block.lavaMoving, 1); + aitemstack[1][0] = new ItemStack(Block.lavaMoving, 1); + aitemstack[1][1] = new ItemStack(Block.lavaMoving, 1); + aitemstack[1][2] = new ItemStack(Block.lavaMoving, 1); + replBlocks(world, i, j, k, l, ai, aitemstack, i1); + mod_Golems.trigger("meltdown"); + return true; + } + if (hasBlock(ai, ai1, Block.stoneBrick.blockID, -1) && Math.random() <= 0.40000000000000002D) + { + boolean flag3 = false; + Entity aentity1[][] = new Entity[3][3]; + for (int k2 = 0; k2 < 3; k2++) + { + for (int i3 = 0; i3 < 3; i3++) + { + aentity1[k2][i3] = null; + if (ai[k2][i3] == Block.stoneBrick.blockID) + { + aentity1[k2][i3] = Math.random() <= 0.59999999999999998D ? ((Entity) (new EntitySilverfish(world))) : null; + } + } + } + + replEntity(world, i, j, k, l, ai, aentity1, i1); + i1 = updateBody(ai, ai1); + EntityGenericGolem entitygenericgolem1 = new EntityGenericGolem(world); + entitygenericgolem1.setBody(ai, ai1, l, i1); + entitygenericgolem1.setPositionAndRotation((double) i + 0.5D, (j - i1) + 1, (double) k + 0.5D, (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F, 0.0F); + if (flag) + { + entitygenericgolem1.setCore(itemstack); + } + world.spawnEntityInWorld(entitygenericgolem1); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + mod_Golems.trigger("silverfish"); + return true; + } + if (countBlock(ai, ai1, Block.melon.blockID, -1) == 4) + { + delBlocks(world, i, j, k, l, ai, i1); + EntityGSpawn entitygspawn = new EntityGSpawn(world); + entitygspawn.setPosition(i, j, k); + entitygspawn.skin = "http://s3.amazonaws.com/MinecraftSkins/loligator704.png"; + world.spawnEntityInWorld(entitygspawn); + mod_Golems.trigger("loligator"); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + return true; + } + if (countBlock(ai, ai1, Block.cloth.blockID, 13) == 3 && ai[1][1] == Block.cloth.blockID && ai1[1][1] == 0) + { + delBlocks(world, i, j, k, l, ai, i1); + EntityGSpawn entitygspawn1 = new EntityGSpawn(world); + entitygspawn1.setPosition(i, j, k); + entitygspawn1.skin = "http://s3.amazonaws.com/MinecraftSkins/coalheartly.png"; + world.spawnEntityInWorld(entitygspawn1); + mod_Golems.trigger("bitterman"); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + return true; + } + if (countBlock(ai, ai1, Block.cloth.blockID, 11) == 3 && ai[1][1] == Block.blockLapis.blockID) + { + delBlocks(world, i, j, k, l, ai, i1); + EntityGSpawn entitygspawn2 = new EntityGSpawn(world); + entitygspawn2.setPosition(i, j, k); + entitygspawn2.skin = "http://s3.amazonaws.com/MinecraftSkins/BILLYTG101.png"; + world.spawnEntityInWorld(entitygspawn2); + mod_Golems.trigger("yourstruly"); + return true; + } + if (countBlock(ai, ai1, Block.cloth.blockID, 12) == 2 && ai[1][1] == Block.blockGold.blockID && ai[1][2] == Block.cloth.blockID && ai1[1][2] == 0) + { + delBlocks(world, i, j, k, l, ai, i1); + EntityGSpawn entitygspawn3 = new EntityGSpawn(world); + entitygspawn3.setPosition(i, j, k); + entitygspawn3.skin = "http://s3.amazonaws.com/MinecraftSkins/Notch.png"; + world.spawnEntityInWorld(entitygspawn3); + mod_Golems.trigger("king"); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + return true; + } + + if (isAll(ai, ai1, Block.blockClay.blockID, -1) && i1 == 3 && countBlock(ai, ai1, Block.blockClay.blockID, -1) == 2 && j1 >= 1) + { + EntityZombie entityzombie = new EntityZombie(world); + entityzombie.setPositionAndRotation((double) i + 0.5D, (j - i1) + 1, (double) k + 0.5D, (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F, 0.0F); + world.spawnEntityInWorld(entityzombie); + delBlocks(world, i, j, k, l, ai, i1); + world.spawnParticle("hugeexplosion", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + mod_Golems.trigger("zombie"); + return true; + } + }*/ + return false; + } + + private void delBlocks (World world, int i, int j, int k, int l, int ai[][], int i1) + { + for (int j1 = -1; j1 <= 1; j1++) + { + for (int k1 = 0; k1 < i1; k1++) + { + if (k1 == 0 && j1 != 0 || ai[j1 + 1][(k1 - i1) + 3] == 0) + { + continue; + } + if (l == 0) + { + world.setBlock(i - j1, j - k1, k, 0); + } + if (l == 1) + { + world.setBlock(i, j - k1, k - j1, 0); + } + if (l == 2) + { + world.setBlock(i + j1, j - k1, k, 0); + } + if (l == 3) + { + world.setBlock(i, j - k1, k + j1, 0); + } + } + } + + if (i1 == 2 && (ai[0][1] != 0 || ai[2][1] != 0)) + { + if (l == 0) + { + if (ai[0][1] != 0) + { + world.setBlock(i + 1, j, k, 0); + } + if (ai[2][1] != 0) + { + world.setBlock(i - 1, j, k, 0); + } + } + if (l == 1) + { + if (ai[0][1] != 0) + { + world.setBlock(i, j, k + 1, 0); + } + if (ai[2][1] != 0) + { + world.setBlock(i, j, k - 1, 0); + } + } + if (l == 2) + { + if (ai[0][1] != 0) + { + world.setBlock(i - 1, j, k, 0); + } + if (ai[2][1] != 0) + { + world.setBlock(i + 1, j, k, 0); + } + } + if (l == 3) + { + if (ai[0][1] != 0) + { + world.setBlock(i, j, k - 1, 0); + } + if (ai[2][1] != 0) + { + world.setBlock(i, j, k + 1, 0); + } + } + } + } + + private boolean hasBlock (int ai[][], int ai1[][], int i, int j) + { + for (int k = 0; k < 3; k++) + { + for (int l = 0; l < 3; l++) + { + if (ai[k][l] == i && (ai1[k][l] == j || j == -1)) + { + return true; + } + } + } + + return false; + } + + private void replBlocks (World world, int i, int j, int k, int l, int ai[][], ItemStack aitemstack[][], int i1) + { + for (int j1 = -1; j1 <= 1; j1++) + { + for (int k1 = 0; k1 < i1; k1++) + { + if (aitemstack[j1 + 1][(k1 - i1) + 3] == null) + { + aitemstack[j1 + 1][(k1 - i1) + 3] = new ItemStack(0, 0, 0); + } + if (k1 == 0 && j1 != 0 || ai[j1 + 1][(k1 - i1) + 3] == 0) + { + continue; + } + if (l == 0) + { + world.setBlock(i - j1, j - k1, k, aitemstack[j1 + 1][(k1 - i1) + 3].itemID, aitemstack[j1 + 1][(k1 - i1) + 3].getItemDamage(), 3); + } + if (l == 1) + { + world.setBlock(i, j - k1, k - j1, aitemstack[j1 + 1][(k1 - i1) + 3].itemID, aitemstack[j1 + 1][(k1 - i1) + 3].getItemDamage(), 3); + } + if (l == 2) + { + world.setBlock(i + j1, j - k1, k, aitemstack[j1 + 1][(k1 - i1) + 3].itemID, aitemstack[j1 + 1][(k1 - i1) + 3].getItemDamage(), 3); + } + if (l == 3) + { + world.setBlock(i, j - k1, k + j1, aitemstack[j1 + 1][(k1 - i1) + 3].itemID, aitemstack[j1 + 1][(k1 - i1) + 3].getItemDamage(), 3); + } + } + } + + if (i1 == 2 && (ai[0][1] != 0 || ai[2][1] != 0)) + { + if (l == 0) + { + if (ai[0][1] != 0) + { + world.setBlock(i + 1, j, k, aitemstack[0][1].itemID, aitemstack[0][1].getItemDamage(), 3); + } + if (ai[2][1] != 0) + { + world.setBlock(i - 1, j, k, aitemstack[2][1].itemID, aitemstack[2][1].getItemDamage(), 3); + } + } + if (l == 1) + { + if (ai[0][1] != 0) + { + world.setBlock(i, j, k + 1, aitemstack[0][1].itemID, aitemstack[0][1].getItemDamage(), 3); + } + if (ai[2][1] != 0) + { + world.setBlock(i, j, k - 1, aitemstack[2][1].itemID, aitemstack[2][1].getItemDamage(), 3); + } + } + if (l == 2) + { + if (ai[0][1] != 0) + { + world.setBlock(i - 1, j, k, aitemstack[0][1].itemID, aitemstack[0][1].getItemDamage(), 3); + } + if (ai[2][1] != 0) + { + world.setBlock(i + 1, j, k, aitemstack[2][1].itemID, aitemstack[2][1].getItemDamage(), 3); + } + } + if (l == 3) + { + if (ai[0][1] != 0) + { + world.setBlock(i, j, k - 1, aitemstack[0][1].itemID, aitemstack[0][1].getItemDamage(), 3); + } + if (ai[2][1] != 0) + { + world.setBlock(i, j, k + 1, aitemstack[2][1].itemID, aitemstack[2][1].getItemDamage(), 3); + } + } + } + } + + private void replEntity (World world, int i, int j, int k, int l, int ai[][], Entity aentity[][], int i1) + { + for (int j1 = -1; j1 <= 1; j1++) + { + for (int k1 = 0; k1 < i1; k1++) + { + if (k1 == 0 && j1 != 0) + { + continue; + } + Entity entity8 = aentity[j1 + 1][(k1 - i1) + 3]; + if (ai[j1 + 1][(k1 - i1) + 3] == 0) + { + if (entity8 != null) + { + entity8.setDead(); + } + continue; + } + if (l == 0) + { + world.setBlock(i - j1, j - k1, k, 0); + if (entity8 != null) + { + entity8.setPosition(((float) i - (float) j1) + 0.5F, ((float) j - (float) k1) + 0.5F, (float) k + 0.5F); + world.spawnEntityInWorld(entity8); + ai[j1 + 1][(k1 - i1) + 3] = 0; + } + } + if (l == 1) + { + world.setBlock(i, j - k1, k - j1, 0); + if (entity8 != null) + { + entity8.setPosition(((float) i - (float) j1) + 0.5F, ((float) j - (float) k1) + 0.5F, (float) k + 0.5F); + world.spawnEntityInWorld(entity8); + ai[j1 + 1][(k1 - i1) + 3] = 0; + } + } + if (l == 2) + { + world.setBlock(i + j1, j - k1, k, 0); + if (entity8 != null) + { + entity8.setPosition(((float) i - (float) j1) + 0.5F, ((float) j - (float) k1) + 0.5F, (float) k + 0.5F); + world.spawnEntityInWorld(entity8); + ai[j1 + 1][(k1 - i1) + 3] = 0; + } + } + if (l != 3) + { + continue; + } + world.setBlock(i, j - k1, k + j1, 0); + if (entity8 != null) + { + entity8.setPosition(((float) i - (float) j1) + 0.5F, ((float) j - (float) k1) + 0.5F, (float) k + 0.5F); + world.spawnEntityInWorld(entity8); + ai[j1 + 1][(k1 - i1) + 3] = 0; + } + } + } + + if (i1 == 2 && (ai[0][1] != 0 || ai[2][1] != 0)) + { + Object obj = null; + if (l == 0) + { + if (ai[0][1] != 0) + { + world.setBlock(i + 1, j, k, 0); + Entity entity; + if ((entity = aentity[0][1]) != null) + { + entity.setPosition((float) i + 1.0F + 0.5F, (float) j + 0.5F, (float) k + 0.5F); + world.spawnEntityInWorld(aentity[0][1]); + ai[2][1] = 0; + } + } + else if (aentity[0][1] != null) + { + aentity[0][1].setDead(); + } + if (ai[2][1] != 0) + { + world.setBlock(i - 1, j, k, 0); + Entity entity1; + if ((entity1 = aentity[2][1]) != null) + { + entity1.setPosition(((float) i - 1.0F) + 0.5F, (float) j + 0.5F, (float) k + 0.5F); + world.spawnEntityInWorld(aentity[2][1]); + ai[2][1] = 0; + } + } + else if (aentity[2][1] != null) + { + aentity[2][1].setDead(); + } + } + if (l == 1) + { + if (ai[0][1] != 0) + { + world.setBlock(i, j, k + 1, 0); + Entity entity2; + if ((entity2 = aentity[0][1]) != null) + { + entity2.setPosition((float) i + 0.5F, (float) j + 0.5F, (float) k + 1.0F + 0.5F); + world.spawnEntityInWorld(aentity[0][1]); + ai[2][1] = 0; + } + } + else if (aentity[0][1] != null) + { + aentity[0][1].setDead(); + } + if (ai[2][1] != 0) + { + world.setBlock(i, j, k - 1, 0); + Entity entity3; + if ((entity3 = aentity[2][1]) != null) + { + entity3.setPosition((float) i + 0.5F, (float) j + 0.5F, ((float) k - 1.0F) + 0.5F); + world.spawnEntityInWorld(aentity[2][1]); + ai[2][1] = 0; + } + } + else if (aentity[2][1] != null) + { + aentity[2][1].setDead(); + } + } + if (l == 2) + { + if (ai[0][1] != 0) + { + world.setBlock(i - 1, j, k, 0); + Entity entity4; + if ((entity4 = aentity[0][1]) != null) + { + entity4.setPosition(((float) i - 1.0F) + 0.5F, (float) j + 0.5F, (float) k + 0.5F); + world.spawnEntityInWorld(aentity[0][1]); + ai[2][1] = 0; + } + } + else if (aentity[0][1] != null) + { + aentity[0][1].setDead(); + } + if (ai[2][1] != 0) + { + world.setBlock(i + 1, j, k, 0); + Entity entity5; + if ((entity5 = aentity[2][1]) != null) + { + entity5.setPosition((float) i + 1.0F + 0.5F, (float) j + 0.5F, (float) k + 0.5F); + world.spawnEntityInWorld(aentity[2][1]); + ai[2][1] = 0; + } + } + else if (aentity[2][1] != null) + { + aentity[2][1].setDead(); + } + } + if (l == 3) + { + if (ai[0][1] != 0) + { + world.setBlock(i, j, k - 1, 0); + Entity entity6; + if ((entity6 = aentity[0][1]) != null) + { + entity6.setPosition((float) i + 0.5F, (float) j + 0.5F, (float) k + 1.0F + 0.5F); + world.spawnEntityInWorld(aentity[0][1]); + } + } + else if (aentity[0][1] != null) + { + aentity[0][1].setDead(); + } + if (ai[2][1] != 0) + { + world.setBlock(i, j, k + 1, 0); + Entity entity7; + if ((entity7 = aentity[2][1]) != null) + { + entity7.setPosition((float) i + 0.5F, (float) j + 0.5F, (float) k + 1.0F + 0.5F); + world.spawnEntityInWorld(aentity[2][1]); + } + } + else if (aentity[2][1] != null) + { + aentity[2][1].setDead(); + } + } + } + } + + private int updateBody (int ai[][], int ai1[][]) + { + for (int i = 0; ai[1][2] == 0 && i < 3;) + { + i++; + for (int i1 = 0; i1 < 3; i1++) + { + int j2 = ai[i1][0]; + int l2 = ai[i1][1]; + ai[i1][0] = ai[i1][2]; + ai[i1][1] = j2; + ai[i1][2] = l2; + } + + int j1 = 0; + while (j1 < 3) + { + int k2 = ai1[j1][0]; + int i3 = ai1[j1][1]; + ai1[j1][0] = ai1[j1][2]; + ai1[j1][1] = k2; + ai1[j1][2] = i3; + j1++; + } + } + + if (ai[1][1] == 0) + { + for (int j = 0; j < 3; j++) + { + int k1 = ai[j][0]; + ai[j][0] = ai[j][1]; + ai[j][1] = k1; + } + + for (int k = 0; k < 3; k++) + { + int l1 = ai1[k][0]; + ai1[k][0] = ai1[k][1]; + ai1[k][1] = l1; + } + } + int l = 0; + for (int i2 = 0; i2 < 3; i2++) + { + if (ai[1][i2] != 0) + { + l = 3 - i2; + } + } + + if (l == 1) + { + ai[0][1] = 0; + ai[2][1] = 0; + ai1[0][1] = 0; + ai1[2][1] = 0; + } + return 0; + } + + private boolean isAll (int ai[][], int ai1[][], int i, int j) + { + boolean flag = false; + for (int k = 0; k < 3; k++) + { + for (int l = 0; l < 3; l++) + { + if (ai[k][l] != i && ai[k][l] != 0 && ai[k][l] != this.blockID && (ai1[k][l] != j || j == -1)) + { + return false; + } + if (ai[k][l] == i && (ai1[k][l] == j || j == -1)) + { + flag = true; + } + } + } + + return flag; + } + + private int countBlock (int ai[][], int ai1[][], int i, int j) + { + int k = 0; + for (int l = 0; l < 3; l++) + { + for (int i1 = 0; i1 < 3; i1++) + { + if (ai[l][i1] == i && (ai1[l][i1] == j || j == -1)) + { + k++; + } + } + } + + return k; + } +} diff --git a/tconstruct/blocks/GolemPedestalBlock.java b/tconstruct/blocks/GolemPedestalBlock.java new file mode 100644 index 00000000..a2d6b2c6 --- /dev/null +++ b/tconstruct/blocks/GolemPedestalBlock.java @@ -0,0 +1,146 @@ +package tconstruct.blocks; + +import java.util.Random; + +import tconstruct.blocks.logic.GolemPedestalLogic; +import tconstruct.library.blocks.InventoryBlock; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class GolemPedestalBlock extends InventoryBlock +{ + /*public static int texTop; + public static int texTopp; + public static int texSide; + public static int texBottom;*/ + + public GolemPedestalBlock(int i) + { + super(i, Material.wood); + /*texTop = ModLoader.addOverride("/terrain.png", "/GGE/pedestaltop.png"); + texTopp = ModLoader.addOverride("/terrain.png", "/GGE/pedestaltopp.png"); + texSide = ModLoader.addOverride("/terrain.png", "/GGE/pedestalside.png"); + texBottom = ModLoader.addOverride("/terrain.png", "/GGE/pedestalbottom.png");*/ + } + + /*public int getIcon(int i, int j) + { + if (i == 1) + { + return j == 0 ? texTop : texTopp; + } + if (i == 0) + { + return texBottom; + } + if (i == 2 || i == 4) + { + return texSide; + } + else + { + return texSide; + } + }*/ + + /*public int idDropped(int i, Random random, int j) + { + return super.idDropped(i, random, j); + }*/ + + /*public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) + { + super.onBlockPlacedBy(world, i, j, k, entityliving); + ItemStack itemstack = ((EntityPlayer)entityliving).getCurrentEquippedItem(); + world.setBlockMetadata(i, j, k, itemstack.getItemDamage()); + }*/ + + public void onBlockRemoval (World world, int i, int j, int k) + { + Random random = new Random(); + GolemPedestalLogic tileentitygolempedestal = (GolemPedestalLogic) world.getBlockTileEntity(i, j, k); + if (tileentitygolempedestal != null) + { + label0: for (int l = 0; l < tileentitygolempedestal.getSizeInventory(); l++) + { + ItemStack itemstack = tileentitygolempedestal.getStackInSlot(l); + if (itemstack == null) + { + continue; + } + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + float f2 = random.nextFloat() * 0.8F + 0.1F; + do + { + if (itemstack.stackSize <= 0) + { + continue label0; + } + int i1 = random.nextInt(21) + 10; + if (i1 > itemstack.stackSize) + { + i1 = itemstack.stackSize; + } + itemstack.stackSize -= i1; + EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + world.spawnEntityInWorld(entityitem); + } while (true); + } + } + //super.onBlockRemoval(world, i, j, k); + } + + public boolean blockActivated (World world, int i, int j, int k, EntityPlayer entityplayer) + { + /*ItemStack itemstack = entityplayer.getCurrentEquippedItem(); + if (world.isRemote) + { + return true; + } + if (itemstack == null || itemstack != null && (itemstack.itemID >= 256 || itemstack.itemID == 0 || itemstack.itemID == Block.slowSand.blockID)) + { + ModLoader.openGUI(entityplayer, new GuiGolemPedestal(entityplayer.inventory, world, i, j, k)); + return true; + } + else + { + return false; + }*/ + return false; + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + return new GolemPedestalLogic(); + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getModInstance () + { + return null; + } + + @Override + public String[] getTextureNames () + { + return null; + } +} diff --git a/tconstruct/blocks/GravelOre.java b/tconstruct/blocks/GravelOre.java new file mode 100644 index 00000000..17f87a45 --- /dev/null +++ b/tconstruct/blocks/GravelOre.java @@ -0,0 +1,77 @@ +package tconstruct.blocks; + +import java.util.List; +import java.util.Random; + +import tconstruct.library.TConstructRegistry; + + +import net.minecraft.block.BlockSand; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.world.World; + +public class GravelOre extends BlockSand +{ + public String[] textureNames = new String[] { "iron", "gold", "copper", "tin", "aluminum", "cobalt" }; + public Icon[] icons; + + public GravelOre(int id) + { + super(id, Material.craftedSnow); + this.setCreativeTab(TConstructRegistry.blockTab); + this.setStepSound(soundGravelFootstep); + } + + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:ore_" + textureNames[i] + "_gravel"); + } + } + + @Override + public Icon getIcon (int side, int meta) + { + return icons[meta]; + } + + public float getBlockHardness (World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 5) + return 10f; + else + return 3f; + } + + @Override + public int damageDropped (int meta) + { + /*if (meta == 1) + return 0;*/ + return meta; + } + + public int idDropped (int par1, Random par2Random, int par3) + { + /*if (par1 == 1) + return Item.goldNugget.itemID;*/ + return this.blockID; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 6; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } +} diff --git a/tconstruct/blocks/LavaTankBlock.java b/tconstruct/blocks/LavaTankBlock.java new file mode 100644 index 00000000..81d9ecba --- /dev/null +++ b/tconstruct/blocks/LavaTankBlock.java @@ -0,0 +1,246 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.blocks.logic.LavaTankLogic; +import tconstruct.client.block.TankRender; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.util.IServantLogic; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidTank; + +public class LavaTankBlock extends BlockContainer +{ + public Icon[] icons; + + public LavaTankBlock(int id) + { + super(id, Material.rock); + setHardness(12); + setCreativeTab(TConstructRegistry.blockTab); + setUnlocalizedName("TConstruct.LavaTank"); + setStepSound(Block.soundGlassFootstep); + } + + public String[] getTextureNames () + { + String[] textureNames = { "lavatank_side", "lavatank_top", "searedgague_top", "searedgague_side", "searedgague_bottom", "searedwindow_top", "searedwindow_side", "searedwindow_bottom" }; + + return textureNames; + } + + public void registerIcons (IconRegister iconRegister) + { + String[] textureNames = getTextureNames(); + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]); + } + } + + @Override + public int getRenderBlockPass () + { + return 1; + } + + @Override + public boolean isOpaqueCube () + { + return false; + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side) + { + //if (side == 0 && world.getBlockMetadata(x, y, z) == 0) + //return super.shouldSideBeRendered(world, x, y, z, side); + int bID = world.getBlockId(x, y, z); + return bID == this.blockID ? false : super.shouldSideBeRendered(world, x, y, z, side); + //return true; + } + + @Override + public int getLightValue (IBlockAccess world, int x, int y, int z) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + if (logic != null && logic instanceof LavaTankLogic) + return ((LavaTankLogic) logic).getBrightness(); + return 0; + } + + /*@Override + public int getRenderBlockPass() + { + return 1; + }*/ + + @Override + public int getRenderType () + { + return TankRender.tankModelID; + } + + public Icon getIcon (int side, int meta) + { + if (meta == 0) + { + if (side == 0 || side == 1) + { + return icons[1]; + } + else + { + return icons[0]; + } + } + else + { + return icons[meta * 3 + getTextureIndex(side) - 1]; + } + } + + public int getTextureIndex (int side) + { + if (side == 0) + return 2; + if (side == 1) + return 0; + + return 1; + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + return new LavaTankLogic(); + } + + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ) + { + ItemStack heldItem = player.inventory.getCurrentItem(); + if (heldItem != null) + { + FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(player.getCurrentEquippedItem()); + LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z); + if (liquid != null) + { + int amount = logic.fill(ForgeDirection.UNKNOWN, liquid, false); + if (amount == liquid.amount) + { + logic.fill(ForgeDirection.UNKNOWN, liquid, true); + if (!player.capabilities.isCreativeMode) + player.inventory.setInventorySlotContents(player.inventory.currentItem, consumeItem(heldItem)); + return true; + } + else + return true; + } + else if (FluidContainerRegistry.isBucket(heldItem)) + { + FluidTankInfo[] tanks = logic.getTankInfo(ForgeDirection.UNKNOWN); + FluidStack fillFluid = tanks[0].fluid;//getFluid(); + ItemStack fillStack = FluidContainerRegistry.fillFluidContainer(fillFluid, heldItem); + if (fillStack != null) + { + logic.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getFluidForFilledItem(fillStack).amount, true); + if (!player.capabilities.isCreativeMode) + { + if (heldItem.stackSize == 1) + { + player.inventory.setInventorySlotContents(player.inventory.currentItem, fillStack); + } + else + { + player.inventory.setInventorySlotContents(player.inventory.currentItem, consumeItem(heldItem)); + + if (!player.inventory.addItemStackToInventory(fillStack)) + { + player.dropPlayerItem(fillStack); + } + } + } + return true; + } + else + { + return true; + } + } + } + + return false; + } + + public static ItemStack consumeItem (ItemStack stack) + { + if (stack.stackSize == 1) + { + if (stack.getItem().hasContainerItem()) + return stack.getItem().getContainerItemStack(stack); + else + return null; + } + else + { + stack.splitStack(1); + + return stack; + } + } + + @Override + public TileEntity createNewTileEntity (World world) + { + return createTileEntity(world, 0); + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 3; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } + + /* Data */ + public int damageDropped (int meta) + { + return meta; + } + + /* Updates */ + public void onNeighborBlockChange (World world, int x, int y, int z, int nBlockID) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + if (logic instanceof IServantLogic) + { + ((IServantLogic) logic).notifyMasterOfChange(); + } + } +} diff --git a/tconstruct/blocks/LightCrystalBase.java b/tconstruct/blocks/LightCrystalBase.java new file mode 100644 index 00000000..9c59937e --- /dev/null +++ b/tconstruct/blocks/LightCrystalBase.java @@ -0,0 +1,103 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.client.block.CrystalBlockRender; +import tconstruct.common.TContent; +import tconstruct.crystal.TheftValueTracker; +import tconstruct.library.TConstructRegistry; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.world.World; + +public class LightCrystalBase extends Block +{ + String[] textureNames = { "amber_crystal" }; + Icon[] icons; + + public LightCrystalBase(int id) + { + super(id, Material.glass); + this.setCreativeTab(TConstructRegistry.blockTab); + } + + @Override + public Icon getIcon (int side, int meta) + { + if (meta < 5) + return Block.glowStone.getIcon(side, meta); + if (meta < 10) + return Block.blockNetherQuartz.getIcon(side, 1); + return icons[0]; + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public boolean isOpaqueCube () + { + return false; + } + + @Override + public int getRenderType () + { + return CrystalBlockRender.model; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 15; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } + + @Override + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]); + } + } + + @Override + public void breakBlock (World world, int x, int y, int z, int par5, int meta) + { + switch (meta % 5) + { + case 0: + case 4: + TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -10); + break; + case 1: + TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -20); + break; + case 2: + TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -35); + break; + case 3: + TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -60); + break; + } + + Block block = Block.blocksList[world.getBlockId(x, y - 1, z)]; + if (block == TContent.aggregator) + { + ((Aggregator) block).updateCrystalValue(world, x, y - 1, z); + } + } +} diff --git a/tconstruct/blocks/LiquidMetalFinite.java b/tconstruct/blocks/LiquidMetalFinite.java new file mode 100644 index 00000000..8d04c079 --- /dev/null +++ b/tconstruct/blocks/LiquidMetalFinite.java @@ -0,0 +1,57 @@ +package tconstruct.blocks; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.util.DamageSource; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidFinite; +import net.minecraftforge.fluids.Fluid; +import tconstruct.common.TContent; +import tconstruct.library.TConstructRegistry; + +public class LiquidMetalFinite extends BlockFluidFinite +{ + String texture; + public Icon stillIcon; + public Icon flowIcon; + + public LiquidMetalFinite(int id, Fluid fluid, String texture) + { + super(id, fluid, TContent.liquidMetal); + this.texture = texture; + this.setCreativeTab(TConstructRegistry.blockTab); + } + + @Override + public void registerIcons (IconRegister iconRegister) + { + stillIcon = iconRegister.registerIcon("tinker:" + texture); + flowIcon = iconRegister.registerIcon("tinker:" + texture + "_flow"); + } + + @Override + public Icon getIcon (int side, int meta) + { + if (side == 0 || side == 1) + return stillIcon; + return flowIcon; + } + + @Override + public void onEntityCollidedWithBlock (World par1World, int x, int y, int z, Entity entity) + { + if (entity instanceof EntityLivingBase) + { + entity.motionX *= 0.4D; + entity.motionZ *= 0.4D; + } + if (!(entity instanceof EntityItem) && !entity.isImmuneToFire()) + { + entity.attackEntityFrom(DamageSource.lava, 4); + entity.setFire(15); + } + } +} diff --git a/tconstruct/blocks/MetalOre.java b/tconstruct/blocks/MetalOre.java new file mode 100644 index 00000000..42f3009d --- /dev/null +++ b/tconstruct/blocks/MetalOre.java @@ -0,0 +1,35 @@ +package tconstruct.blocks; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class MetalOre extends TConstructBlock +{ + public MetalOre(int id, Material material, float hardness, String[] tex) + { + super(id, material, hardness, tex); + } + + public float getBlockHardness (World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta <= 2) + return 10f; + else + return 3f; + //return this.blockHardness; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 1; iter < 6; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } +} diff --git a/tconstruct/blocks/MultiBrick.java b/tconstruct/blocks/MultiBrick.java new file mode 100644 index 00000000..92c9494c --- /dev/null +++ b/tconstruct/blocks/MultiBrick.java @@ -0,0 +1,159 @@ +package tconstruct.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MultiBrick extends TConstructBlock +{ + static String blockTextures[] = { "brick_obsidian", "brick_sandstone", "brick_netherrack", "brick_stone_refined", "brick_iron", "brick_gold", "brick_lapis", "brick_diamond", "brick_redstone", + "brick_bone", "brick_slime", "brick_blueslime", "brick_endstone", "brick_obsidian_ingot" }; + + public MultiBrick(int id) + { + super(id, Material.rock, 3f, blockTextures); + } + + @Override + public float getBlockHardness (World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + switch (meta) + { + case 0: + return Block.obsidian.getBlockHardness(world, x, y, z); + case 1: + return Block.sandStone.getBlockHardness(world, x, y, z); + case 2: + return Block.netherrack.getBlockHardness(world, x, y, z); + case 3: + return Block.stone.getBlockHardness(world, x, y, z); + case 4: + return Block.blockIron.getBlockHardness(world, x, y, z); + case 5: + return Block.blockGold.getBlockHardness(world, x, y, z); + case 6: + return Block.blockLapis.getBlockHardness(world, x, y, z); + case 7: + return Block.blockDiamond.getBlockHardness(world, x, y, z); + case 8: + return Block.blockRedstone.getBlockHardness(world, x, y, z); + case 9: + return 1.0F; + case 10: + return 1.5F; + case 11: + return 1.5F; + case 12: + return Block.whiteStone.getBlockHardness(world, x, y, z); + case 13: + return Block.obsidian.getBlockHardness(world, x, y, z); + default: + return blockHardness; + } + } + + public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) + { + int meta = world.getBlockMetadata(x, y, z); + switch (meta) + { + case 0: + return Block.obsidian.getExplosionResistance(entity); + case 1: + return Block.sandStone.getExplosionResistance(entity); + case 2: + return Block.netherrack.getExplosionResistance(entity); + case 3: + return Block.stone.getExplosionResistance(entity); + case 4: + return Block.blockIron.getExplosionResistance(entity); + case 5: + return Block.blockGold.getExplosionResistance(entity); + case 6: + return Block.blockLapis.getExplosionResistance(entity); + case 7: + return Block.blockDiamond.getExplosionResistance(entity); + case 8: + return Block.blockRedstone.getExplosionResistance(entity); + case 9: + return 1.0F; + case 10: + return 1.5F; + case 11: + return 1.5F; + case 12: + return Block.whiteStone.getExplosionResistance(entity); + case 13: + return Block.obsidian.getExplosionResistance(entity); + default: + return getExplosionResistance(entity); + } + } + + @Override + public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 10 || meta == 11) + { + if (entity.motionY < 0) + entity.motionY *= -1.2F; + entity.fallDistance = 0; + } + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 10 || meta == 11) + return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D); + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } + + /*@Override + public int getRenderType () + { + return BrickRender.model; + }*/ + + @Override + public boolean isBlockNormalCube (World world, int x, int y, int z) + { + return world.getBlockMetadata(x, y, z) != 8; + } + + @Override + public boolean canProvidePower () + { + return true; + } + + @Override + public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side) + { + if (world.getBlockMetadata(x, y, z) == 8) + return 4; + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]); + } + } +} diff --git a/tconstruct/blocks/MultiBrickFancy.java b/tconstruct/blocks/MultiBrickFancy.java new file mode 100644 index 00000000..a8ed4084 --- /dev/null +++ b/tconstruct/blocks/MultiBrickFancy.java @@ -0,0 +1,164 @@ +package tconstruct.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MultiBrickFancy extends TConstructBlock +{ + static String blockTextures[] = { "fancybrick_obsidian", "fancybrick_sandstone", "fancybrick_netherrack", "fancybrick_stone_refined", "fancybrick_iron", "fancybrick_gold", "fancybrick_lapis", + "fancybrick_diamond", "fancybrick_redstone", "fancybrick_bone", "fancybrick_slime", "fancybrick_blueslime", "fancybrick_endstone", "fancybrick_obsidian_ingot", "fancybrick_stone", + "road_stone" }; + + public MultiBrickFancy(int id) + { + super(id, Material.rock, 3f, blockTextures); + } + + @Override + public float getBlockHardness (World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + switch (meta) + { + case 0: + return Block.obsidian.getBlockHardness(world, x, y, z); + case 1: + return Block.sandStone.getBlockHardness(world, x, y, z); + case 2: + return Block.netherrack.getBlockHardness(world, x, y, z); + case 4: + return Block.blockIron.getBlockHardness(world, x, y, z); + case 5: + return Block.blockGold.getBlockHardness(world, x, y, z); + case 6: + return Block.blockLapis.getBlockHardness(world, x, y, z); + case 7: + return Block.blockDiamond.getBlockHardness(world, x, y, z); + case 8: + return Block.blockRedstone.getBlockHardness(world, x, y, z); + case 9: + return 1.0F; + case 10: + return 1.5F; + case 11: + return 1.5F; + case 12: + return Block.whiteStone.getBlockHardness(world, x, y, z); + case 13: + return Block.obsidian.getBlockHardness(world, x, y, z); + case 3: + case 14: + case 15: + return Block.stone.getBlockHardness(world, x, y, z); + default: + return blockHardness; + } + } + + public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) + { + int meta = world.getBlockMetadata(x, y, z); + switch (meta) + { + case 0: + return Block.obsidian.getExplosionResistance(entity); + case 1: + return Block.sandStone.getExplosionResistance(entity); + case 2: + return Block.netherrack.getExplosionResistance(entity); + case 4: + return Block.blockIron.getExplosionResistance(entity); + case 5: + return Block.blockGold.getExplosionResistance(entity); + case 6: + return Block.blockLapis.getExplosionResistance(entity); + case 7: + return Block.blockDiamond.getExplosionResistance(entity); + case 8: + return Block.blockRedstone.getExplosionResistance(entity); + case 9: + return 1.0F; + case 10: + return 1.5F; + case 11: + return 1.5F; + case 12: + return Block.whiteStone.getExplosionResistance(entity); + case 13: + return Block.obsidian.getExplosionResistance(entity); + case 3: + case 14: + case 15: + return Block.stone.getExplosionResistance(entity); + default: + return getExplosionResistance(entity); + } + } + + @Override + public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 10 || meta == 11) + { + if (entity.motionY < 0) + entity.motionY *= -1.2F; + entity.fallDistance = 0; + } + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 10 || meta == 11) + return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D); + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } + + /*@Override + public int getRenderType () + { + return BrickRender.model; + }*/ + + @Override + public boolean isBlockNormalCube (World world, int x, int y, int z) + { + return world.getBlockMetadata(x, y, z) != 8; + } + + @Override + public boolean canProvidePower () + { + return false; + } + + @Override + public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side) + { + if (world.getBlockMetadata(x, y, z) == 8) + return 4; + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]); + } + } +} diff --git a/tconstruct/blocks/OreberryBush.java b/tconstruct/blocks/OreberryBush.java new file mode 100644 index 00000000..7cb41326 --- /dev/null +++ b/tconstruct/blocks/OreberryBush.java @@ -0,0 +1,350 @@ +package tconstruct.blocks; + +import java.util.List; +import java.util.Random; + +import tconstruct.client.block.OreberryRender; +import tconstruct.common.TContent; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.AbilityHelper; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockLeavesBase; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.IPlantable; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class OreberryBush extends BlockLeavesBase implements IPlantable +{ + Random random; + public Icon[] fastIcons; + public Icon[] fancyIcons; + public String[] textureNames; + public String[] oreTypes; + public int itemMeat; + private int subitems; + + public OreberryBush(int id, String[] textureNames, int meta, int sub, String[] oreTypes) + { + super(id, Material.leaves, false); + this.textureNames = textureNames; + this.itemMeat = meta; + this.subitems = sub; + this.oreTypes = oreTypes; + this.setTickRandomly(true); + random = new Random(); + this.setHardness(0.3F); + this.setStepSound(Block.soundMetalFootstep); + this.setCreativeTab(TConstructRegistry.blockTab); + } + + /* Berries show up at meta 12-15 */ + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons (IconRegister iconRegister) + { + this.fastIcons = new Icon[textureNames.length]; + this.fancyIcons = new Icon[textureNames.length]; + + for (int i = 0; i < this.fastIcons.length; i++) + { + if (textureNames[i] != "") + { + this.fastIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fast"); + this.fancyIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fancy"); + } + } + } + + @Override + public Icon getIcon (int side, int metadata) + { + if (graphicsLevel) + { + if (metadata < 12) + { + return fancyIcons[metadata % 4]; + } + else + { + return fancyIcons[metadata % 4 + 4]; + } + } + else + { + if (metadata < 12) + { + return fastIcons[metadata % 4]; + } + else + { + return fastIcons[metadata % 4 + 4]; + } + } + } + + /* Bushes are stored by size then type */ + @Override + public int damageDropped (int metadata) + { + return metadata % 4; + } + + /* The following methods define a berry bush's size depending on metadata */ + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) + { + int l = world.getBlockMetadata(x, y, z); + if (l < 4) + { + return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D); + } + else if (l < 8) + { + return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D); + } + else + { + return AxisAlignedBB.getBoundingBox(x + 0.0625, y, z + 0.0625, (double) x + 0.9375D, (double) y + 0.9375D, (double) z + 0.9375D); + } + } + + public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z) + { + int l = world.getBlockMetadata(x, y, z); + if (l < 4) + { + return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D); + } + else if (l < 8) + { + return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D); + } + else + { + return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 1.0D, (double) z + 1.0D); + } + } + + @Override + public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int x, int y, int z) + { + int md = iblockaccess.getBlockMetadata(x, y, z); + + float minX; + float minY = 0F; + float minZ; + float maxX; + float maxY; + float maxZ; + + if (md < 4) + { + minX = minZ = 0.25F; + maxX = maxZ = 0.75F; + maxY = 0.5F; + } + else + + if (md < 8) + { + minX = minZ = 0.125F; + maxX = maxZ = 0.875F; + maxY = 0.75F; + } + + else + { + minX = minZ = 0.0F; + maxX = maxZ = 1.0F; + maxY = 1.0F; + } + setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); + } + + /* Left-click harvests berries */ + @Override + public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player) + { + if (!world.isRemote) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta >= 12) + { + world.setBlock(x, y, z, blockID, meta - 4, 3); + AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.oreBerries, 1, meta % 4 + itemMeat)); + } + } + } + + /* Right-click harvests berries */ + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) + { + /*if (world.isRemote) + return false;*/ + + int meta = world.getBlockMetadata(x, y, z); + if (meta >= 12) + { + if (world.isRemote) + return true; + + world.setBlock(x, y, z, blockID, meta - 4, 3); + AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.oreBerries, 1, meta % 4 + itemMeat)); + return true; + } + + return false; + } + + /* Render logic */ + + @Override + public boolean isOpaqueCube () + { + return false; + } + + public void setGraphicsLevel (boolean flag) + { + graphicsLevel = flag; + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + public int getRenderType () + { + return OreberryRender.model; + } + + public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int x, int y, int z, int meta) + { + if (meta > 7 || graphicsLevel) + { + return super.shouldSideBeRendered(iblockaccess, x, y, z, meta); + } + else + { + return true; + } + } + + /* Bush growth */ + + @Override + public void updateTick (World world, int x, int y, int z, Random random1) + { + if (world.isRemote) + { + return; + } + + if (random1.nextInt(20) == 0)// && world.getBlockLightValue(x, y, z) <= 8) + { + if (world.getFullBlockLightValue(x, y, z) < 10) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta < 12) + { + world.setBlock(x, y, z, blockID, meta + 4, 3); + } + } + /*else if (meta < 8) + { + world.setBlock(x, y, z, blockID, meta + 4, 3); + }*/ + } + } + + public boolean canSustainPlant (World world, int x, int y, int z, ForgeDirection direction, IPlantable plant) + { + if (plant instanceof OreberryBush) + return (world.getBlockMetadata(x, y, z) > 7); + return super.canSustainPlant(world, x, y, z, direction, plant); + } + + public boolean canPlaceBlockAt (World world, int x, int y, int z) + { + if (world.getFullBlockLightValue(x, y, z) < 13) + return super.canPlaceBlockAt(world, x, y, z); + return false; + } + + /* Resistance to fire */ + + @Override + public int getFlammability (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) + { + return 0; + } + + @Override + public boolean isFlammable (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) + { + return false; + } + + @Override + public int getFireSpreadSpeed (World world, int x, int y, int z, int metadata, ForgeDirection face) + { + return 0; + } + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int var4 = 8; var4 < 8 + subitems; ++var4) + { + par3List.add(new ItemStack(par1, 1, var4)); + } + } + + @Override + public EnumPlantType getPlantType (World world, int x, int y, int z) + { + return EnumPlantType.Cave; + } + + @Override + public int getPlantID (World world, int x, int y, int z) + { + return this.blockID; + } + + @Override + public int getPlantMetadata (World world, int x, int y, int z) + { + return world.getBlockMetadata(x, y, z) - 4; + } + + @Override + public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity) + { + if (!(entity instanceof EntityItem)) + entity.attackEntityFrom(DamageSource.cactus, 1); + } +} diff --git a/tconstruct/blocks/OreberryBushEssence.java b/tconstruct/blocks/OreberryBushEssence.java new file mode 100644 index 00000000..8c08583d --- /dev/null +++ b/tconstruct/blocks/OreberryBushEssence.java @@ -0,0 +1,49 @@ +package tconstruct.blocks; + +import java.util.Random; + +import net.minecraft.world.World; +import net.minecraftforge.common.IPlantable; + +public class OreberryBushEssence extends OreberryBush implements IPlantable +{ + public OreberryBushEssence(int id, String[] textureNames, int meta, int sub, String[] oreTypes) + { + super(id, textureNames, meta, sub, oreTypes); + } + + /* Bush growth */ + + @Override + public void updateTick (World world, int x, int y, int z, Random random1) + { + if (world.isRemote) + { + return; + } + + if (random1.nextInt(20) == 0)// && world.getBlockLightValue(x, y, z) <= 8) + { + int meta = world.getBlockMetadata(x, y, z); + if (world.getFullBlockLightValue(x, y, z) < 10 || meta % 4 == 1) + { + if (meta < 12) + { + world.setBlock(x, y, z, blockID, meta + 4, 3); + } + } + /*else if (meta < 8) + { + world.setBlock(x, y, z, blockID, meta + 4, 3); + }*/ + } + } + + public boolean canPlaceBlockAt (World world, int x, int y, int z) + { + return true; + /*if (world.getFullBlockLightValue(x, y, z) < 13) + return super.canPlaceBlockAt(world, x, y, z); + return false;*/ + } +} diff --git a/tconstruct/blocks/PaneBase.java b/tconstruct/blocks/PaneBase.java new file mode 100644 index 00000000..2d79c44a --- /dev/null +++ b/tconstruct/blocks/PaneBase.java @@ -0,0 +1,187 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.client.block.PaneRender; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockPane; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class PaneBase extends Block +{ + public String[] textureNames; + public String folder; + public Icon[] icons; + public Icon[] sideIcons; + + public PaneBase(int id, Material material, String folder, String[] blockTextures) + { + super(id, material); + textureNames = blockTextures; + this.folder = folder; + } + + public boolean canConnectTo (int blockID) + { + Block block = Block.blocksList[blockID]; + return Block.opaqueCubeLookup[blockID] || block instanceof PaneBase || block instanceof BlockPane || blockID == Block.glass.blockID; + } + + public Icon getSideTextureIndex (int meta) + { + return sideIcons[meta]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + this.sideIcons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]); + this.sideIcons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i] + "_side"); + } + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon (int side, int meta) + { + return icons[meta]; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < textureNames.length; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } + + public boolean isOpaqueCube () + { + return false; + } + + public boolean renderAsNormalBlock () + { + return false; + } + + public int getRenderType () + { + return PaneRender.model; + } + + public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int i, int j, int k, int l) + { + int bID = iblockaccess.getBlockId(i, j, k); + if (Block.blocksList[bID] instanceof PaneBase || Block.blocksList[bID] instanceof BlockPane) + { + return false; + } + else + { + return super.shouldSideBeRendered(iblockaccess, i, j, k, l); + } + } + + @Override + public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity) + { + boolean south = canConnectTo(world.getBlockId(x, y, z - 1)); + boolean north = canConnectTo(world.getBlockId(x, y, z + 1)); + boolean east = canConnectTo(world.getBlockId(x - 1, y, z)); + boolean west = canConnectTo(world.getBlockId(x + 1, y, z)); + if (east && west || !east && !west && !south && !north) + { + setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F); + super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity); + } + else if (east && !west) + { + setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F); + super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity); + } + else if (!east && west) + { + setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F); + super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity); + } + if (south && north || !east && !west && !south && !north) + { + setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity); + } + else if (south && !north) + { + setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F); + super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity); + } + else if (!south && north) + { + setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity); + } + } + + public void setBlockBoundsForItemRender () + { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int i, int j, int k) + { + float f = 0.4375F; + float f1 = 0.5625F; + float f2 = 0.4375F; + float f3 = 0.5625F; + boolean flag = canConnectTo(iblockaccess.getBlockId(i, j, k - 1)); + boolean flag1 = canConnectTo(iblockaccess.getBlockId(i, j, k + 1)); + boolean flag2 = canConnectTo(iblockaccess.getBlockId(i - 1, j, k)); + boolean flag3 = canConnectTo(iblockaccess.getBlockId(i + 1, j, k)); + if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1) + { + f = 0.0F; + f1 = 1.0F; + } + else if (flag2 && !flag3) + { + f = 0.0F; + } + else if (!flag2 && flag3) + { + f1 = 1.0F; + } + if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1) + { + f2 = 0.0F; + f3 = 1.0F; + } + else if (flag && !flag1) + { + f2 = 0.0F; + } + else if (!flag && flag1) + { + f3 = 1.0F; + } + setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3); + } + +} diff --git a/tconstruct/blocks/RedstoneBallRepeater.java b/tconstruct/blocks/RedstoneBallRepeater.java new file mode 100644 index 00000000..4da274b6 --- /dev/null +++ b/tconstruct/blocks/RedstoneBallRepeater.java @@ -0,0 +1,217 @@ +package tconstruct.blocks; + +import java.util.Random; + +import tconstruct.client.block.BallRepeaterRender; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockRedstoneLogic; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Direction; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RedstoneBallRepeater extends BlockRedstoneLogic +{ + /** The offsets for the two torches in redstone repeater blocks. */ + public static final double[] repeaterTorchOffset = new double[] { -0.0625D, 0.0625D, 0.1875D, 0.3125D }; + + /** The states in which the redstone repeater blocks can be. */ + public static final int[] repeaterState = new int[] { 1, 2, 3, 4 }; + + @SideOnly(Side.CLIENT) + public static Icon field_94413_c; + @SideOnly(Side.CLIENT) + public static Icon field_94410_cO; + @SideOnly(Side.CLIENT) + public static Icon field_94411_cP; + @SideOnly(Side.CLIENT) + public static Icon field_94412_cQ; + + public RedstoneBallRepeater(int par1, boolean par2) + { + super(par1, par2); + //this.setCreativeTab(CreativeTabs.tabRedstone); + } + + /** + * Called upon block activation (right click on the block.) + */ + public boolean onBlockActivated (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) + { + int i1 = par1World.getBlockMetadata(par2, par3, par4); + int j1 = (i1 & 12) >> 2; + j1 = j1 + 1 << 2 & 12; + par1World.setBlockMetadataWithNotify(par2, par3, par4, j1 | i1 & 3, 3); + return true; + } + + public int func_94481_j_ (int par1) + { + return repeaterState[(par1 & 12) >> 2] * 2; + } + + public BlockRedstoneLogic func_94485_e () + { + return Block.redstoneRepeaterActive; + } + + public BlockRedstoneLogic func_94484_i () + { + return Block.redstoneRepeaterIdle; + } + + /** + * Returns the ID of the items to drop on destruction. + */ + public int idDropped (int par1, Random par2Random, int par3) + { + return this.blockID; + } + + @SideOnly(Side.CLIENT) + /** + * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) + */ + /*public int idPicked(World par1World, int par2, int par3, int par4) + { + return Item.redstoneRepeater.itemID; + }*/ + /** + * The type of render function that is called for this block + */ + public int getRenderType () + { + return BallRepeaterRender.model; + } + + public boolean func_94476_e (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + return this.func_94482_f(par1IBlockAccess, par2, par3, par4, par5) > 0; + } + + public boolean func_94477_d (int par1) + { + return isRedstoneRepeaterBlockID(par1); + } + + public static boolean isPowerProviderOrWire (IBlockAccess par0IBlockAccess, int par1, int par2, int par3, int par4) + { + int i1 = par0IBlockAccess.getBlockId(par1, par2, par3); + + if (i1 == Block.redstoneWire.blockID) + { + return true; + } + else if (i1 == 0) + { + return false; + } + else if (!Block.redstoneRepeaterIdle.func_94487_f(i1)) + { + return (Block.blocksList[i1] != null && Block.blocksList[i1].canConnectRedstone(par0IBlockAccess, par1, par2, par3, par4)); + } + else + { + int j1 = par0IBlockAccess.getBlockMetadata(par1, par2, par3); + return par4 == (j1 & 3) || par4 == Direction.rotateOpposite[j1 & 3]; + } + } + + @SideOnly(Side.CLIENT) + /** + * A randomly called display update to be able to add particles or other items for display + */ + public void randomDisplayTick (World par1World, int par2, int par3, int par4, Random par5Random) + { + if (this.isRepeaterPowered) + { + int l = par1World.getBlockMetadata(par2, par3, par4); + int i1 = getDirection(l); + double d0 = (double) ((float) par2 + 0.5F) + (double) (par5Random.nextFloat() - 0.5F) * 0.2D; + double d1 = (double) ((float) par3 + 0.4F) + (double) (par5Random.nextFloat() - 0.5F) * 0.2D; + double d2 = (double) ((float) par4 + 0.5F) + (double) (par5Random.nextFloat() - 0.5F) * 0.2D; + double d3 = 0.0D; + double d4 = 0.0D; + + if (par5Random.nextInt(2) == 0) + { + switch (i1) + { + case 0: + d4 = -0.3125D; + break; + case 1: + d3 = 0.3125D; + break; + case 2: + d4 = 0.3125D; + break; + case 3: + d3 = -0.3125D; + } + } + else + { + int j1 = (l & 12) >> 2; + + switch (i1) + { + case 0: + d4 = repeaterTorchOffset[j1]; + break; + case 1: + d3 = -repeaterTorchOffset[j1]; + break; + case 2: + d4 = -repeaterTorchOffset[j1]; + break; + case 3: + d3 = repeaterTorchOffset[j1]; + } + } + + par1World.spawnParticle("reddust", d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); + } + } + + public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4) + { + return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || par1World.getBlockId(par2, par3 - 1, par4) == Block.glowStone.blockID; + } + + /** + * ejects contained items into the world, and notifies neighbours of an update, as appropriate + */ + public void breakBlock (World par1World, int par2, int par3, int par4, int par5, int par6) + { + super.breakBlock(par1World, par2, par3, par4, par5, par6); + this.func_94483_i_(par1World, par2, par3, par4); + } + + @Override + public int colorMultiplier (IBlockAccess par1IBlockAccess, int par2, int par3, int par4) + { + return 8388608; + } + + public void registerIcons (IconRegister par1IconRegister) + { + this.field_94413_c = par1IconRegister.registerIcon("tinker:repeaterDust_cross"); + this.field_94410_cO = par1IconRegister.registerIcon("tinker:repeaterDust_line"); + this.field_94411_cP = par1IconRegister.registerIcon("tinker:repeaterDust_cross_overlay"); + this.field_94412_cQ = par1IconRegister.registerIcon("tinker:repeaterDust_line_overlay"); + this.blockIcon = this.field_94413_c; + } + + @SideOnly(Side.CLIENT) + public static Icon func_94409_b (String par0Str) + { + return par0Str == "repeaterDust_cross" ? field_94413_c : (par0Str == "repeaterDust_line" ? field_94410_cO : (par0Str == "repeaterDust_cross_overlay" ? field_94411_cP + : (par0Str == "repeaterDust_line_overlay" ? field_94412_cQ : null))); + } +} diff --git a/tconstruct/blocks/RedstoneMachine.java b/tconstruct/blocks/RedstoneMachine.java new file mode 100644 index 00000000..4168a750 --- /dev/null +++ b/tconstruct/blocks/RedstoneMachine.java @@ -0,0 +1,205 @@ +package tconstruct.blocks; + +import static net.minecraftforge.common.ForgeDirection.UP; + +import java.util.List; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.DrawbridgeLogic; +import tconstruct.blocks.logic.FirestarterLogic; +import tconstruct.client.block.MachineRender; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.InventoryBlock; +import tconstruct.library.util.IActiveLogic; +import tconstruct.library.util.IFacingLogic; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; + +public class RedstoneMachine extends InventoryBlock +{ + public RedstoneMachine(int id) + { + super(id, Material.iron); + this.setCreativeTab(TConstructRegistry.blockTab); + setHardness(12); + setStepSound(soundMetalFootstep); + } + + @Override + public int getLightValue (IBlockAccess world, int x, int y, int z) + { + if (world.getBlockMetadata(x, y, z) == 0) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + + if (logic != null && logic instanceof IInventory) + { + if (((IInventory) logic).getStackInSlot(1) != null) + { + return lightValue[((IInventory) logic).getStackInSlot(1).itemID]; + } + } + } + return super.getLightValue(world, x, y, z); + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + switch (metadata) + { + case 0: + return new DrawbridgeLogic(); + case 1: + return new FirestarterLogic(); + default: + return null; + } + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + int meta = world.getBlockMetadata(x, y, z); + switch (meta) + { + case 0: + return TConstruct.proxy.drawbridgeGui; + } + return null; + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } + + /* Rendering */ + + @Override + public String[] getTextureNames () + { + String[] textureNames = { "drawbridge_top", "drawbridge_side", "drawbridge_bottom", "drawbridge_top_face", "drawbridge_side_face", "drawbridge_bottom_face", "firestarter_top", + "firestarter_side", "firestarter_bottom" }; + + return textureNames; + } + + @Override + public void registerIcons (IconRegister iconRegister) + { + String[] textureNames = getTextureNames(); + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:machines/" + textureNames[i]); + } + } + + @Override + public Icon getIcon (int side, int meta) + { + if (meta == 0) + { + if (side == 5) + return icons[5]; + return icons[getTextureIndex(side)]; + } + if (meta == 1) + { + return icons[getTextureIndex(side) + 6]; + } + return icons[0]; + } + + public Icon getBlockTexture (IBlockAccess world, int x, int y, int z, int side) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0; + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) + { + DrawbridgeLogic drawbridge = (DrawbridgeLogic) logic; + ItemStack stack = drawbridge.getStackInSlot(1); + if (stack != null && stack.itemID < 4096) + { + Block block = Block.blocksList[stack.itemID]; + if (block != null && block.renderAsNormalBlock()) + return block.getIcon(side, stack.getItemDamage()); + } + if (side == direction) + { + return icons[getTextureIndex(side) + 3]; + } + else + { + return icons[getTextureIndex(side)]; + } + } + + if (meta == 1) + { + if (side == direction) + { + return icons[6]; + } + else if (side / 2 == direction / 2) + { + return icons[8]; + } + return icons[7]; + } + return icons[0]; + } + + public int getTextureIndex (int side) + { + if (side == 0) + return 2; + if (side == 1) + return 0; + + return 1; + } + + public int getRenderType () + { + return MachineRender.model; + } + + public boolean isFireSource (World world, int x, int y, int z, int metadata, ForgeDirection side) + { + if (metadata == 1) + return side == UP; + return false; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 2; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } + + /* Redstone */ + public void onNeighborBlockChange (World world, int x, int y, int z, int neighborBlockID) + { + IActiveLogic logic = (IActiveLogic) world.getBlockTileEntity(x, y, z); + logic.setActive(world.isBlockIndirectlyGettingPowered(x, y, z)); + } +} diff --git a/tconstruct/blocks/SearedBlock.java b/tconstruct/blocks/SearedBlock.java new file mode 100644 index 00000000..5fcf2e0c --- /dev/null +++ b/tconstruct/blocks/SearedBlock.java @@ -0,0 +1,339 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.CastingBasinLogic; +import tconstruct.blocks.logic.CastingTableLogic; +import tconstruct.blocks.logic.FaucetLogic; +import tconstruct.client.block.SearedRender; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.InventoryBlock; +import tconstruct.library.tools.AbilityHelper; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class SearedBlock extends InventoryBlock +{ + + public SearedBlock(int id) + { + super(id, Material.rock); + this.setCreativeTab(TConstructRegistry.blockTab); + setHardness(12); + setStepSound(soundMetalFootstep); + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + switch (metadata) + { + case 0: + return new CastingTableLogic(); + case 1: + return new FaucetLogic(); + case 2: + return new CastingBasinLogic(); + default: + return null; + } + } + + @Override + public int getRenderBlockPass () + { + return 1; + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + return null; + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } + + /* Activation */ + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ) + { + int md = world.getBlockMetadata(x, y, z); + if (md == 0) + { + return activateCastingTable(world, x, y, z, player); + } + if (md == 2) + { + return activateCastingBasin(world, x, y, z, player); + } + else if (md == 1) + { + if (player.isSneaking()) + return false; + + FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z); + logic.setActive(true); + return true; + } + else + return super.onBlockActivated(world, x, y, z, player, side, clickX, clickY, clickZ); + } + + boolean activateCastingTable (World world, int x, int y, int z, EntityPlayer player) + { + if (!world.isRemote) + { + CastingTableLogic logic = (CastingTableLogic) world.getBlockTileEntity(x, y, z); + if (logic.liquid != null) + return true; + + if (!logic.isStackInSlot(0) && !logic.isStackInSlot(1)) + { + ItemStack stack = player.getCurrentEquippedItem(); + stack = player.inventory.decrStackSize(player.inventory.currentItem, 1); + logic.setInventorySlotContents(0, stack); + } + else + { + if (logic.isStackInSlot(1)) + { + ItemStack stack = logic.decrStackSize(1, 1); + if (stack != null) + addItemToInventory(player, world, x, y, z, stack); + } + else if (logic.isStackInSlot(0)) + { + ItemStack stack = logic.decrStackSize(0, 1); + if (stack != null) + addItemToInventory(player, world, x, y, z, stack); + } + } + + world.markBlockForUpdate(x, y, z); + } + return true; + } + + boolean activateCastingBasin (World world, int x, int y, int z, EntityPlayer player) + { + if (!world.isRemote) + { + CastingBasinLogic logic = (CastingBasinLogic) world.getBlockTileEntity(x, y, z); + if (logic.liquid != null) + return true; + + if (!logic.isStackInSlot(0) && !logic.isStackInSlot(1)) + { + ItemStack stack = player.getCurrentEquippedItem(); + stack = player.inventory.decrStackSize(player.inventory.currentItem, 1); + logic.setInventorySlotContents(0, stack); + } + else + { + if (logic.isStackInSlot(1)) + { + ItemStack stack = logic.decrStackSize(1, 1); + if (stack != null) + addItemToInventory(player, world, x, y, z, stack); + } + else if (logic.isStackInSlot(0)) + { + ItemStack stack = logic.decrStackSize(0, 1); + if (stack != null) + addItemToInventory(player, world, x, y, z, stack); + } + } + + world.markBlockForUpdate(x, y, z); + } + return true; + } + + public void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack stack) + { + AbilityHelper.spawnItemAtPlayer(player, stack); + /*if (!world.isRemote) + { + EntityItem entityitem = new EntityItem(world, (double) x + 0.5D, (double) y + 0.9325D, (double) z + 0.5D, stack); + world.spawnEntityInWorld(entityitem); + entityitem.onCollideWithPlayer(player); + }*/ + } + + /* Rendering */ + @Override + public int getRenderType () + { + return SearedRender.searedModel; + } + + @Override + public String[] getTextureNames () + { + String[] textureNames = { "castingtable_top", "castingtable_side", "castingtable_bottom", "faucet", "blockcast_top", "blockcast_side", "blockcast_bottom" }; + + return textureNames; + } + + @Override + public Icon getIcon (int side, int meta) + { + if (meta == 0) + return icons[getTextureIndex(side)]; + else if (meta == 2) + return icons[getTextureIndex(side) + 4]; + else + return icons[3]; + } + + public int getTextureIndex (int side) + { + if (side == 0) + return 2; + if (side == 1) + return 0; + + return 1; + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public boolean isOpaqueCube () + { + return false; + } + + @Override + public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + return true; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 3; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } + + @Override + public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta != 1) + { + this.setBlockBounds(0, 0, 0, 1, 1, 1); + } + else + { + FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z); + float xMin = 0.25F; + float xMax = 0.75F; + float zMin = 0.25F; + float zMax = 0.75F; + + switch (logic.getRenderDirection()) + { + case 2: + zMin = 0.625F; + zMax = 1.0F; + break; + case 3: + zMax = 0.375F; + zMin = 0F; + break; + case 4: + xMin = 0.625F; + xMax = 1.0F; + break; + case 5: + xMax = 0.375F; + xMin = 0F; + break; + } + + this.setBlockBounds(xMin, 0.25F, zMin, xMax, 0.625F, zMax); + } + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta != 1) + { + return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1, z + 1); + } + else + { + FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z); + if (logic != null) + { + float xMin = 0.25F; + float xMax = 0.75F; + float zMin = 0.25F; + float zMax = 0.75F; + + switch (logic.getRenderDirection()) + { + case 2: + zMin = 0.625F; + zMax = 1.0F; + break; + case 3: + zMax = 0.375F; + zMin = 0F; + break; + case 4: + xMin = 0.625F; + xMax = 1.0F; + break; + case 5: + xMax = 0.375F; + xMin = 0F; + break; + } + + return AxisAlignedBB.getAABBPool().getAABB((double) ((float) x + xMin), (double) y + 0.25, (double) ((float) z + zMin), (double) ((float) x + xMax), (double) y + 0.625, + (double) ((float) z + zMax)); + } + } + + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } + + /* Redstone */ + public boolean canConnectRedstone (IBlockAccess world, int x, int y, int z, int side) + { + return world.getBlockMetadata(x, y, z) == 1; + } + + public void onNeighborBlockChange (World world, int x, int y, int z, int neighborBlockID) + { + if (world.isBlockIndirectlyGettingPowered(x, y, z) && world.getBlockMetadata(x, y, z) == 1) + { + FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z); + logic.setActive(true); + } + } +} diff --git a/tconstruct/blocks/SearedSlab.java b/tconstruct/blocks/SearedSlab.java new file mode 100644 index 00000000..587d1a0d --- /dev/null +++ b/tconstruct/blocks/SearedSlab.java @@ -0,0 +1,52 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.common.TContent; +import tconstruct.library.TConstructRegistry; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SearedSlab extends SlabBase +{ + public SearedSlab(int id) + { + super(id, Material.rock); + this.setCreativeTab(TConstructRegistry.blockTab); + setHardness(12F); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon (int side, int meta) + { + meta = meta % 8; + if (meta == 0) + return TContent.smeltery.getIcon(side, 2); + if (meta <= 3) + return TContent.smeltery.getIcon(side, meta + 3); + + return TContent.smeltery.getIcon(side, meta + 4); + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 8; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } +} diff --git a/tconstruct/blocks/SlabBase.java b/tconstruct/blocks/SlabBase.java new file mode 100644 index 00000000..f55fa151 --- /dev/null +++ b/tconstruct/blocks/SlabBase.java @@ -0,0 +1,58 @@ +package tconstruct.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class SlabBase extends Block +{ + public SlabBase(int id, Material material) + { + super(id, material); + } + + @Override + public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity) + { + setBlockBoundsBasedOnState(world, x, y, z); + super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity); + } + + public void setBlockBoundsForItemRender () + { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + + public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z) / 8; + float minY = meta == 1 ? 0.5F : 0.0F; + float maxY = meta == 1 ? 1.0F : 0.5F; + setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F); + } + + public int onBlockPlaced (World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, float clickZ, int metadata) + { + if (side == 1) + return metadata; + if (side == 0 || clickY >= 0.5F) + return metadata | 8; + + return metadata; + } + + public boolean isOpaqueCube () + { + return false; + } + + public boolean renderAsNormalBlock () + { + return false; + } +} diff --git a/tconstruct/blocks/SmelteryBlock.java b/tconstruct/blocks/SmelteryBlock.java new file mode 100644 index 00000000..5c3414a4 --- /dev/null +++ b/tconstruct/blocks/SmelteryBlock.java @@ -0,0 +1,280 @@ +package tconstruct.blocks; + +import java.util.List; +import java.util.Random; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.MultiServantLogic; +import tconstruct.blocks.logic.SmelteryDrainLogic; +import tconstruct.blocks.logic.SmelteryLogic; +import tconstruct.client.block.SmelteryRender; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.InventoryBlock; +import tconstruct.library.util.IFacingLogic; +import tconstruct.library.util.IMasterLogic; +import tconstruct.library.util.IServantLogic; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class SmelteryBlock extends InventoryBlock +{ + Random rand; + + public SmelteryBlock(int id) + { + super(id, Material.rock); + setHardness(12F); + setStepSound(soundMetalFootstep); + rand = new Random(); + this.setCreativeTab(TConstructRegistry.blockTab); + this.setUnlocalizedName("tconstruct.Smeltery"); + } + + /* Rendering */ + + @Override + public int getRenderType () + { + return SmelteryRender.smelteryModel; + } + + @Override + public String[] getTextureNames () + { + String[] textureNames = { "smeltery_side", "smeltery_inactive", "smeltery_active", "drain_side", "drain_out", "drain_basin", "searedbrick", "searedstone", "searedcobble", "searedpaver", + "searedbrickcracked", "searedroad", "searedbrickfancy", "searedbricksquare", "searedcreeper" }; + + return textureNames; + } + + public Icon getIcon (int side, int meta) + { + if (meta < 2) + { + int sideTex = side == 3 ? 1 : 0; + return icons[sideTex + meta * 3]; + } + else if (meta == 2) + { + return icons[6]; + } + else if (meta == 11) + { + if (side == 0 || side == 1) + return icons[9]; + } + + return icons[3 + meta]; + } + + public Icon getBlockTexture (IBlockAccess world, int x, int y, int z, int side) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0; + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) //Smeltery + { + if (side == direction) + { + if (isActive(world, x, y, z)) + { + return icons[2]; + } + else + { + return icons[1]; + } + } + else + { + return icons[0]; + } + } + if (meta == 1) //Drain + { + if (side == direction) + return icons[5]; + else if (side / 2 == direction / 2) + return icons[4]; + else + return icons[3]; + } + else if (meta == 2) + { + return icons[6]; + } + else if (meta == 11) + { + if (side == 0 || side == 1) + return icons[9]; + } + return icons[3 + meta]; + + } + + /*@Override + public int getRenderBlockPass() + { + return 1; + }*/ + + public int damageDropped (int meta) + { + return meta; + } + + public int quantityDropped (Random random) + { + return 1; + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + return TConstruct.proxy.smelteryGuiID; + } + + public void randomDisplayTick (World world, int x, int y, int z, Random random) + { + if (isActive(world, x, y, z)) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + byte face = 0; + if (logic instanceof IFacingLogic) + face = ((IFacingLogic) logic).getRenderDirection(); + float f = (float) x + 0.5F; + float f1 = (float) y + 0.5F + (random.nextFloat() * 6F) / 16F; + float f2 = (float) z + 0.5F; + float f3 = 0.52F; + float f4 = random.nextFloat() * 0.6F - 0.3F; + switch (face) + { + case 4: + world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + break; + + case 5: + world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + break; + + case 2: + world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + break; + + case 3: + world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + break; + } + } + } + + public int getLightValue (IBlockAccess world, int x, int y, int z) + { + return !isActive(world, x, y, z) ? 0 : 9; + } + + //@Override + /*public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 9; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + }*/ + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } + + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ) + { + if (player.isSneaking() || world.getBlockMetadata(x, y, z) != 0) + return false; + + Integer integer = getGui(world, x, y, z, player); + if (integer == null || integer == -1) + { + return false; + } + else + { + player.openGui(getModInstance(), integer, world, x, y, z); + return true; + } + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + switch (metadata) + { + case 0: + return new SmelteryLogic(); + case 1: + return new SmelteryDrainLogic(); + case 3: + return null; //Furnace + } + return new MultiServantLogic(); + } + + @Override + public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) + { + super.onBlockPlacedBy(world, x, y, z, entityliving, stack); + if (world.getBlockMetadata(x, y, z) == 0) + onBlockPlacedElsewhere(world, x, y, z, entityliving); + } + + public void onBlockPlacedElsewhere (World world, int x, int y, int z, EntityLivingBase entityliving) + { + SmelteryLogic logic = (SmelteryLogic) world.getBlockTileEntity(x, y, z); + logic.checkValidPlacement(); + } + + @Override + public void breakBlock (World world, int x, int y, int z, int par5, int par6) //Don't drop inventory + { + world.removeBlockTileEntity(x, y, z); + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 12; iter++) + { + if (iter != 3) + list.add(new ItemStack(id, 1, iter)); + } + } + + /* Updating */ + public void onNeighborBlockChange (World world, int x, int y, int z, int nBlockID) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + if (logic instanceof IServantLogic) + { + ((IServantLogic) logic).notifyMasterOfChange(); + } + else if (logic instanceof IMasterLogic) + { + ((IMasterLogic) logic).notifyChange(x, y, z); + } + } +} diff --git a/tconstruct/blocks/SoilBlock.java b/tconstruct/blocks/SoilBlock.java new file mode 100644 index 00000000..0504c999 --- /dev/null +++ b/tconstruct/blocks/SoilBlock.java @@ -0,0 +1,49 @@ +package tconstruct.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +public class SoilBlock extends TConstructBlock +{ + static String[] soilTypes = new String[] { "slimesand", "grout", "slimesandblue", "graveyardsoil", "consecratedsoil" }; + + public SoilBlock(int id) + { + super(id, Material.ground, 3.0F, soilTypes); + } + + @Override + public void onEntityWalking (World world, int x, int y, int z, Entity entity) + { + if (entity instanceof EntityLiving) + { + EntityLiving living = ((EntityLiving) entity); + if (living.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) + { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 3) + { + living.heal(1); + } + else if (metadata == 4) + { + living.attackEntityFrom(DamageSource.magic, 1); + living.setFire(1); + } + } + } + } + + /*public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + if (world.getBlockMetadata(x, y, z) >= 3) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.875F, 1.0F); + } + }*/ +} diff --git a/tconstruct/blocks/SoilSlab.java b/tconstruct/blocks/SoilSlab.java new file mode 100644 index 00000000..e49e5686 --- /dev/null +++ b/tconstruct/blocks/SoilSlab.java @@ -0,0 +1,98 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.common.TContent; +import tconstruct.library.TConstructRegistry; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.world.ColorizerGrass; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SoilSlab extends SlabBase +{ + public SoilSlab(int id) + { + super(id, Material.ground); + this.setCreativeTab(TConstructRegistry.blockTab); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.blockIcon = iconRegister.registerIcon("tinker:grass_top"); + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon (int side, int meta) + { + switch (meta % 8) + { + case 0: + return this.blockIcon;//Block.grass.getIcon(1, 0); + case 1: + return Block.dirt.getIcon(side, 0); + case 2: + return Block.mycelium.getIcon(1, 0); + default: + return TContent.craftedSoil.getIcon(side, meta - 3); + } + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 8; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getBlockColor () + { + double d0 = 0.5D; + double d1 = 1.0D; + return ColorizerGrass.getGrassColor(d0, d1); + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderColor (int par1) + { + //if (par1 % 8 == 0) + return this.getBlockColor(); + //return 0xFFFFFF; + } + + @Override + @SideOnly(Side.CLIENT) + public int colorMultiplier (IBlockAccess world, int x, int y, int z) + { + int l = 0; + int i1 = 0; + int j1 = 0; + + for (int k1 = -1; k1 <= 1; ++k1) + { + for (int l1 = -1; l1 <= 1; ++l1) + { + int i2 = world.getBiomeGenForCoords(x + l1, z + k1).getBiomeGrassColor(); + l += (i2 & 16711680) >> 16; + i1 += (i2 & 65280) >> 8; + j1 += i2 & 255; + } + } + return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255; + } +} diff --git a/tconstruct/blocks/SpeedBlock.java b/tconstruct/blocks/SpeedBlock.java new file mode 100644 index 00000000..a5a2eca8 --- /dev/null +++ b/tconstruct/blocks/SpeedBlock.java @@ -0,0 +1,59 @@ +package tconstruct.blocks; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SpeedBlock extends TConstructBlock +{ + public static String[] textureNames = new String[] { "brownstone_rough", "brownstone_rough_road", "brownstone_smooth", "brownstone_smooth_brick", "brownstone_smooth_road", + "brownstone_smooth_fancy", "brownstone_smooth_chiseled" }; + + public SpeedBlock(int id) + { + super(id, Material.rock, 3.0f, textureNames); + //this.setBlockBounds(0f, 0f, 0f, 1.0f, 0.5f, 1.0f); + } + + @Override + public void onEntityWalking (World world, int x, int y, int z, Entity entity) + { + double boost = 2.2D; + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 1 || metadata == 4) + boost = 2.7D; + + double mX = Math.abs(entity.motionX); + double mZ = Math.abs(entity.motionZ); + if (mX < 0.5D) + { + entity.motionX *= boost; + } + if (mZ < 0.5D) + { + entity.motionZ *= boost; + } + } + + @Override + public int damageDropped (int meta) + { + return meta; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < textureNames.length; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } +} diff --git a/tconstruct/blocks/SpeedSlab.java b/tconstruct/blocks/SpeedSlab.java new file mode 100644 index 00000000..4f5396be --- /dev/null +++ b/tconstruct/blocks/SpeedSlab.java @@ -0,0 +1,69 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.common.TContent; +import tconstruct.library.TConstructRegistry; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SpeedSlab extends SlabBase +{ + public SpeedSlab(int id) + { + super(id, Material.rock); + this.setCreativeTab(TConstructRegistry.blockTab); + setHardness(3F); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon (int side, int meta) + { + meta = meta % 8; + return TContent.speedBlock.getIcon(side, meta); + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 7; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } + + @Override + public void onEntityWalking (World world, int x, int y, int z, Entity entity) + { + double boost = 2.2D; + int metadata = world.getBlockMetadata(x, y, z) % 8; + if (metadata == 1 || metadata == 4) + boost = 2.7D; + + double mX = Math.abs(entity.motionX); + double mZ = Math.abs(entity.motionZ); + if (mX < 0.5D) + { + entity.motionX *= boost; + } + if (mZ < 0.5D) + { + entity.motionZ *= boost; + } + } +} diff --git a/tconstruct/blocks/StoneTorch.java b/tconstruct/blocks/StoneTorch.java new file mode 100644 index 00000000..6542a6e6 --- /dev/null +++ b/tconstruct/blocks/StoneTorch.java @@ -0,0 +1,308 @@ +package tconstruct.blocks; + +import static net.minecraftforge.common.ForgeDirection.EAST; +import static net.minecraftforge.common.ForgeDirection.NORTH; +import static net.minecraftforge.common.ForgeDirection.SOUTH; +import static net.minecraftforge.common.ForgeDirection.WEST; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class StoneTorch extends Block +{ + public StoneTorch(int id) + { + super(id, Material.circuits); + this.setCreativeTab(CreativeTabs.tabDecorations); + setLightValue(0.9375F); + } + + /** + * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been + * cleared to be reused) + */ + public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int par2, int par3, int par4) + { + return null; + } + + /** + * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two + * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. + */ + public boolean isOpaqueCube () + { + return false; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + public boolean renderAsNormalBlock () + { + return false; + } + + /** + * The type of render function that is called for this block + */ + public int getRenderType () + { + return 2; + } + + /** + * Gets if we can place a torch on a block. + */ + private boolean canPlaceTorchOn (World par1World, int par2, int par3, int par4) + { + if (par1World.doesBlockHaveSolidTopSurface(par2, par3, par4)) + { + return true; + } + else + { + int l = par1World.getBlockId(par2, par3, par4); + return (Block.blocksList[l] != null && Block.blocksList[l].canPlaceTorchOnTop(par1World, par2, par3, par4)); + } + } + + /** + * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z + */ + public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4) + { + return par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true) || par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true) + || par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true) || par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true) + || canPlaceTorchOn(par1World, par2, par3 - 1, par4); + } + + /** + * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata + */ + public int onBlockPlaced (World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) + { + int j1 = par9; + + if (par5 == 0) + { + if (this.canPlaceTorchOn(par1World, par2, par3 - 1, par4)) + { + j1 = 5; + } + else if (par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true)) + { + j1 = 4; + } + else if (par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true)) + { + j1 = 3; + } + else if (par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true)) + { + j1 = 2; + } + else if (par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true)) + { + j1 = 1; + } + } + + if (par5 == 1 && this.canPlaceTorchOn(par1World, par2, par3 - 1, par4)) + { + j1 = 5; + } + + if (par5 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true)) + { + j1 = 4; + } + + if (par5 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true)) + { + j1 = 3; + } + + if (par5 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true)) + { + j1 = 2; + } + + if (par5 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true)) + { + j1 = 1; + } + + return j1; + } + + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon("tinker:torch_stone"); + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are + * their own) Args: x, y, z, neighbor blockID + */ + public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, int par5) + { + this.func_94397_d(par1World, par2, par3, par4, par5); + } + + protected boolean func_94397_d (World par1World, int par2, int par3, int par4, int par5) + { + if (this.dropTorchIfCantStay(par1World, par2, par3, par4)) + { + int i1 = par1World.getBlockMetadata(par2, par3, par4); + boolean flag = false; + + if (!par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true) && i1 == 1) + { + flag = true; + } + + if (!par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true) && i1 == 2) + { + flag = true; + } + + if (!par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true) && i1 == 3) + { + flag = true; + } + + if (!par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true) && i1 == 4) + { + flag = true; + } + + if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5) + { + flag = true; + } + + if (flag) + { + this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); + par1World.setBlockToAir(par2, par3, par4); + return true; + } + else + { + return false; + } + } + else + { + return true; + } + } + + /** + * Tests if the block can remain at its current location and will drop as an item if it is unable to stay. Returns + * True if it can stay and False if it drops. Args: world, x, y, z + */ + protected boolean dropTorchIfCantStay (World par1World, int par2, int par3, int par4) + { + if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) + { + if (par1World.getBlockId(par2, par3, par4) == this.blockID) + { + this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); + par1World.setBlockToAir(par2, par3, par4); + } + + return false; + } + else + { + return true; + } + } + + /** + * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world, + * x, y, z, startVec, endVec + */ + public MovingObjectPosition collisionRayTrace (World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) + { + int l = par1World.getBlockMetadata(par2, par3, par4) & 7; + float f = 0.15F; + + if (l == 1) + { + this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); + } + else if (l == 2) + { + this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); + } + else if (l == 3) + { + this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); + } + else if (l == 4) + { + this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); + } + else + { + f = 0.1F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f); + } + + return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3); + } + + @SideOnly(Side.CLIENT) + /** + * A randomly called display update to be able to add particles or other items for display + */ + public void randomDisplayTick (World par1World, int par2, int par3, int par4, Random par5Random) + { + int meta = par1World.getBlockMetadata(par2, par3, par4); + double d0 = (double) ((float) par2 + 0.5F); + double d1 = (double) ((float) par3 + 0.7F); + double d2 = (double) ((float) par4 + 0.5F); + double d3 = 0.2199999988079071D; + double d4 = 0.27000001072883606D; + + if (meta == 1) + { + par1World.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (meta == 2) + { + par1World.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (meta == 3) + { + par1World.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); + } + else if (meta == 4) + { + par1World.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); + } + else + { + par1World.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } +} diff --git a/tconstruct/blocks/TConstructBlock.java b/tconstruct/blocks/TConstructBlock.java new file mode 100644 index 00000000..d4c55924 --- /dev/null +++ b/tconstruct/blocks/TConstructBlock.java @@ -0,0 +1,63 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.library.TConstructRegistry; + + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class TConstructBlock extends Block +{ + public String[] textureNames; + public Icon[] icons; + + public TConstructBlock(int id, Material material, float hardness, String[] tex) + { + super(id, material); + setHardness(hardness); + this.setCreativeTab(TConstructRegistry.blockTab); + textureNames = tex; + } + + @Override + public int damageDropped (int meta) + { + return meta; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]); + } + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon (int side, int meta) + { + return icons[meta]; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < icons.length; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } +} diff --git a/tconstruct/blocks/TMetalBlock.java b/tconstruct/blocks/TMetalBlock.java new file mode 100644 index 00000000..95d5c332 --- /dev/null +++ b/tconstruct/blocks/TMetalBlock.java @@ -0,0 +1,23 @@ +package tconstruct.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.world.World; + +public class TMetalBlock extends TConstructBlock +{ + + static String[] metalTypes = new String[] { "compressed_cobalt", "compressed_ardite", "compressed_manyullyn", "compressed_copper", "compressed_bronze", "compressed_tin", "compressed_aluminum", + "compressed_alubrass", "compressed_alumite", "compressed_steel" }; + + public TMetalBlock(int id, Material material, float hardness) + { + super(id, material, hardness, metalTypes); + this.setStepSound(Block.soundMetalFootstep); + } + + public boolean isBeaconBase (World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) + { + return true; + } +} diff --git a/tconstruct/blocks/ToolForgeBlock.java b/tconstruct/blocks/ToolForgeBlock.java new file mode 100644 index 00000000..12f52168 --- /dev/null +++ b/tconstruct/blocks/ToolForgeBlock.java @@ -0,0 +1,135 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.ToolForgeLogic; +import tconstruct.client.block.TableForgeRender; +import tconstruct.common.TContent; +import tconstruct.common.TProxyCommon; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.InventoryBlock; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class ToolForgeBlock extends InventoryBlock +{ + public ToolForgeBlock(int id, Material material) + { + super(id, material); + this.setCreativeTab(TConstructRegistry.blockTab); + this.setHardness(2f); + this.setStepSound(Block.soundWoodFootstep); + } + + //Block.hasComparatorInputOverride and Block.getComparatorInputOverride + + String[] textureNames = { "toolforge_iron", "toolforge_gold", "toolforge_diamond", "toolforge_emerald", "toolforge_cobalt", "toolforge_ardite", "toolforge_manyullyn", "toolforge_copper", + "toolforge_bronze", "toolforge_tin", "toolforge_aluminum", "toolforge_alubrass", "toolforge_alumite", "toolforge_steel" }; + + /* Rendering */ + @Override + public String[] getTextureNames () + { + return textureNames; + } + + Icon textureTop; + + @Override + public void registerIcons (IconRegister iconRegister) + { + super.registerIcons(iconRegister); + textureTop = iconRegister.registerIcon("tinker:toolforge_top"); + } + + @Override + public Icon getIcon (int side, int meta) + { + if (side == 1) + { + return textureTop; + } + if (side == 0) + { + switch (meta) + { + case 0: + return Block.blockIron.getIcon(side, 0); + case 1: + return Block.blockGold.getIcon(side, 0); + case 2: + return Block.blockDiamond.getIcon(side, 0); + case 3: + return Block.blockEmerald.getIcon(side, 0); + default: + return TContent.metalBlock.getIcon(side, meta - 4); + } + } + + return this.icons[meta]; + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public boolean isOpaqueCube () + { + return false; + } + + @Override + public int getRenderType () + { + return TableForgeRender.model; + } + + @Override + public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + return true; + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + + return new ToolForgeLogic(); + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + int md = world.getBlockMetadata(x, y, z); + return TProxyCommon.toolForge; + //return -1; + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < textureNames.length; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } +} diff --git a/tconstruct/blocks/ToolStationBlock.java b/tconstruct/blocks/ToolStationBlock.java new file mode 100644 index 00000000..cb7f4a51 --- /dev/null +++ b/tconstruct/blocks/ToolStationBlock.java @@ -0,0 +1,206 @@ +package tconstruct.blocks; + +import java.util.List; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.PartCrafterLogic; +import tconstruct.blocks.logic.PatternChestLogic; +import tconstruct.blocks.logic.StencilTableLogic; +import tconstruct.blocks.logic.ToolStationLogic; +import tconstruct.client.block.TableRender; +import tconstruct.common.TContent; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.InventoryBlock; +import tconstruct.util.PHConstruct; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class ToolStationBlock extends InventoryBlock +{ + public ToolStationBlock(int id, Material material) + { + super(id, material); + this.setCreativeTab(TConstructRegistry.blockTab); + this.setHardness(2f); + this.setStepSound(Block.soundWoodFootstep); + } + + //Block.hasComparatorInputOverride and Block.getComparatorInputOverride + + /* Rendering */ + @Override + public String[] getTextureNames () + { + String[] textureNames = { "toolstation_top", "toolstation_side", "toolstation_bottom", "partbuilder_oak_top", "partbuilder_oak_side", "partbuilder_oak_bottom", "partbuilder_spruce_top", + "partbuilder_spruce_side", "partbuilder_spruce_bottom", "partbuilder_birch_top", "partbuilder_birch_side", "partbuilder_birch_bottom", "partbuilder_jungle_top", + "partbuilder_jungle_side", "partbuilder_jungle_bottom", "patternchest_top", "patternchest_side", "patternchest_bottom", "stenciltable_oak_top", "stenciltable_oak_side", + "stenciltable_oak_bottom", "stenciltable_spruce_top", "stenciltable_spruce_side", "stenciltable_spruce_bottom", "stenciltable_birch_top", "stenciltable_birch_side", + "stenciltable_birch_bottom", "stenciltable_jungle_top", "stenciltable_jungle_side", "stenciltable_jungle_bottom" }; + + return textureNames; + } + + @Override + public Icon getIcon (int side, int meta) + { + if (meta <= 4) + { + return icons[meta * 3 + getTextureIndex(side)]; + } + else if (meta <= 9) + { + return icons[15 + getTextureIndex(side)]; + } + else + { + return icons[meta * 3 + getTextureIndex(side) - 12]; + } + } + + public int getTextureIndex (int side) + { + if (side == 0) + return 2; + if (side == 1) + return 0; + + return 1; + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public boolean isOpaqueCube () + { + return false; + } + + @Override + public int getRenderType () + { + return TableRender.tabelModelID; + } + + @Override + public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + return true; + } + + public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 5) + return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125, + (double) z + this.maxZ); + return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ); + } + + @Override + public TileEntity createTileEntity (World world, int metadata) + { + switch (metadata) + { + case 0: + return new ToolStationLogic(); + case 1: + return new PartCrafterLogic(); + case 2: + return new PartCrafterLogic(); + case 3: + return new PartCrafterLogic(); + case 4: + return new PartCrafterLogic(); + case 5: + return new PatternChestLogic(); + case 6: + return new PatternChestLogic(); + case 7: + return new PatternChestLogic(); + case 8: + return new PatternChestLogic(); + case 9: + return new PatternChestLogic(); + case 10: + return new StencilTableLogic(); + case 11: + return new StencilTableLogic(); + case 12: + return new StencilTableLogic(); + case 13: + return new StencilTableLogic(); + /*case 14: + return new CastingTableLogic();*/ + default: + return null; + } + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + int md = world.getBlockMetadata(x, y, z); + if (md == 0) + return 0; + else if (md < 5) + return 1; + else if (md < 10) + return 2; + else + return 3; + + //return -1; + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 6; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + + for (int iter = 10; iter < 14; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } + + @Override + public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) + { + if (PHConstruct.freePatterns) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 5) + { + PatternChestLogic logic = (PatternChestLogic) world.getBlockTileEntity(x, y, z); + for (int i = 1; i <= 13; i++) + { + logic.setInventorySlotContents(i - 1, new ItemStack(TContent.woodPattern, 1, i)); + } + logic.setInventorySlotContents(13, new ItemStack(TContent.woodPattern, 1, 22)); + } + } + } +} diff --git a/tconstruct/blocks/logic/AggregatorLogic.java b/tconstruct/blocks/logic/AggregatorLogic.java new file mode 100644 index 00000000..b974ce7f --- /dev/null +++ b/tconstruct/blocks/logic/AggregatorLogic.java @@ -0,0 +1,11 @@ +package tconstruct.blocks.logic; + +import tconstruct.library.blocks.InventoryLogic; + +public abstract class AggregatorLogic extends InventoryLogic +{ + public AggregatorLogic(int invSize) + { + super(invSize); + } +} diff --git a/tconstruct/blocks/logic/AqueductLogic.java b/tconstruct/blocks/logic/AqueductLogic.java new file mode 100644 index 00000000..100dfe21 --- /dev/null +++ b/tconstruct/blocks/logic/AqueductLogic.java @@ -0,0 +1,44 @@ +package tconstruct.blocks.logic; + +import net.minecraft.tileentity.TileEntity; + +public class AqueductLogic extends TileEntity //implements ITankContainer +{ + + /*@Override + public int fill (ForgeDirection from, FluidStack resource, boolean doFill) + { + return 0; + } + + @Override + public int fill (int tankIndex, FluidStack resource, boolean doFill) + { + return 0; + } + + @Override + public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain) + { + return null; + } + + @Override + public FluidStack drain (int tankIndex, int maxDrain, boolean doDrain) + { + return null; + } + + @Override + public ILiquidTank[] getTanks (ForgeDirection direction) + { + return null; + } + + @Override + public ILiquidTank getTank (ForgeDirection direction, FluidStack type) + { + return null; + }*/ + +} diff --git a/tconstruct/blocks/logic/CastingBasinLogic.java b/tconstruct/blocks/logic/CastingBasinLogic.java new file mode 100644 index 00000000..38811ad0 --- /dev/null +++ b/tconstruct/blocks/logic/CastingBasinLogic.java @@ -0,0 +1,429 @@ +package tconstruct.blocks.logic; + +import tconstruct.TConstruct; +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.library.crafting.CastingRecipe; +import tconstruct.library.util.IPattern; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +public class CastingBasinLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory +{ + public FluidStack liquid; + int castingDelay = 0; + int renderOffset = 0; + int capacity = 0; + boolean needsUpdate; + boolean init = true; + int tick; + + public CastingBasinLogic() + { + super(2); + } + + @Override + public int getInventoryStackLimit () + { + return 1; + } + + @Override + public String getInvName () //Not a gui block + { + return null; + } + + @Override + protected String getDefaultName () //Still not a gui block + { + return null; + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) //Definitely not a gui block + { + return null; + } + + /* Tank */ + + @Override + public int getCapacity () + { + return this.capacity; + } + + public int updateCapacity () //Only used to initialize + { + int ret = TConstruct.ingotLiquidValue; + + ItemStack inv = inventory[0]; + + if (inv != null && inv.getItem() instanceof IPattern) + { + int cost = ((IPattern) inv.getItem()).getPatternCost(inv); + if (cost > 0) + ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5; + else + ret = TConstruct.basinCasting.getCastingAmount(this.liquid, inv); + } + + else + { + ret = TConstruct.basinCasting.getCastingAmount(this.liquid, inv); + } + + System.out.println("Ret: " + ret); + return ret; + } + + public int updateCapacity (int capacity) + { + int ret = TConstruct.ingotLiquidValue; + + ItemStack inv = inventory[0]; + + if (inv != null && inv.getItem() instanceof IPattern) + { + int cost = ((IPattern) inv.getItem()).getPatternCost(inv); + if (cost > 0) + ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5; + else + ret = capacity; + } + + else + ret = capacity; + + return ret; + } + + @Override + public int fill (FluidStack resource, boolean doFill) + { + if (resource == null) + return 0; + + if (this.liquid == null) + { + CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(resource, inventory[0]); + if (recipe == null) + return 0; + this.capacity = updateCapacity(recipe.castingMetal.amount); + + if (inventory[1] == null) + { + FluidStack copyLiquid = resource.copy(); + + if (copyLiquid.amount > this.capacity) + { + copyLiquid.amount = this.capacity; + } + + if (doFill) + { + if (copyLiquid.amount == this.capacity) + { + castingDelay = recipe.coolTime; + } + renderOffset = copyLiquid.amount; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + this.liquid = copyLiquid; + needsUpdate = true; + } + return copyLiquid.amount; + } + else + { + return 0; + } + } + + else if (resource.isFluidEqual(this.liquid)) + { + if (resource.amount + this.liquid.amount >= this.capacity) //Start timer here + { + int roomInTank = this.capacity - liquid.amount; + if (doFill && roomInTank > 0) + { + renderOffset = roomInTank; + castingDelay = TConstruct.basinCasting.getCastingDelay(this.liquid, inventory[0]); + this.liquid.amount = this.capacity; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + needsUpdate = true; + } + return roomInTank; + } + + else + { + if (doFill) + { + this.liquid.amount += resource.amount; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + needsUpdate = true; + } + return resource.amount; + } + } + + else + { + return 0; + } + } + + @Override + public void onInventoryChanged () //Isn't actually called? + { + super.onInventoryChanged(); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + needsUpdate = true; + } + + public ItemStack decrStackSize (int slot, int quantity) + { + ItemStack stack = super.decrStackSize(slot, quantity); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + return stack; + } + + @Override + public FluidStack drain (int maxDrain, boolean doDrain) + { + if (liquid == null || liquid.fluidID <= 0 || castingDelay > 0) + return null; + if (liquid.amount <= 0) + return null; + + int used = maxDrain; + if (liquid.amount < used) + used = liquid.amount; + + if (doDrain) + { + liquid.amount -= used; + } + + FluidStack drained = liquid.copy();//new FluidStack(liquid.itemID, used, liquid.itemMeta); + drained.amount = used; + + // Reset liquid if emptied + if (liquid.amount <= 0) + liquid = null; + + if (doDrain) + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this)); + + return drained; + } + + /* Tank Container */ + + @Override + public int fill (ForgeDirection from, FluidStack resource, boolean doFill) + { + //if (from == ForgeDirection.UP) + return fill(resource, doFill); + //return 0; + } + + @Override + public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain) + { + return drain(maxDrain, doDrain); + } + + + @Override + public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain) + { + return null; + } + + @Override + public boolean canFill (ForgeDirection from, Fluid fluid) + { + return false; + } + + @Override + public boolean canDrain (ForgeDirection from, Fluid fluid) + { + // TODO Auto-generated method stub + return false; + } + + @Override + public FluidTankInfo[] getTankInfo (ForgeDirection from) + { + return new FluidTankInfo[] {getInfo()}; + } + + @Override + public FluidStack getFluid () + { + return liquid.copy(); + } + + @Override + public int getFluidAmount () + { + return liquid != null ? liquid.amount : 0; + } + + @Override + public FluidTankInfo getInfo () + { + FluidTankInfo info = new FluidTankInfo(this); + return info; + } + + public int getLiquidAmount () + { + return liquid.amount - renderOffset; + } + + /* Updating */ + @Override + public void updateEntity () + { + if (castingDelay > 0) + { + //System.out.println("Casting"); + castingDelay--; + if (castingDelay == 0) + castLiquid(); + } + if (renderOffset > 0) + { + renderOffset -= 6; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + tick++; + if (tick % 20 == 0) + { + tick = 0; + if (needsUpdate) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + + public void castLiquid () + { + CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(liquid, inventory[0]); + if (recipe != null) + { + inventory[1] = recipe.getResult(); + if (recipe.consumeCast) + inventory[0] = null; + liquid = null; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + + /* NBT */ + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { + if (tags.getBoolean("hasLiquid")) + { + this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid")); + } + //FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt); + //this.liquid = new FluidStack(tags.getInteger("itemID"), tags.getInteger("amount"), tags.getInteger("itemMeta")); + else + this.liquid = null; + + if (tags.getBoolean("Initialized")) + this.capacity = tags.getInteger("Capacity"); + else + this.capacity = updateCapacity(); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } + + public void writeCustomNBT (NBTTagCompound tags) + { + tags.setBoolean("hasLiquid", liquid != null); + if (liquid != null) + { + NBTTagCompound nbt = new NBTTagCompound(); + liquid.writeToNBT(nbt); + tags.setCompoundTag("Fluid", nbt); + } + tags.setBoolean("Initialized", init); + tags.setInteger("Capacity", capacity); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readFromNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + @Override + public int[] getAccessibleSlotsFromSide (int side) + { + return new int[] { 0, 1 }; + } + + @Override + public boolean canInsertItem (int slot, ItemStack itemstack, int side) + { + if (liquid != null) + return false; + + if (slot == 0) + return true; + + return false; + } + + @Override + public boolean canExtractItem (int slot, ItemStack itemstack, int side) + { + if (slot == 1) + return true; + + return false; + } +} diff --git a/tconstruct/blocks/logic/CastingTableLogic.java b/tconstruct/blocks/logic/CastingTableLogic.java new file mode 100644 index 00000000..8efc493f --- /dev/null +++ b/tconstruct/blocks/logic/CastingTableLogic.java @@ -0,0 +1,429 @@ +package tconstruct.blocks.logic; + +import tconstruct.TConstruct; +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.library.crafting.CastingRecipe; +import tconstruct.library.util.IPattern; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory +{ + public FluidStack liquid; + int castingDelay = 0; + int renderOffset = 0; + int capacity = 0; + boolean needsUpdate; + boolean init = true; + int tick; + + public CastingTableLogic() + { + super(2); + } + + @Override + public int getInventoryStackLimit () + { + return 1; + } + + @Override + public String getInvName () //Not a gui block + { + return null; + } + + @Override + protected String getDefaultName () //Still not a gui block + { + return null; + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) //Definitely not a gui block + { + return null; + } + + /* Tank */ + + @Override + public int getCapacity () + { + return this.capacity; + } + + public int updateCapacity () //Only used to initialize + { + int ret = TConstruct.ingotLiquidValue; + + ItemStack inv = inventory[0]; + + if (inv != null && inv.getItem() instanceof IPattern) + { + int cost = ((IPattern) inv.getItem()).getPatternCost(inv); + if (cost > 0) + ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5; + else + ret = TConstruct.tableCasting.getCastingAmount(this.liquid, inv); + } + + else + { + ret = TConstruct.tableCasting.getCastingAmount(this.liquid, inv); + } + + System.out.println("Ret: " + ret); + return ret; + } + + public int updateCapacity (int capacity) + { + int ret = TConstruct.ingotLiquidValue; + + ItemStack inv = inventory[0]; + + if (inv != null && inv.getItem() instanceof IPattern) + { + int cost = ((IPattern) inv.getItem()).getPatternCost(inv); + if (cost > 0) + ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5; + else + ret = capacity; + } + + else + ret = capacity; + + return ret; + } + + @Override + public int fill (FluidStack resource, boolean doFill) + { + if (resource == null) + return 0; + + if (this.liquid == null) + { + CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(resource, inventory[0]); + if (recipe == null) + return 0; + this.capacity = updateCapacity(recipe.castingMetal.amount); + + if (inventory[1] == null) + { + FluidStack copyLiquid = resource.copy(); + + if (copyLiquid.amount > this.capacity) + { + copyLiquid.amount = this.capacity; + } + + if (doFill) + { + if (copyLiquid.amount == this.capacity) + { + castingDelay = recipe.coolTime; + } + renderOffset = copyLiquid.amount; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + this.liquid = copyLiquid; + needsUpdate = true; + } + return copyLiquid.amount; + } + else + { + return 0; + } + } + + else if (resource.isFluidEqual(this.liquid)) + { + if (resource.amount + this.liquid.amount >= this.capacity) //Start timer here + { + int roomInTank = this.capacity - liquid.amount; + if (doFill && roomInTank > 0) + { + renderOffset = roomInTank; + castingDelay = TConstruct.tableCasting.getCastingDelay(this.liquid, inventory[0]); + this.liquid.amount = this.capacity; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + needsUpdate = true; + } + return roomInTank; + } + + else + { + if (doFill) + { + this.liquid.amount += resource.amount; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + needsUpdate = true; + } + return resource.amount; + } + } + + else + { + return 0; + } + } + + @Override + public void onInventoryChanged () //Isn't actually called? + { + super.onInventoryChanged(); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + needsUpdate = true; + } + + public ItemStack decrStackSize (int slot, int quantity) + { + ItemStack stack = super.decrStackSize(slot, quantity); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + return stack; + } + + @Override + public FluidStack drain (int maxDrain, boolean doDrain) + { + if (liquid == null || liquid.fluidID <= 0 || castingDelay > 0) + return null; + if (liquid.amount <= 0) + return null; + + int used = maxDrain; + if (liquid.amount < used) + used = liquid.amount; + + if (doDrain) + { + liquid.amount -= used; + } + + FluidStack drained = liquid.copy();//new FluidStack(liquid.itemID, used, liquid.itemMeta); + drained.amount = used; + + // Reset liquid if emptied + if (liquid.amount <= 0) + liquid = null; + + if (doDrain) + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this)); + + return drained; + } + + /* Tank Container */ + + @Override + public int fill (ForgeDirection from, FluidStack resource, boolean doFill) + { + //if (from == ForgeDirection.UP) + return fill(resource, doFill); + //return 0; + } + + @Override + public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain) + { + return drain(maxDrain, doDrain); + } + + + @Override + public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain) + { + return null; + } + + @Override + public boolean canFill (ForgeDirection from, Fluid fluid) + { + return false; + } + + @Override + public boolean canDrain (ForgeDirection from, Fluid fluid) + { + // TODO Auto-generated method stub + return false; + } + + @Override + public FluidTankInfo[] getTankInfo (ForgeDirection from) + { + return new FluidTankInfo[] {getInfo()}; + } + + @Override + public FluidStack getFluid () + { + return liquid.copy(); + } + + @Override + public int getFluidAmount () + { + return liquid != null ? liquid.amount : 0; + } + + @Override + public FluidTankInfo getInfo () + { + FluidTankInfo info = new FluidTankInfo(this); + return info; + } + + public int getLiquidAmount () + { + return liquid.amount - renderOffset; + } + + /* Updating */ + @Override + public void updateEntity () + { + if (castingDelay > 0) + { + //System.out.println("Casting"); + castingDelay--; + if (castingDelay == 0) + castLiquid(); + } + if (renderOffset > 0) + { + renderOffset -= 6; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + tick++; + if (tick % 20 == 0) + { + tick = 0; + if (needsUpdate) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + + public void castLiquid () + { + CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(liquid, inventory[0]); + if (recipe != null) + { + inventory[1] = recipe.getResult(); + if (recipe.consumeCast) + inventory[0] = null; + liquid = null; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + + /* NBT */ + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { + if (tags.getBoolean("hasLiquid")) + { + this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid")); + } + //FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt); + //this.liquid = new FluidStack(tags.getInteger("itemID"), tags.getInteger("amount"), tags.getInteger("itemMeta")); + else + this.liquid = null; + + if (tags.getBoolean("Initialized")) + this.capacity = tags.getInteger("Capacity"); + else + this.capacity = updateCapacity(); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } + + public void writeCustomNBT (NBTTagCompound tags) + { + tags.setBoolean("hasLiquid", liquid != null); + if (liquid != null) + { + NBTTagCompound nbt = new NBTTagCompound(); + liquid.writeToNBT(nbt); + tags.setCompoundTag("Fluid", nbt); + } + tags.setBoolean("Initialized", init); + tags.setInteger("Capacity", capacity); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readFromNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + @Override + public int[] getAccessibleSlotsFromSide (int side) + { + return new int[] { 0, 1 }; + } + + @Override + public boolean canInsertItem (int slot, ItemStack itemstack, int side) + { + if (liquid != null) + return false; + + if (slot == 0) + return true; + + return false; + } + + @Override + public boolean canExtractItem (int slot, ItemStack itemstack, int side) + { + if (slot == 1) + return true; + + return false; + } +} diff --git a/tconstruct/blocks/logic/DrawbridgeLogic.java b/tconstruct/blocks/logic/DrawbridgeLogic.java new file mode 100644 index 00000000..f1c8241e --- /dev/null +++ b/tconstruct/blocks/logic/DrawbridgeLogic.java @@ -0,0 +1,358 @@ +package tconstruct.blocks.logic; + +import tconstruct.inventory.DrawbridgeContainer; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.library.util.IActiveLogic; +import tconstruct.library.util.IFacingLogic; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; + +public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IActiveLogic +{ + boolean active; + boolean working; + int ticks; + byte extension; + byte direction; + + public DrawbridgeLogic() + { + super(2); + } + + @Override + public boolean getActive () + { + return active; + } + + @Override + public void setActive (boolean flag) + { + active = flag; + working = true; + } + + @Override + public byte getRenderDirection () + { + return direction; + } + + @Override + public ForgeDirection getForgeDirection () + { + return ForgeDirection.VALID_DIRECTIONS[direction]; + } + + @Override + public void setDirection (int side) + { + } + + @Override + public void setDirection (float yaw, float pitch, EntityLivingBase player) + { + if (pitch > 45) + { + direction = 1; + } + else if (pitch < -45) + { + direction = 0; + } + else + { + int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; + switch (facing) + { + case 0: + direction = 2; + break; + + case 1: + direction = 5; + break; + + case 2: + direction = 3; + break; + + case 3: + direction = 4; + break; + } + } + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return new DrawbridgeContainer(inventoryplayer, this); + } + + @Override + protected String getDefaultName () + { + return "tinker.drawbridge"; + } + + @Override + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + super.setInventorySlotContents(slot, itemstack); + if (slot == 1) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + @Override + public ItemStack decrStackSize (int slot, int quantity) + { + ItemStack stack = super.decrStackSize(slot, quantity); + if (slot == 1) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return stack; + } + + public void updateEntity () + { + if (working) + { + ticks++; + if (ticks == 5) + { + ticks = 0; + if (active) //Placement + { + if (inventory[0] != null && inventory[0].stackSize > 1 && extension < 15) + { + extension++; + int xPos = xCoord; + int yPos = yCoord; + int zPos = zCoord; + + switch (direction) + { + case 0: + yPos -= extension; + break; + case 1: + yPos += extension; + break; + case 2: + zPos -= extension; + break; + case 3: + zPos += extension; + break; + case 4: + xPos -= extension; + break; + case 5: + xPos += extension; + break; + } + + Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; + if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos) || block.isBlockReplaceable(worldObj, xPos, yPos, zPos)) + { + //tryExtend(worldObj, xPos, yPos, zPos, direction); + int blockToItem = TConstructRegistry.blockToItemMapping[inventory[0].itemID]; + if (blockToItem == 0) + { + if (inventory[0].itemID >= 4096 || Block.blocksList[inventory[0].itemID] == null) + return; + + worldObj.setBlock(xPos, yPos, zPos, inventory[0].itemID, inventory[0].getItemDamage(), 3); + } + else + { + worldObj.setBlock(xPos, yPos, zPos, blockToItem, inventory[0].getItemDamage(), 3); + } + worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.out", 0.25F, worldObj.rand.nextFloat() * 0.25F + 0.6F); + inventory[0].stackSize--; + } + else + { + extension--; + working = false; + } + } + + else + { + working = false; + } + } + else + //Retraction + { + if ((inventory[0] == null || inventory[0].stackSize < inventory[0].getMaxStackSize()) && extension > 0) + { + int xPos = xCoord; + int yPos = yCoord; + int zPos = zCoord; + + switch (direction) + { + case 0: + yPos -= extension; + break; + case 1: + yPos += extension; + break; + case 2: + zPos -= extension; + break; + case 3: + zPos += extension; + break; + case 4: + xPos -= extension; + break; + case 5: + xPos += extension; + break; + } + + Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; + if (block != null) + { + int meta = worldObj.getBlockMetadata(xPos, yPos, zPos); + if (inventory[0] != null && validBlock(block) && validMetadata(block.blockID, meta)) + { + worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.in", 0.25F, worldObj.rand.nextFloat() * 0.15F + 0.6F); + worldObj.setBlock(xPos, yPos, zPos, 0); + inventory[0].stackSize++; + } + else + { + working = false; + } + } + extension--; + } + else + { + working = false; + } + } + } + } + } + + boolean validBlock (Block block) + { + int type = TConstructRegistry.interchangableBlockMapping[block.blockID]; + if (type != 0) + { + if (type == inventory[0].itemID) + return true; + } + int blockToItem = TConstructRegistry.blockToItemMapping[block.blockID]; + if (blockToItem != 0) + { + if (blockToItem == inventory[0].itemID) + return true; + } + return block.blockID == inventory[0].itemID; + } + + boolean validMetadata (int blockID, int metadata) + { + int type = TConstructRegistry.drawbridgeState[blockID]; + if (type == 0) + { + return metadata == inventory[0].getItemDamage(); + } + if (type == 1) + { + return true; + } + if (type == 2) + { + return false; + } + if (type == 3) + { + return true; //TODO: rotational metadata + } + if (type == 4) + { + return true; + } + if (type == 5) + { + return metadata == inventory[0].getItemDamage(); + } + return false; + } + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + active = tags.getBoolean("Active"); + working = tags.getBoolean("Working"); + extension = tags.getByte("Extension"); + readCustomNBT(tags); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + tags.setBoolean("Active", active); + tags.setBoolean("Working", working); + tags.setByte("Extension", extension); + writeCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { + direction = tags.getByte("Direction"); + } + + public void writeCustomNBT (NBTTagCompound tags) + { + tags.setByte("Direction", direction); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readFromNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + public boolean hasExtended () + { + return extension != 0; + } + + @Override + public void onInventoryChanged() { + super.onInventoryChanged(); + this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } +} diff --git a/tconstruct/blocks/logic/DryingRackLogic.java b/tconstruct/blocks/logic/DryingRackLogic.java new file mode 100644 index 00000000..b608457d --- /dev/null +++ b/tconstruct/blocks/logic/DryingRackLogic.java @@ -0,0 +1,127 @@ +package tconstruct.blocks.logic; + +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.library.crafting.DryingRackRecipes; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class DryingRackLogic extends InventoryLogic +{ + int currentTime; + int maxTime; + + public DryingRackLogic() + { + super(1); + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return null; + } + + @Override + protected String getDefaultName () + { + return ""; + } + + @Override + public void updateEntity () + { + if (maxTime > 0 && currentTime < maxTime) + { + currentTime++; + if (currentTime >= maxTime) + { + inventory[0] = DryingRackRecipes.getDryingResult(inventory[0]); + updateDryingTime(); + } + } + } + + @Override + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + super.setInventorySlotContents(slot, itemstack); + updateDryingTime(); + } + + @Override + public ItemStack decrStackSize (int slot, int quantity) + { + ItemStack stack = super.decrStackSize(slot, quantity); + maxTime = 0; + currentTime = 0; + return stack; + } + + public void updateDryingTime () + { + currentTime = 0; + if (inventory[0] != null) + maxTime = DryingRackRecipes.getDryingTime(inventory[0]); + else + maxTime = 0; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + @Override + public void readFromNBT (NBTTagCompound tags) + { + tags.setInteger("Time", currentTime); + tags.setInteger("MaxTime", maxTime); + readCustomNBT(tags); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + currentTime = tags.getInteger("Time"); + maxTime = tags.getInteger("MaxTime"); + writeCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + } + + public void writeCustomNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readCustomNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox () + { + AxisAlignedBB cbb = AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord - 1, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); + return cbb; + } +} diff --git a/tconstruct/blocks/logic/EquipLogic.java b/tconstruct/blocks/logic/EquipLogic.java new file mode 100644 index 00000000..d8945ab3 --- /dev/null +++ b/tconstruct/blocks/logic/EquipLogic.java @@ -0,0 +1,51 @@ +package tconstruct.blocks.logic; + +import tconstruct.library.blocks.InventoryLogic; +import net.minecraft.item.ItemStack; + +/* Slots + * 0: Frying pan item + * 1: Fuel + * 2-9: Food + */ + +public abstract class EquipLogic extends InventoryLogic +{ + + public EquipLogic(int invSize) + { + super(invSize); + } + + public void setEquipmentItem (ItemStack stack) + { + inventory[0] = stack.copy(); + } + + public boolean hasEquipmentItem () + { + return inventory[0] != null; + } + + public ItemStack getEquipmentItem () + { + return inventory[0]; + } + + /*@Override + public ItemStack getStackInSlot(int slot) + { + return inventory[slot +1]; + } + + public boolean isStackInSlot(int slot) + { + return inventory[slot +1] != null; + } + + @Override + public int getSizeInventory() + { + return inventory.length - 1; + }*/ +} diff --git a/tconstruct/blocks/logic/FaucetLogic.java b/tconstruct/blocks/logic/FaucetLogic.java new file mode 100644 index 00000000..e6d5b512 --- /dev/null +++ b/tconstruct/blocks/logic/FaucetLogic.java @@ -0,0 +1,247 @@ +package tconstruct.blocks.logic; + +import tconstruct.TConstruct; +import tconstruct.library.util.IActiveLogic; +import tconstruct.library.util.IFacingLogic; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogic, IFluidHandler +{ + byte direction; + boolean active; + public FluidStack liquid; + + public boolean activateFaucet () + { + if (liquid == null && active) + { + int x = xCoord, z = zCoord; + switch (getRenderDirection()) + { + case 2: + z++; + break; + case 3: + z--; + break; + case 4: + x++; + break; + case 5: + x--; + break; + } + + TileEntity drainte = worldObj.getBlockTileEntity(x, yCoord, z); + TileEntity tankte = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord); + + if (drainte != null && drainte instanceof IFluidHandler && tankte != null && tankte instanceof IFluidHandler) + { + FluidStack templiquid = ((IFluidHandler) drainte).drain(getForgeDirection(), TConstruct.ingotLiquidValue, false); + if (templiquid != null) + { + int drained = ((IFluidHandler) tankte).fill(ForgeDirection.UP, templiquid, false); + if (drained > 0) + { + liquid = ((IFluidHandler) drainte).drain(getForgeDirection(), drained, true); + ((IFluidHandler) tankte).fill(ForgeDirection.UP, liquid, true); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return true; + } + else + { + return false; + } + + } + } + } + return false; + } + + @Override + public void updateEntity () + { + if (liquid != null) + { + liquid.amount -= TConstruct.liquidUpdateAmount; + if (liquid.amount <= 0) + { + liquid = null; + if (!activateFaucet()) + { + active = false; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + } + } + + @Override + public byte getRenderDirection () + { + return direction; + } + + @Override + public ForgeDirection getForgeDirection () + { + return ForgeDirection.VALID_DIRECTIONS[direction]; + } + + @Override + public void setDirection (int side) + { + //direction = (byte) side; + } + + @Override + public void setDirection (float yaw, float pitch, EntityLivingBase player) + { + int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; + switch (facing) + { + case 0: + direction = 2; + break; + + case 1: + direction = 5; + break; + + case 2: + direction = 3; + break; + + case 3: + direction = 4; + break; + } + } + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { + direction = tags.getByte("Direction"); + if (tags.getBoolean("hasLiquid")) + { + this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid")); + } + else + this.liquid = null; + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } + + public void writeCustomNBT (NBTTagCompound tags) + { + tags.setByte("Direction", direction); + tags.setBoolean("hasLiquid", liquid != null); + if (liquid != null) + { + NBTTagCompound nbt = new NBTTagCompound(); + liquid.writeToNBT(nbt); + tags.setCompoundTag("Fluid", nbt); + } + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readCustomNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + @Override + public boolean getActive () + { + return active; + } + + @Override + public void setActive (boolean flag) + { + if (!active) + { + active = true; + activateFaucet(); + } + else + { + active = false; + } + } + + @Override + public int fill (ForgeDirection from, FluidStack resource, boolean doFill) + { + // TODO Auto-generated method stub + return 0; + } + + @Override + public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean canFill (ForgeDirection from, Fluid fluid) + { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean canDrain (ForgeDirection from, Fluid fluid) + { + // TODO Auto-generated method stub + return false; + } + + @Override + public FluidTankInfo[] getTankInfo (ForgeDirection from) + { + // TODO Auto-generated method stub + return null; + } +} diff --git a/tconstruct/blocks/logic/FirestarterLogic.java b/tconstruct/blocks/logic/FirestarterLogic.java new file mode 100644 index 00000000..ff47001c --- /dev/null +++ b/tconstruct/blocks/logic/FirestarterLogic.java @@ -0,0 +1,196 @@ +package tconstruct.blocks.logic; + +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.util.IActiveLogic; +import tconstruct.library.util.IFacingLogic; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraftforge.common.ForgeDirection; + +public class FirestarterLogic extends TileEntity implements IFacingLogic, IActiveLogic +{ + boolean active; + //boolean putOut; + boolean shouldActivate; + byte direction; + + @Override + public boolean getActive () + { + return active; + } + + @Override + public void setActive (boolean flag) + { + /*if (active && !flag) + { + putOut = true; + }*/ + + active = flag; + shouldActivate = true; + //setFire(); + } + + void setFire () + { + int xPos = xCoord; + int yPos = yCoord; + int zPos = zCoord; + + switch (direction) + { + case 0: + yPos -= 1; + break; + case 1: + yPos += 1; + break; + case 2: + zPos -= 1; + break; + case 3: + zPos += 1; + break; + case 4: + xPos -= 1; + break; + case 5: + xPos += 1; + break; + } + + Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; + if (active) + { + System.out.println("Setting fire"); + if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos)) + { + worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "fire.ignite", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F); + worldObj.setBlock(xPos, yPos, zPos, Block.fire.blockID); + } + } + else + { + //System.out.println("Stopping fire "+putOut); + if (block == Block.fire) + { + //worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "random.fizz", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F); + worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "fire.ignite", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F); + worldObj.setBlock(xPos, yPos, zPos, 0, 0, 3); + //putOut = false; + shouldActivate = true; + } + } + } + + public void updateEntity () + { + if (shouldActivate) + { + shouldActivate = false; + setFire(); + } + } + + @Override + public byte getRenderDirection () + { + return direction; + } + + @Override + public ForgeDirection getForgeDirection () + { + return ForgeDirection.VALID_DIRECTIONS[direction]; + } + + @Override + public void setDirection (int side) + { + } + + @Override + public void setDirection (float yaw, float pitch, EntityLivingBase player) + { + if (pitch > 45) + { + direction = 1; + } + else if (pitch < -45) + { + direction = 0; + } + else + { + int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; + switch (facing) + { + case 0: + direction = 2; + break; + + case 1: + direction = 5; + break; + + case 2: + direction = 3; + break; + + case 3: + direction = 4; + break; + } + } + } + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + tags.setBoolean("Active", active); + readCustomNBT(tags); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + active = tags.getBoolean("Active"); + writeCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { + direction = tags.getByte("Direction"); + } + + public void writeCustomNBT (NBTTagCompound tags) + { + tags.setByte("Direction", direction); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readCustomNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } +} diff --git a/tconstruct/blocks/logic/FrypanLogic.java b/tconstruct/blocks/logic/FrypanLogic.java new file mode 100644 index 00000000..69042dbd --- /dev/null +++ b/tconstruct/blocks/logic/FrypanLogic.java @@ -0,0 +1,301 @@ +package tconstruct.blocks.logic; + +import tconstruct.inventory.FrypanContainer; +import tconstruct.library.util.IActiveLogic; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.item.ItemTool; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +/* Slots + * 0: Frying pan item + * 1: Fuel + * 2-9: Food + */ + +public class FrypanLogic extends EquipLogic implements IActiveLogic +{ + boolean active; + public int fuel; + public int fuelGague; + public int progress; + + public FrypanLogic() + { + super(10); + active = false; + } + + @Override + public String getDefaultName () + { + return "crafters.frypan"; + } + + @Override + public boolean getActive () + { + return active; + } + + @Override + public void setActive (boolean flag) + { + active = flag; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + /* Fuel gauge */ + public int gaugeProgressScaled (int scale) + { + return (progress * scale) / 1000; + } + + public int gaugeFuelScaled (int scale) + { + if (fuelGague == 0) + { + fuelGague = fuel; + if (fuelGague == 0) + { + fuelGague = 1000; + } + } + return (fuel * scale) / fuelGague; + } + + /* Item cooking */ + public void updateEntity () + { + boolean burning = isBurning(); + boolean updateInventory = false; + if (fuel <= 0 && canCook()) + { + fuel = fuelGague = (int) (getItemBurnTime(inventory[1]) * 2.5); + if (fuel > 0) + { + if (inventory[1].getItem().hasContainerItem()) //Fuel slot + { + inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem()); + } + else + { + inventory[1].stackSize--; + } + if (inventory[1].stackSize <= 0) + { + inventory[1] = null; + } + updateInventory = true; + } + } + if (isBurning() && canCook()) + { + progress++; + if (progress >= 1000) + { + progress = 0; + cookItems(); + updateInventory = true; + } + } + else + { + progress = 0; + } + if (fuel > 0) + { + fuel--; + } + if (burning != isBurning()) + { + setActive(isBurning()); + updateInventory = true; + } + if (updateInventory) + { + onInventoryChanged(); + } + } + + public void cookItems () + { + if (!canCook()) + return; + + for (int id = 2; id < 10; id++) //Check every slot + { + if (canCook()) + { + ItemStack result = getResultFor(inventory[id]); + if (result != null) + { + int ids = 2; + boolean placed = false; + while (ids < 10 && !placed) //Try to merge stacks first + { + if (inventory[ids] != null && inventory[ids].isItemEqual(result) && inventory[ids].stackSize < inventory[ids].getMaxStackSize()) + { + if (inventory[ids].stackSize + result.stackSize <= inventory[ids].getMaxStackSize()) + { + inventory[ids].stackSize += result.stackSize; + placed = true; + } + else + { + int decrement = inventory[ids].getMaxStackSize() - inventory[ids].stackSize; + inventory[ids].stackSize = inventory[ids].getMaxStackSize(); + result.stackSize -= decrement; + } + } + ids++; + } + + ids = 2; + while (!placed && ids < 10) //Place remaining in slot + { + if (inventory[ids] == null) + { + inventory[ids] = result; + placed = true; + } + ids++; + } + + if (placed) + decrStackSize(id, 1); + } + } + } + } + + public boolean canCook () + { + for (int id = 2; id < 10; id++) + { + if (inventory[id] == null) //Nothing here! + continue; + + ItemStack result = getResultFor(inventory[id]); + if (result == null) //Doesn't cook into anything + continue; + + for (int slotid = 2; slotid < 10; slotid++) + { + if (inventory[slotid] == null) + return true; + + else if (inventory[slotid].isItemEqual(result) && inventory[slotid].stackSize + result.stackSize <= inventory[slotid].getMaxStackSize()) + return true; + } + } + return false; + } + + public boolean isBurning () + { + return fuel > 0; + } + + public ItemStack getResultFor (ItemStack stack) + { + ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack); + if (result != null && result.getItem() instanceof ItemFood) //Only valid for food + return result.copy(); + + return null; + } + + public static int getItemBurnTime (ItemStack stack) + { + if (stack == null) + { + return 0; + } + else + { + int itemID = stack.getItem().itemID; + Item item = stack.getItem(); + + if (stack.getItem() instanceof ItemBlock && Block.blocksList[itemID] != null) + { + Block block = Block.blocksList[itemID]; + + if (block == Block.woodSingleSlab) + { + return 150; + } + + if (block == Block.wood) + { + return 2400; + } + + if (block.blockMaterial == Material.wood) + { + return 300; + } + } + if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) + return 200; + if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) + return 200; + if (item instanceof ItemHoe && ((ItemHoe) item).getMaterialName().equals("WOOD")) + return 200; + if (itemID == Item.stick.itemID) + return 100; + if (itemID == Item.coal.itemID) + return 800; + if (itemID == Item.bucketLava.itemID) + return 20000; + if (itemID == Block.sapling.blockID) + return 100; + if (itemID == Item.blazeRod.itemID) + return 2400; + return GameRegistry.getFuelValue(stack); + } + } + + /* NBT */ + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + active = tags.getBoolean("Active"); + fuel = tags.getInteger("Fuel"); + fuelGague = tags.getInteger("FuelGague"); + } + + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + tags.setBoolean("Active", active); + tags.setInteger("Fuel", fuel); + tags.setInteger("FuelGague", fuelGague); + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return new FrypanContainer(inventoryplayer, this); + } + + /*@Override + public boolean canDropInventorySlot(int slot) + { + if (slot == 0) + return false; + else + return true; + }*/ +} diff --git a/tconstruct/blocks/logic/GlowstoneAggregator.java b/tconstruct/blocks/logic/GlowstoneAggregator.java new file mode 100644 index 00000000..151cef7e --- /dev/null +++ b/tconstruct/blocks/logic/GlowstoneAggregator.java @@ -0,0 +1,197 @@ +package tconstruct.blocks.logic; + +import tconstruct.common.TContent; +import tconstruct.crystal.TheftValueTracker; +import tconstruct.inventory.AggregatorContainer; +import tconstruct.library.util.IActiveLogic; +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; + +public class GlowstoneAggregator extends AggregatorLogic implements IActiveLogic +{ + short currentTime; + short maxTime = 20 * 60 * 5; + public int currentLightLevel; + public boolean active; + public byte crystalValue; + + public GlowstoneAggregator() + { + super(3); + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return new AggregatorContainer(inventoryplayer, this); + } + + @Override + protected String getDefaultName () + { + return "aggregator.glowstone"; + } + + @Override + public void updateEntity () + { + if (worldObj.isRemote) + return; + + if (worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && crystalValue < 64) + { + Block block = Block.blocksList[worldObj.getBlockId(xCoord, yCoord + 1, zCoord)]; + if (block == null || validBlock(block) || block.isAirBlock(worldObj, xCoord, yCoord + 1, zCoord)) + { + currentLightLevel = worldObj.getSavedLightValue(EnumSkyBlock.Sky, xCoord, yCoord, zCoord) - worldObj.skylightSubtracted; + if (currentLightLevel > 12) + { + currentTime++; + if (currentTime >= 180) + { + currentTime = 0; + crystalValue++; + if (block == TContent.lightCrystalBase) + { + int meta = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord); + if (crystalValue >= 64) + { + if (meta < 3) + { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, zCoord, 3, 3); + TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 25); //Total 60 + } + } + else if (crystalValue >= 28) + { + if (meta < 2) + { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, zCoord, 2, 3); + TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 15); //Total 35 + } + } + else if (crystalValue >= 8) + { + if (meta < 1) + { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, zCoord, 1, 3); + TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 10); //Total 20 + } + } + } + else + { + worldObj.setBlock(xCoord, yCoord + 1, zCoord, TContent.lightCrystalBase.blockID, 0, 3); + TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 10); //Total 10 + } + } + if (active == false) + { + active = true; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + else + { + if (active == true) + { + active = false; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + } + } + } + + boolean validBlock (Block block) + { + return block == TContent.lightCrystalBase; + } + + @Override + public boolean getActive () + { + return active; + } + + @Override + public void setActive (boolean flag) + { + active = flag; + } + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + tags.setShort("Time", currentTime); + tags.setByte("Value", crystalValue); + readCustomNBT(tags); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + currentTime = tags.getShort("Time"); + crystalValue = tags.getByte("Value"); + writeCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { + active = tags.getBoolean("Active"); + } + + public void writeCustomNBT (NBTTagCompound tags) + { + tags.setBoolean("Active", active); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readCustomNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + public void updateCrystalValue () + { + if (crystalValue > 0) + { + Block block = Block.blocksList[worldObj.getBlockId(xCoord, yCoord + 1, zCoord)]; + if (block == TContent.lightCrystalBase) + { + int meta = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord); + if (meta == 3) + crystalValue = 64; + else if (meta == 2) + crystalValue = 28; + else if (meta == 1) + crystalValue = 8; + else + crystalValue = 1; + } + else + { + crystalValue = 0; + } + } + } +} diff --git a/tconstruct/blocks/logic/GolemCoreLogic.java b/tconstruct/blocks/logic/GolemCoreLogic.java new file mode 100644 index 00000000..72697147 --- /dev/null +++ b/tconstruct/blocks/logic/GolemCoreLogic.java @@ -0,0 +1,117 @@ +package tconstruct.blocks.logic; + +import tconstruct.library.blocks.InventoryLogic; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.world.World; + +public class GolemCoreLogic extends InventoryLogic implements IInventory +{ + + public GolemCoreLogic() + { + super(1); + } + + public ItemStack getKey () + { + return inventory[0]; + } + + public void setKey (ItemStack itemstack) + { + inventory[0] = itemstack; + onInventoryChanged(); + } + + public void clear () + { + inventory[0] = null; + } + + public int getSizeInventory () + { + return 1; + } + + public ItemStack getStackInSlot (int slot) + { + return inventory[0]; + } + + public int getInventoryStackLimit () + { + return 1; + } + + public boolean canInteractWith (EntityPlayer entityplayer) + { + return true; + } + + public void openChest () + { + } + + public void closeChest () + { + } + + public boolean isUseableByPlayer (EntityPlayer entityplayer) + { + return true; + } + + @Override + public ItemStack getStackInSlotOnClosing (int i) + { + return null; + } + + @Override + public boolean isInvNameLocalized () + { + return false; + } + + @Override + public boolean isItemValidForSlot (int i, ItemStack itemstack) + { + return true; + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return null; + } + + @Override + protected String getDefaultName () + { + return "golems.core"; + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readFromNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } +} diff --git a/tconstruct/blocks/logic/GolemPedestalLogic.java b/tconstruct/blocks/logic/GolemPedestalLogic.java new file mode 100644 index 00000000..13af961c --- /dev/null +++ b/tconstruct/blocks/logic/GolemPedestalLogic.java @@ -0,0 +1,360 @@ +package tconstruct.blocks.logic; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.src.ModLoader; +import net.minecraft.tileentity.TileEntity; + +public class GolemPedestalLogic extends TileEntity implements IInventory +{ + public ItemStack supply; + public static int cost[] = null; + public static int souls[] = null; + + public GolemPedestalLogic() + { + supply = null; + if (cost == null) + { + cost = new int[512]; + souls = new int[512]; + cost[Block.planks.blockID] = 0; + cost[Block.wood.blockID] = 32; + cost[Block.cloth.blockID] = 8; + cost[Block.cobblestoneMossy.blockID] = 16; + cost[Block.obsidian.blockID] = 8; + cost[Block.pumpkin.blockID] = 8; + cost[Block.netherrack.blockID] = 64; + cost[Block.slowSand.blockID] = 1; + cost[Block.glowStone.blockID] = 1; + cost[Block.pumpkinLantern.blockID] = 8; + cost[Block.blockDiamond.blockID] = 1; + cost[Block.blockGold.blockID] = 1; + cost[Block.blockIron.blockID] = 1; + cost[Block.blockLapis.blockID] = 1; + cost[Block.jukebox.blockID] = 1; + cost[Block.music.blockID] = 1; + cost[Block.melon.blockID] = 8; + cost[Block.torchRedstoneIdle.blockID] = 6; + cost[Block.torchRedstoneActive.blockID] = cost[Block.torchRedstoneIdle.blockID]; + cost[Item.redstone.itemID] = 6; + cost[Item.beefRaw.itemID] = 8; + cost[Item.beefCooked.itemID] = cost[Item.beefRaw.itemID]; + cost[Item.porkRaw.itemID] = cost[Item.beefRaw.itemID]; + cost[Item.porkCooked.itemID] = cost[Item.beefRaw.itemID]; + cost[Item.enderPearl.itemID] = 1; + cost[Item.eyeOfEnder.itemID] = 1; + cost[Item.blazeRod.itemID] = 2; + cost[Block.mushroomBrown.blockID] = 16; + cost[Block.mushroomRed.blockID] = cost[Block.mushroomBrown.blockID]; + cost[Block.netherStalk.blockID] = 6; + cost[Item.glowstone.itemID] = 4; + cost[Item.diamond.itemID] = 1; + cost[Item.ingotIron.itemID] = 8; + cost[Item.ingotGold.itemID] = 2; + cost[Item.reed.itemID] = 8; + cost[Item.sugar.itemID] = cost[Item.reed.itemID]; + cost[Item.bucketLava.itemID] = 1; + cost[Item.cake.itemID] = 1; + cost[Item.bucketMilk.itemID] = 1; + cost[Item.wheat.itemID] = 32; + cost[Item.bread.itemID] = 8; + cost[Block.plantYellow.blockID] = 32; + cost[Block.plantRed.blockID] = cost[Block.plantYellow.blockID]; + cost[Block.dragonEgg.blockID] = 1; + cost[Block.tallGrass.blockID] = 64; + cost[Block.sapling.blockID] = 64; + cost[Item.ghastTear.itemID] = 8; + cost[Item.goldNugget.itemID] = 18; + cost[Item.spiderEye.itemID] = 16; + cost[Item.fermentedSpiderEye.itemID] = 6; + cost[Item.bowlSoup.itemID] = 0; + cost[Item.fishRaw.itemID] = 1; + cost[Item.fishCooked.itemID] = cost[Item.fishRaw.itemID]; + cost[Item.magmaCream.itemID] = 2; + cost[Item.blazePowder.itemID] = 4; + cost[Item.speckledMelon.itemID] = 1; + cost[Item.paper.itemID] = 8; + cost[Item.book.itemID] = 2; + cost[Item.egg.itemID] = 4; + cost[Item.slimeBall.itemID] = 2; + cost[Item.saddle.itemID] = 1; + cost[Item.feather.itemID] = 48; + cost[Item.gunpowder.itemID] = 16; + cost[Item.appleRed.itemID] = 8; + cost[Item.appleGold.itemID] = 1; + cost[Item.dyePowder.itemID] = 64; + cost[Item.bone.itemID] = 2; + cost[Item.rottenFlesh.itemID] = 48; + cost[Item.cookie.itemID] = 16; + cost[Item.melon.itemID] = 32; + cost[Item.chickenCooked.itemID] = 8; + cost[Item.chickenRaw.itemID] = cost[Item.chickenCooked.itemID]; + cost[Item.silk.itemID] = 64; + cost[Block.cactus.blockID] = 32; + souls[Block.planks.blockID] = 0; + souls[Block.wood.blockID] = 1; + souls[Block.cloth.blockID] = 1; + souls[Block.cobblestoneMossy.blockID] = 1; + souls[Block.obsidian.blockID] = 1; + souls[Block.pumpkin.blockID] = 1; + souls[Block.netherrack.blockID] = 1; + souls[Block.slowSand.blockID] = 1; + souls[Block.glowStone.blockID] = 2; + souls[Block.pumpkinLantern.blockID] = 1; + souls[Block.blockDiamond.blockID] = 27; + souls[Block.blockGold.blockID] = 2; + souls[Block.blockIron.blockID] = 2; + souls[Block.blockLapis.blockID] = 3; + souls[Block.jukebox.blockID] = 3; + souls[Block.music.blockID] = 1; + souls[Block.melon.blockID] = 1; + souls[Block.torchRedstoneIdle.blockID] = 1; + souls[Block.torchRedstoneActive.blockID] = souls[Block.torchRedstoneIdle.blockID]; + souls[Item.redstone.itemID] = 1; + souls[Item.beefRaw.itemID] = 1; + souls[Item.beefCooked.itemID] = souls[Item.beefRaw.itemID]; + souls[Item.porkRaw.itemID] = souls[Item.beefRaw.itemID]; + souls[Item.porkCooked.itemID] = souls[Item.beefRaw.itemID]; + souls[Item.enderPearl.itemID] = 1; + souls[Item.eyeOfEnder.itemID] = 2; + souls[Item.blazeRod.itemID] = 2; + souls[Block.mushroomBrown.blockID] = 1; + souls[Block.mushroomRed.blockID] = souls[Block.mushroomBrown.blockID]; + souls[Block.netherStalk.blockID] = 1; + souls[Item.glowstone.itemID] = 1; + souls[Item.diamond.itemID] = 3; + souls[Item.ingotIron.itemID] = 1; + souls[Item.ingotGold.itemID] = 1; + souls[Item.reed.itemID] = 1; + souls[Item.sugar.itemID] = souls[Item.reed.itemID]; + souls[Item.bucketLava.itemID] = 1; + souls[Item.cake.itemID] = 1; + souls[Item.bucketMilk.itemID] = 1; + souls[Item.wheat.itemID] = 1; + souls[Item.bread.itemID] = 1; + souls[Block.plantYellow.blockID] = 1; + souls[Block.plantRed.blockID] = souls[Block.plantYellow.blockID]; + souls[Block.dragonEgg.blockID] = 1; + souls[Block.tallGrass.blockID] = 1; + souls[Block.sapling.blockID] = 1; + souls[Item.ghastTear.itemID] = 1; + souls[Item.goldNugget.itemID] = 1; + souls[Item.spiderEye.itemID] = 1; + souls[Item.fermentedSpiderEye.itemID] = 1; + souls[Item.bowlSoup.itemID] = 1; + souls[Item.fishRaw.itemID] = 1; + souls[Item.fishCooked.itemID] = souls[Item.fishRaw.itemID]; + souls[Item.magmaCream.itemID] = 1; + souls[Item.blazePowder.itemID] = 1; + souls[Item.speckledMelon.itemID] = 1; + souls[Item.paper.itemID] = 1; + souls[Item.book.itemID] = 1; + souls[Item.egg.itemID] = 1; + souls[Item.slimeBall.itemID] = 1; + souls[Item.saddle.itemID] = 1; + souls[Item.feather.itemID] = 1; + souls[Item.gunpowder.itemID] = 1; + souls[Item.appleRed.itemID] = 1; + souls[Item.appleGold.itemID] = 3; + souls[Item.dyePowder.itemID] = 1; + souls[Item.bone.itemID] = 1; + souls[Item.rottenFlesh.itemID] = 1; + souls[Item.cookie.itemID] = 1; + souls[Item.melon.itemID] = 1; + souls[Item.chickenCooked.itemID] = 1; + souls[Item.chickenRaw.itemID] = souls[Item.chickenCooked.itemID]; + souls[Item.silk.itemID] = 1; + souls[Block.cactus.blockID] = 1; + } + } + + public int getSizeInventory () + { + return 9; + } + + public ItemStack getStackInSlot (int i) + { + if (supply != null && supply.getItem() == null) + { + supply = null; + } + return supply; + } + + public boolean subtractSoul (int i) + { + System.out.println("SUBTRACT WHY"); + if (supply == null || supply.itemID >= 512 || cost[supply.itemID] == 0) + { + worldObj.playSoundAtEntity(ModLoader.getMinecraftInstance().thePlayer, "mob.blaze.death", 1.0F, 0.5F); + ModLoader.getMinecraftInstance().thePlayer.addChatMessage("I require more souls..."); + return false; + } + int j = cost[supply.itemID]; + int k = souls[supply.itemID]; + int l = (supply.stackSize / j) * k; + System.out.println((new StringBuilder()).append("Subtracting amt").append(i).append(" s").append(k).append(" c").append(j).append(" ss").append(supply.stackSize).append(" id") + .append(supply.itemID).append(" sa").append(l).append(" calc").append(Math.ceil((double) i / (double) k)).toString()); + if (l < i) + { + worldObj.playSoundAtEntity(ModLoader.getMinecraftInstance().thePlayer, "mob.blaze.death", 1.0F, 0.5F); + ModLoader.getMinecraftInstance().thePlayer.addChatMessage("I need more souls..."); + return false; + } + supply.stackSize -= Math.ceil((double) i / (double) k) * (double) j; + if (supply.stackSize == 0) + { + supply = null; + } + else if (supply.stackSize < 0) + { + throw new UnsupportedOperationException((new StringBuilder()) + .append("If you are getting this error then your golems mod has derped, \nplease contact billythegoat101 on the minecraftforums with the error code: LERN YO MATHS [i") + .append(supply.itemID).append(",ss").append(supply.stackSize).append(",a").append(i).append("]").toString()); + } + return true; + } + + public ItemStack decrStackSize (int i, int j) + { + if (supply != null && supply.getItem() == null) + { + supply = null; + } + if (supply != null) + { + if (supply.stackSize <= j) + { + ItemStack itemstack = supply; + supply = null; + onInventoryChanged(); + return itemstack; + } + ItemStack itemstack1 = supply.splitStack(j); + if (supply.stackSize == 0) + { + supply = null; + } + onInventoryChanged(); + return itemstack1; + } + else + { + return null; + } + } + + public void setInventorySlotContents (int i, ItemStack itemstack) + { + supply = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); + } + if (supply != null && supply.getItem() == null) + { + supply = null; + } + onInventoryChanged(); + } + + public void writeToNBT (NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + if (supply == null) + { + supply = new ItemStack(0, 0, 0); + } + NBTTagList nbttaglist = new NBTTagList(); + if (supply != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) 0); + supply.writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + nbttagcompound.setTag("Items", nbttaglist); + } + + public void readFromNBT (NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + supply = new ItemStack(0, 0, 0); + NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); + for (int i = 0; i < nbttaglist.tagCount(); i++) + { + NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); + int j = nbttagcompound1.getByte("Slot") & 0xff; + if (j >= 0 && j < 1) + { + supply = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + + if (supply != null && supply.getItem() == null) + { + supply = null; + } + } + + public String getInvName () + { + return "golempedestalinv"; + } + + public int getInventoryStackLimit () + { + return 64; + } + + public boolean canInteractWith (EntityPlayer entityplayer) + { + return true; + } + + public void openChest () + { + } + + public void closeChest () + { + } + + public void clear () + { + supply = null; + } + + public boolean isUseableByPlayer (EntityPlayer entityplayer) + { + return true; + } + + @Override + public ItemStack getStackInSlotOnClosing (int i) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isInvNameLocalized () + { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isItemValidForSlot (int i, ItemStack itemstack) + { + // TODO Auto-generated method stub + return false; + } +} diff --git a/tconstruct/blocks/logic/LavaTankLogic.java b/tconstruct/blocks/logic/LavaTankLogic.java new file mode 100644 index 00000000..682a5870 --- /dev/null +++ b/tconstruct/blocks/logic/LavaTankLogic.java @@ -0,0 +1,180 @@ +package tconstruct.blocks.logic; + +import net.minecraft.block.Block; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +public class LavaTankLogic extends MultiServantLogic implements IFluidHandler +{ + public FluidTank tank; + public int renderOffset; + + public LavaTankLogic() + { + tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 4); + } + + @Override + public int fill (ForgeDirection from, FluidStack resource, boolean doFill) + { + int amount = tank.fill(resource, doFill); + if (amount > 0 && doFill) + { + renderOffset = resource.amount; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + return amount; + } + + @Override + public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain) + { + FluidStack amount = tank.drain(maxDrain, doDrain); + if (amount != null && doDrain) + { + renderOffset = -maxDrain; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + return amount; + } + + @Override + public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain) + { + return null; + } + + @Override + public boolean canFill (ForgeDirection from, Fluid fluid) + { + //return tank.fill(fluid, false) > 0; + return false; + } + + @Override + public boolean canDrain (ForgeDirection from, Fluid fluid) + { + // TODO Auto-generated method stub + return false; + } + + @Override + public FluidTankInfo[] getTankInfo (ForgeDirection from) + { + FluidStack fluid = null; + if (tank.getFluid() != null) + fluid = tank.getFluid().copy(); + return new FluidTankInfo[] { new FluidTankInfo(fluid, tank.getCapacity())}; + } + + /*@Override + public IFluidTank[] getTanks (ForgeDirection direction) + { + return new IFluidTank[] { tank }; + } + + @Override + public IFluidTank getTank (ForgeDirection direction, FluidStack type) + { + return tank; + }*/ + + public float getFluidAmountScaled () + { + return (float) (tank.getFluid().amount - renderOffset) / (float) (tank.getCapacity() * 1.01F); + } + + public boolean containsFluid () + { + return tank.getFluid() != null; + } + + public int getBrightness () + { + if (containsFluid()) + { + int id = tank.getFluid().fluidID; + if (id < 4096) + { + return Block.lightValue[id]; + } + } + return 0; + } + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { + if (tags.getBoolean("hasFluid")) + tank.setFluid(new FluidStack(tags.getInteger("itemID"), tags.getInteger("amount"))); + else + tank.setFluid(null); + } + + public void writeCustomNBT (NBTTagCompound tags) + { + FluidStack liquid = tank.getFluid(); + tags.setBoolean("hasFluid", liquid != null); + if (liquid != null) + { + tags.setInteger("itemID", liquid.fluidID); + tags.setInteger("amount", liquid.amount); + } + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readCustomNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + /* Updating */ + public boolean canUpdate () + { + return true; + } + + @Override + public void updateEntity () + { + if (renderOffset > 0) + { + renderOffset -= 6; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + } +} diff --git a/tconstruct/blocks/logic/LiquidTextureLogic.java b/tconstruct/blocks/logic/LiquidTextureLogic.java new file mode 100644 index 00000000..1117356e --- /dev/null +++ b/tconstruct/blocks/logic/LiquidTextureLogic.java @@ -0,0 +1,65 @@ +package tconstruct.blocks.logic; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.tileentity.TileEntity; + +public class LiquidTextureLogic extends TileEntity +{ + int texturePos; + + public boolean canUpdate () + { + return false; + } + + public void setLiquidType (int tex) + { + texturePos = tex; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + public int getLiquidType () + { + return texturePos; + } + + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { + texturePos = tags.getInteger("Texture"); + } + + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } + + public void writeCustomNBT (NBTTagCompound tags) + { + tags.setInteger("Texture", texturePos); + } + + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readCustomNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } +} diff --git a/tconstruct/blocks/logic/MultiServantLogic.java b/tconstruct/blocks/logic/MultiServantLogic.java new file mode 100644 index 00000000..23f314f8 --- /dev/null +++ b/tconstruct/blocks/logic/MultiServantLogic.java @@ -0,0 +1,146 @@ +package tconstruct.blocks.logic; + +import tconstruct.library.util.CoordTuple; +import tconstruct.library.util.IMasterLogic; +import tconstruct.library.util.IServantLogic; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.tileentity.TileEntity; + +public class MultiServantLogic extends TileEntity implements IServantLogic +{ + boolean hasMaster; + CoordTuple master; + short masterID; + byte masterMeat; //Typo, it stays! + + public boolean canUpdate () + { + return false; + } + + public boolean hasValidMaster () + { + if (!hasMaster) + return false; + + if (worldObj.getBlockId(master.x, master.y, master.z) == masterID && worldObj.getBlockMetadata(master.x, master.y, master.z) == masterMeat) + return true; + else + { + hasMaster = false; + master = null; + return false; + } + } + + public CoordTuple getMasterPosition () + { + return master; + } + + public void overrideMaster (int x, int y, int z) + { + hasMaster = true; + master = new CoordTuple(x, y, z); + masterID = (short) worldObj.getBlockId(x, y, z); + masterMeat = (byte) worldObj.getBlockMetadata(x, y, z); + } + + public void removeMaster () + { + hasMaster = false; + master = null; + masterID = 0; + masterMeat = 0; + } + + public boolean verifyMaster (int x, int y, int z) + { + if (master.equalCoords(x, y, z) && worldObj.getBlockId(x, y, z) == masterID && worldObj.getBlockMetadata(x, y, z) == masterMeat) + return true; + else + return false; + } + + public boolean setMaster (int x, int y, int z) + { + if (!hasMaster || worldObj.getBlockId(master.x, master.y, master.z) != masterID || (worldObj.getBlockMetadata(master.x, master.y, master.z) != masterMeat)) + { + overrideMaster(x, y, z); + return true; + } + else + { + return false; + } + } + + public void notifyMasterOfChange () + { + if (hasValidMaster()) + { + IMasterLogic logic = (IMasterLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); + logic.notifyChange(xCoord, yCoord, zCoord); + } + } + + public void readCustomNBT (NBTTagCompound tags) + { + hasMaster = tags.getBoolean("HasMaster"); + if (hasMaster) + { + int xCenter = tags.getInteger("xCenter"); + int yCenter = tags.getInteger("yCenter"); + int zCenter = tags.getInteger("zCenter"); + master = new CoordTuple(xCenter, yCenter, zCenter); + masterID = tags.getShort("MasterID"); + masterMeat = tags.getByte("masterMeat"); + } + } + + public void writeCustomNBT (NBTTagCompound tags) + { + tags.setBoolean("HasMaster", hasMaster); + if (hasMaster) + { + tags.setInteger("xCenter", master.x); + tags.setInteger("yCenter", master.y); + tags.setInteger("zCenter", master.z); + tags.setShort("MasterID", masterID); + tags.setByte("masterMeat", masterMeat); + } + } + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readCustomNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } +} diff --git a/tconstruct/blocks/logic/PartCrafterLogic.java b/tconstruct/blocks/logic/PartCrafterLogic.java new file mode 100644 index 00000000..35d6e6e5 --- /dev/null +++ b/tconstruct/blocks/logic/PartCrafterLogic.java @@ -0,0 +1,180 @@ +package tconstruct.blocks.logic; + +import tconstruct.inventory.PartCrafterChestContainer; +import tconstruct.inventory.PartCrafterContainer; +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.library.crafting.PatternBuilder; +import tconstruct.library.util.IPattern; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class PartCrafterLogic extends InventoryLogic implements ISidedInventory +{ + boolean craftedTop; + boolean craftedBottom; + + public PartCrafterLogic() + { + super(10); + craftedTop = false; + craftedBottom = false; + } + + @Override + public String getDefaultName () + { + return "toolstation.parts"; + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + TileEntity tile = world.getBlockTileEntity(xPos, y, zPos); + if (tile != null && tile instanceof PatternChestLogic) + return new PartCrafterChestContainer(inventoryplayer, this, (PatternChestLogic) tile); + } + } + return new PartCrafterContainer(inventoryplayer, this); + } + + //Called when emptying a slot, not when another item is placed in it + public ItemStack decrStackSize (int slotID, int quantity) + { + ItemStack returnStack = super.decrStackSize(slotID, quantity); + tryBuildPart(slotID); + return returnStack; + } + + public void tryBuildPart (int slotID) + { + if (slotID == 4 || slotID == 5) + { + if (!craftedTop && inventory[0] != null) + { + int value = PatternBuilder.instance.getPartValue(inventory[2]); + IPattern item = (IPattern) inventory[0].getItem(); + int cost = item != null ? item.getPatternCost(inventory[0]) : 0; + if (value > 0 && cost > 0) + { + int decrease = cost / value; + if (cost % value != 0) + decrease++; + super.decrStackSize(2, decrease); //Call super to avoid crafting again + } + } + + if (inventory[4] != null || inventory[5] != null) + craftedTop = true; + else + craftedTop = false; + } + + if (!craftedTop) + buildTopPart(); + + if (slotID == 6 || slotID == 7) + { + if (!craftedBottom && inventory[1] != null) + { + int value = PatternBuilder.instance.getPartValue(inventory[3]); + IPattern item = (IPattern) inventory[1].getItem(); + int cost = item != null ? item.getPatternCost(inventory[1]) : 0; + if (value > 0 && cost > 0) + { + int decrease = cost / value; + if (cost % value != 0) + decrease++; + super.decrStackSize(3, decrease); //Call super to avoid crafting again + } + } + + if (inventory[6] != null || inventory[7] != null) + craftedBottom = true; + else + craftedBottom = false; + } + + if (!craftedBottom) + buildBottomPart(); + } + + //Called when a slot has something placed into it. + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + super.setInventorySlotContents(slot, itemstack); + if ((slot == 0 || slot == 2) && !craftedTop) + buildTopPart(); + if ((slot == 1 || slot == 3) && !craftedBottom) + buildBottomPart(); + } + + void buildTopPart () + { + ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[2], inventory[0], inventory[1]); + if (parts != null) + { + inventory[4] = parts[0]; + inventory[5] = parts[1]; + } + else + { + inventory[4] = inventory[5] = null; + } + } + + void buildBottomPart () + { + ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[1], inventory[0]); + if (parts != null) + { + inventory[6] = parts[0]; + inventory[7] = parts[1]; + } + else + { + inventory[6] = inventory[7] = null; + } + } + + /* NBT */ + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + craftedTop = tags.getBoolean("CraftedTop"); + craftedBottom = tags.getBoolean("CraftedBottom"); + } + + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + tags.setBoolean("CraftedTop", craftedTop); + tags.setBoolean("CraftedBottom", craftedBottom); + } + + @Override + public int[] getAccessibleSlotsFromSide (int side) + { + return new int[0]; + } + + @Override + public boolean canInsertItem (int i, ItemStack itemstack, int j) + { + return false; + } + + @Override + public boolean canExtractItem (int i, ItemStack itemstack, int j) + { + return false; + } +} diff --git a/tconstruct/blocks/logic/PatternChestLogic.java b/tconstruct/blocks/logic/PatternChestLogic.java new file mode 100644 index 00000000..0086726a --- /dev/null +++ b/tconstruct/blocks/logic/PatternChestLogic.java @@ -0,0 +1,32 @@ +package tconstruct.blocks.logic; + +import tconstruct.inventory.PatternChestContainer; +import tconstruct.library.blocks.InventoryLogic; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.world.World; + +public class PatternChestLogic extends InventoryLogic +{ + public PatternChestLogic() + { + super(30); + } + + public boolean canUpdate () + { + return false; + } + + @Override + public String getDefaultName () + { + return "toolstation.patternholder"; + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return new PatternChestContainer(inventoryplayer, this); + } +} diff --git a/tconstruct/blocks/logic/RedwireLogic.java b/tconstruct/blocks/logic/RedwireLogic.java new file mode 100644 index 00000000..a5d1fa04 --- /dev/null +++ b/tconstruct/blocks/logic/RedwireLogic.java @@ -0,0 +1,72 @@ +package tconstruct.blocks.logic; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.tileentity.TileEntity; + +public class RedwireLogic extends TileEntity +{ + byte facesUsed; + byte type; + byte distanceTravelled; + byte maxDistance; + + public void readCustomNBT (NBTTagCompound tags) + { + /*hasMaster = tags.getBoolean("HasMaster"); + if (hasMaster) + { + int xCenter = tags.getInteger("xCenter"); + int yCenter = tags.getInteger("yCenter"); + int zCenter = tags.getInteger("zCenter"); + master = new CoordTuple(xCenter, yCenter, zCenter); + masterID = tags.getShort("MasterID"); + masterMeat = tags.getByte("masterMeat"); + }*/ + } + + public void writeCustomNBT (NBTTagCompound tags) + { + /*tags.setBoolean("HasMaster", hasMaster); + if (hasMaster) + { + tags.setInteger("xCenter", master.x); + tags.setInteger("yCenter", master.y); + tags.setInteger("zCenter", master.z); + tags.setShort("MasterID", masterID); + tags.setByte("masterMeat", masterMeat); + }*/ + } + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readCustomNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } +} diff --git a/tconstruct/blocks/logic/SmelteryDrainLogic.java b/tconstruct/blocks/logic/SmelteryDrainLogic.java new file mode 100644 index 00000000..c719f18b --- /dev/null +++ b/tconstruct/blocks/logic/SmelteryDrainLogic.java @@ -0,0 +1,213 @@ +package tconstruct.blocks.logic; + +import tconstruct.library.util.IFacingLogic; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.util.MathHelper; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class SmelteryDrainLogic extends MultiServantLogic implements IFluidHandler, IFacingLogic +{ + byte direction; + + public boolean canUpdate () + { + return false; + } + + /*@Override + public FluidStack getLiquid () + { + return null; + } + + @Override + public int getCapacity () + { + if (!hasMaster) + return 0; + + SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); + return smeltery.getCapacity(); + }*/ + + /*@Override + public int fill (FluidStack resource, boolean doFill) + { + + }*/ + + /*@Override + public FluidStack drain (int maxDrain, boolean doDrain) + { + + }*/ + + @Override + public int fill (ForgeDirection from, FluidStack resource, boolean doFill) + { + if (hasMaster && resource != null) + { + if (doFill) + { + SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); + return smeltery.fill(resource, doFill); + } + else + { + return resource.amount; + } + } + else + { + return 0; + } + } + + @Override + public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain) + { + if (hasValidMaster()) + { + SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); + return smeltery.drain(maxDrain, doDrain); + } + else + { + return null; + } + } + + @Override + public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean canFill (ForgeDirection from, Fluid fluid) + { + return false; + } + + @Override + public boolean canDrain (ForgeDirection from, Fluid fluid) + { + return false; + } + + @Override + public FluidTankInfo[] getTankInfo (ForgeDirection from) + { + return null; + } + + /* + + @Override + public ILiquidTank[] getTanks (ForgeDirection direction) + { + if (hasValidMaster()) + { + SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); + return new ILiquidTank[] { smeltery }; + } + return null; + } + + @Override + public ILiquidTank getTank (ForgeDirection direction, FluidStack type) + { + if (hasValidMaster()) + { + return (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); + } + return null; + }*/ + + @Override + public byte getRenderDirection () + { + return direction; + } + + @Override + public ForgeDirection getForgeDirection () + { + return ForgeDirection.VALID_DIRECTIONS[direction]; + } + + @Override + public void setDirection (int side) + { + + } + + @Override + public void setDirection (float yaw, float pitch, EntityLivingBase player) + { + if (pitch > 45) + direction = 1; + else if (pitch < -45) + direction = 0; + else + { + int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; + switch (facing) + { + case 0: + direction = 2; + break; + + case 1: + direction = 5; + break; + + case 2: + direction = 3; + break; + + case 3: + direction = 4; + break; + } + } + } + + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + direction = tags.getByte("Direction"); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + tags.setByte("Direction", direction); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readFromNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } +} diff --git a/tconstruct/blocks/logic/SmelteryLogic.java b/tconstruct/blocks/logic/SmelteryLogic.java new file mode 100644 index 00000000..aac76151 --- /dev/null +++ b/tconstruct/blocks/logic/SmelteryLogic.java @@ -0,0 +1,1070 @@ +package tconstruct.blocks.logic; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import tconstruct.common.TContent; +import tconstruct.inventory.SmelteryContainer; +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.library.crafting.Smeltery; +import tconstruct.library.util.CoordTuple; +import tconstruct.library.util.IActiveLogic; +import tconstruct.library.util.IFacingLogic; +import tconstruct.library.util.IMasterLogic; +import tconstruct.util.SmelteryDamageSource; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +/* Simple class for storing items in the block + */ + +public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFacingLogic, IFluidTank, IMasterLogic +{ + public boolean validStructure; + public boolean tempValidStructure; + byte direction; + int internalTemp; + public int useTime; + public int fuelGague; + public int fuelAmount; + boolean inUse; + + ArrayList lavaTanks; + CoordTuple activeLavaTank; + public CoordTuple centerPos; + + public int[] activeTemps; + public int[] meltingTemps; + int tick; + + public ArrayList moltenMetal = new ArrayList(); + int maxLiquid; + int currentLiquid; + public int layers; + int slag; + + int numBricks; + + Random rand = new Random(); + boolean needsUpdate; + + public SmelteryLogic() + { + super(0); + lavaTanks = new ArrayList(); + activeTemps = new int[0]; + meltingTemps = new int[0]; + } + + void adjustLayers (int lay, boolean forceAdjust) + { + if (lay != layers || forceAdjust) + { + needsUpdate = true; + layers = lay; + maxLiquid = 20000 * lay; + int[] tempActive = activeTemps; + activeTemps = new int[9 * lay]; + int activeLength = tempActive.length > activeTemps.length ? activeTemps.length : tempActive.length; + System.arraycopy(tempActive, 0, activeTemps, 0, activeLength); + + int[] tempMelting = meltingTemps; + meltingTemps = new int[9 * lay]; + int meltingLength = tempMelting.length > meltingTemps.length ? meltingTemps.length : tempMelting.length; + System.arraycopy(tempMelting, 0, meltingTemps, 0, meltingLength); + + ItemStack[] tempInv = inventory; + inventory = new ItemStack[9 * lay]; + int invLength = tempInv.length > inventory.length ? inventory.length : tempInv.length; + System.arraycopy(tempInv, 0, inventory, 0, invLength); + + if (activeTemps.length > 0 && activeTemps.length > tempActive.length) + { + for (int i = tempActive.length; i < activeTemps.length; i++) + { + activeTemps[i] = 20; + meltingTemps[i] = 20; + } + } + + if (tempInv.length > inventory.length) + { + for (int i = inventory.length; i < tempInv.length; i++) + { + ItemStack stack = tempInv[i]; + if (stack != null) + { + float jumpX = rand.nextFloat() * 0.8F + 0.1F; + float jumpY = rand.nextFloat() * 0.8F + 0.1F; + float jumpZ = rand.nextFloat() * 0.8F + 0.1F; + + int offsetX = 0; + int offsetZ = 0; + switch (getRenderDirection()) + { + case 2: // +z + offsetZ = -1; + break; + case 3: // -z + offsetZ = 1; + break; + case 4: // +x + offsetX = -1; + break; + case 5: // -x + offsetX = 1; + break; + } + + while (stack.stackSize > 0) + { + int itemSize = rand.nextInt(21) + 10; + + if (itemSize > stack.stackSize) + { + itemSize = stack.stackSize; + } + + stack.stackSize -= itemSize; + EntityItem entityitem = new EntityItem(worldObj, (double) ((float) xCoord + jumpX + offsetX), (double) ((float) yCoord + jumpY), + (double) ((float) zCoord + jumpZ + offsetZ), new ItemStack(stack.itemID, itemSize, stack.getItemDamage())); + + if (stack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); + } + + float offset = 0.05F; + entityitem.motionX = (double) ((float) rand.nextGaussian() * offset); + entityitem.motionY = (double) ((float) rand.nextGaussian() * offset + 0.2F); + entityitem.motionZ = (double) ((float) rand.nextGaussian() * offset); + worldObj.spawnEntityInWorld(entityitem); + } + } + } + } + } + } + + /* Misc */ + @Override + public String getDefaultName () + { + return "crafters.Smeltery"; + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return new SmelteryContainer(inventoryplayer, this); + } + + @Override + public byte getRenderDirection () + { + return direction; + } + + @Override + public ForgeDirection getForgeDirection () + { + return ForgeDirection.VALID_DIRECTIONS[direction]; + } + + @Override + public void setDirection (int side) + { + + } + + @Override + public void setDirection (float yaw, float pitch, EntityLivingBase player) + { + int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; + switch (facing) + { + case 0: + direction = 2; + break; + + case 1: + direction = 5; + break; + + case 2: + direction = 3; + break; + + case 3: + direction = 4; + break; + } + } + + @Override + public boolean getActive () + { + return validStructure; + } + + @Override + public void setActive (boolean flag) + { + needsUpdate = true; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + public int getScaledFuelGague (int scale) + { + int ret = (fuelGague * scale) / 52; + if (ret < 1) + ret = 1; + return ret; + } + + public int getInternalTemperature () + { + return internalTemp; + } + + public int getTempForSlot (int slot) + { + return activeTemps[slot]; + } + + public int getMeltingPointForSlot (int slot) + { + return meltingTemps[slot]; + } + + /* Updating */ + public void updateEntity () + { + /*if (worldObj.isRemote) + return;*/ + + tick++; + if (tick % 4 == 0) + heatItems(); + + if (tick % 20 == 0) + { + if (!validStructure) + checkValidPlacement(); + + if (useTime > 0 && inUse) + useTime -= 3; + + if (validStructure && useTime <= 0) + { + updateFuelGague(); + } + + if (needsUpdate) + { + needsUpdate = false; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + + if (tick == 60) + { + tick = 0; + if (validStructure) + detectEntities(); + } + } + + void detectEntities () + { + AxisAlignedBB box = AxisAlignedBB.getAABBPool().getAABB(centerPos.x, centerPos.y, centerPos.z, centerPos.x + 1.0D, centerPos.y + 1.0D, centerPos.z + 1.0D).expand(1.0D, 0.0D, 1.0D); + + List list = worldObj.getEntitiesWithinAABB(Entity.class, box); + for (Object o : list) + { + if (o instanceof EntityVillager) + { + EntityVillager villager = (EntityVillager) o; + if (villager.attackEntityFrom(new SmelteryDamageSource(), 1)) + { + if (currentLiquid + 8 < maxLiquid) + { + int amount = villager.isChild() ? 1 : 8; + this.addMoltenMetal(new FluidStack(TContent.moltenEmeraldFluid, amount), false); + } + } + } + else if (o instanceof EntityLiving) + { + EntityLiving living = (EntityLiving) o; + if (living.attackEntityFrom(new SmelteryDamageSource(), 1)) + { + /*if (currentLiquid + 8 < maxLiquid) + { + int amount = living.isChild() ? 2 : 8; + this.addMoltenMetal(new FluidStack(TContent.liquidMetalStill.blockID, amount, 16), false); + }*/ + } + } + /*boolean itemAdded = false; + if (o instanceof EntityItem) + { + EntityItem item = (EntityItem) o; + item.age = 0; + int position = 0; + boolean canContinue = true; + do + { + if (inventory[position] == null) + { + ItemStack stack = item.getEntityItem(); + if (stack.stackSize > 0) + { + itemAdded = true; + this.setInventorySlotContents(position, stack.copy()); + stack.stackSize--; + this.onInventoryChanged(); + //worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + if (stack.stackSize < 1) + { + canContinue = false; + item.attackEntityFrom(DamageSource.magic, 1000); + } + } + position++; + if (position == inventory.length) + canContinue = false; + } while (canContinue); + } + if (itemAdded) + this.needsUpdate = true;*/ + } + } + + void heatItems () + { + if (useTime > 0) + { + boolean hasUse = false; + for (int i = 0; i < 9 * layers; i++) + { + if (meltingTemps[i] > 20 && this.isStackInSlot(i)) + { + hasUse = true; + if (activeTemps[i] < internalTemp && activeTemps[i] < meltingTemps[i]) + { + activeTemps[i] += 1; + } + else if (activeTemps[i] >= meltingTemps[i]) + { + if (!worldObj.isRemote) + { + FluidStack result = getResultFor(inventory[i]); + if (result != null) + { + if (addMoltenMetal(result, false)) + { + inventory[i] = null; + activeTemps[i] = 20; + ArrayList alloys = Smeltery.mixMetals(moltenMetal); + for (int al = 0; al < alloys.size(); al++) + { + FluidStack liquid = (FluidStack) alloys.get(al); + addMoltenMetal(liquid, true); + } + onInventoryChanged(); + } + } + } + } + + } + + else + activeTemps[i] = 20; + } + inUse = hasUse; + } + } + + boolean addMoltenMetal (FluidStack liquid, boolean first) + { + needsUpdate = true; + if (moltenMetal.size() == 0) + { + moltenMetal.add(liquid); + currentLiquid += liquid.amount; + return true; + } + else + { + if (liquid.amount + currentLiquid > maxLiquid) + return false; + + currentLiquid += liquid.amount; + //System.out.println("Current liquid: "+currentLiquid); + boolean added = false; + for (int i = 0; i < moltenMetal.size(); i++) + { + FluidStack l = moltenMetal.get(i); + //if (l.itemID == liquid.itemID && l.itemMeta == liquid.itemMeta) + if (l.isFluidEqual(liquid)) + { + l.amount += liquid.amount; + added = true; + } + if (l.amount <= 0) + { + moltenMetal.remove(l); + i--; + } + } + if (!added) + { + if (first) + moltenMetal.add(0, liquid); + else + moltenMetal.add(liquid); + } + return true; + } + } + + void updateTemperatures () + { + inUse = true; + for (int i = 0; i < 9 * layers; i++) + { + meltingTemps[i] = Smeltery.instance.getLiquifyTemperature(inventory[i]); + } + } + + public void updateFuelDisplay () + { + if (activeLavaTank == null || useTime > 0) + return; + + if (!worldObj.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z)) + { + fuelAmount = 0; + fuelGague = 0; + return; + } + + TileEntity tankContainer = worldObj.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); + if (tankContainer == null) + { + fuelAmount = 0; + fuelGague = 0; + return; + } + if (tankContainer instanceof IFluidHandler) + { + needsUpdate = true; + FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 150, false); + if (liquid != null && liquid.getFluid().getBlockID() == Block.lavaStill.blockID) + { + FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN); + if (info.length > 0) + { + int capacity = info[0].capacity; + fuelAmount = liquid.amount; + fuelGague = liquid.amount * 52 / capacity; + } + } + else + { + fuelAmount = 0; + fuelGague = 0; + } + } + } + + void updateFuelGague () + { + if (activeLavaTank == null || useTime > 0) + return; + + if (!worldObj.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z)) + { + fuelAmount = 0; + fuelGague = 0; + return; + } + + TileEntity tankContainer = worldObj.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); + if (tankContainer == null) + { + fuelAmount = 0; + fuelGague = 0; + return; + } + if (tankContainer instanceof IFluidHandler) + { + needsUpdate = true; + FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 150, false); + if (liquid != null && liquid.getFluid().getBlockID() == Block.lavaStill.blockID) + { + liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 150, true); + useTime += liquid.amount; + + FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN); + liquid = info[0].fluid; + int capacity = info[0].capacity; + if (liquid != null) + { + fuelAmount = liquid.amount; + fuelGague = liquid.amount * 52 / capacity; + } + else + { + fuelAmount = 0; + fuelGague = 0; + } + } + else + { + boolean foundTank = false; + int iter = 0; + while (!foundTank) + { + CoordTuple possibleTank = lavaTanks.get(iter); + TileEntity newTankContainer = worldObj.getBlockTileEntity(possibleTank.x, possibleTank.y, possibleTank.z); + if (newTankContainer instanceof IFluidHandler) + { + //System.out.println("Tank: "+possibleTank.toString()); + FluidStack newliquid = ((IFluidHandler) newTankContainer).drain(ForgeDirection.UNKNOWN, 150, false); + if (newliquid != null && newliquid.getFluid().getBlockID() == Block.lavaStill.blockID && newliquid.amount > 0) + { + //System.out.println("Tank: "+possibleTank.toString()); + foundTank = true; + activeLavaTank = possibleTank; + iter = lavaTanks.size(); + + /*IFluidTank newTank = ((IFluidHandler) newTankContainer).getTank(ForgeDirection.UNKNOWN, liquid); + liquid = newTank.getFluid(); + int capacity = newTank.getCapacity();*/ + FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN); + liquid = info[0].fluid; + int capacity = info[0].capacity; + if (liquid != null) + { + fuelAmount = liquid.amount; + fuelGague = liquid.amount * 52 / capacity; + } + else + { + fuelAmount = 0; + fuelGague = 0; + } + } + } + iter++; + if (iter >= lavaTanks.size()) + foundTank = true; + } + //System.out.println("Searching for tank, size: "+lavaTanks.size()); + } + } + } + + public FluidStack getResultFor (ItemStack stack) + { + return Smeltery.instance.getSmelteryResult(stack); + } + + /* Inventory */ + /*public int getMaxStackStackSize (ItemStack stack) + { + FluidStack liquid = getResultFor(stack); + if (liquid == null) + return 0; + return liquid.amount; + }*/ + + public int getInventoryStackLimit () + { + return 1; + } + + public void onInventoryChanged () + { + updateTemperatures(); + super.onInventoryChanged(); + needsUpdate = true; + //worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + //worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + /* Multiblock */ + @Override + public void notifyChange (int x, int y, int z) + { + checkValidPlacement(); + } + + public void checkValidPlacement () + { + switch (getRenderDirection()) + { + case 2: // +z + alignInitialPlacement(xCoord, yCoord, zCoord + 2); + break; + case 3: // -z + alignInitialPlacement(xCoord, yCoord, zCoord - 2); + break; + case 4: // +x + alignInitialPlacement(xCoord + 2, yCoord, zCoord); + break; + case 5: // -x + alignInitialPlacement(xCoord - 2, yCoord, zCoord); + break; + } + } + + public void alignInitialPlacement (int x, int y, int z) + { + int northID = worldObj.getBlockId(x, y, z + 1); + int southID = worldObj.getBlockId(x, y, z - 1); + int eastID = worldObj.getBlockId(x + 1, y, z); + int westID = worldObj.getBlockId(x - 1, y, z); + + Block northBlock = Block.blocksList[northID]; + Block southBlock = Block.blocksList[southID]; + Block eastBlock = Block.blocksList[eastID]; + Block westBlock = Block.blocksList[westID]; + + if ((northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1)) + && (eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z))) + { + checkValidStructure(x, y, z); + } + + else if ((northBlock != null && !northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1)) + && (eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z))) + { + checkValidStructure(x, y, z - 1); + } + + else if ((northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock != null && !southBlock.isAirBlock(worldObj, x, y, z - 1)) + && (eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z))) + { + checkValidStructure(x, y, z + 1); + } + + else if ((northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1)) + && (eastBlock != null && !eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z))) + { + checkValidStructure(x - 1, y, z); + } + + else if ((northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1)) + && (eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock != null && !westBlock.isAirBlock(worldObj, x - 1, y, z))) + { + checkValidStructure(x + 1, y, z); + } + + //Not valid, sorry + } + + public void checkValidStructure (int x, int y, int z) + { + int checkLayers = 0; + tempValidStructure = false; + if (checkSameLevel(x, y, z)) + { + checkLayers++; + checkLayers += recurseStructureUp(x, y + 1, z, 0); + checkLayers += recurseStructureDown(x, y - 1, z, 0); + } + + //maxLiquid = capacity * 20000; + + if (tempValidStructure != validStructure || checkLayers != this.layers) + { + if (tempValidStructure) + { + internalTemp = 800; + activeLavaTank = lavaTanks.get(0); + adjustLayers(checkLayers, false); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + validStructure = true; + } + else + { + internalTemp = 20; + validStructure = false; + } + } + } + + public boolean checkSameLevel (int x, int y, int z) + { + numBricks = 0; + lavaTanks.clear(); + Block block; + + //Check inside + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + block = Block.blocksList[worldObj.getBlockId(xPos, y, zPos)]; + if (block != null && !block.isAirBlock(worldObj, xPos, y, zPos)) + return false; + } + } + + //Check outer layer + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + numBricks += checkBricks(xPos, y, z - 2); + numBricks += checkBricks(xPos, y, z + 2); + } + + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + numBricks += checkBricks(x - 2, y, zPos); + numBricks += checkBricks(x + 2, y, zPos); + } + + if (numBricks == 12 && lavaTanks.size() > 0) + return true; + else + return false; + } + + public int recurseStructureUp (int x, int y, int z, int count) + { + numBricks = 0; + //Check inside + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + Block block = Block.blocksList[worldObj.getBlockId(xPos, y, zPos)]; + if (block != null && !block.isAirBlock(worldObj, xPos, y, zPos)) + return count; + } + } + + //Check outer layer + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + numBricks += checkBricks(xPos, y, z - 2); + numBricks += checkBricks(xPos, y, z + 2); + } + + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + numBricks += checkBricks(x - 2, y, zPos); + numBricks += checkBricks(x + 2, y, zPos); + } + + if (numBricks != 12) + return count; + + count++; + return recurseStructureUp(x, y + 1, z, count); + } + + public int recurseStructureDown (int x, int y, int z, int count) + { + numBricks = 0; + //Check inside + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + int blockID = worldObj.getBlockId(xPos, y, zPos); + Block block = Block.blocksList[blockID]; + if (block != null && !block.isAirBlock(worldObj, xPos, y, zPos)) + { + if (blockID == TContent.smeltery.blockID) + return validateBottom(x, y, z, count); + else + return count; + } + } + } + + //Check outer layer + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + numBricks += checkBricks(xPos, y, z - 2); + numBricks += checkBricks(xPos, y, z + 2); + } + + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + numBricks += checkBricks(x - 2, y, zPos); + numBricks += checkBricks(x + 2, y, zPos); + } + + if (numBricks != 12) + return count; + + count++; + return recurseStructureDown(x, y - 1, z, count); + } + + public int validateBottom (int x, int y, int z, int count) + { + int bottomBricks = 0; + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + if (worldObj.getBlockId(xPos, y, zPos) == TContent.smeltery.blockID && (worldObj.getBlockMetadata(xPos, y, zPos) >= 2)) + bottomBricks++; + } + } + + if (bottomBricks == 9) + { + tempValidStructure = true; + centerPos = new CoordTuple(x, y + 1, z); + } + return count; + } + + /* Returns whether the brick is a lava tank or not. + * Increments bricks, sets them as part of the structure, and adds tanks to the list. + */ + int checkBricks (int x, int y, int z) + { + int tempBricks = 0; + int blockID = worldObj.getBlockId(x, y, z); + if (blockID == TContent.smeltery.blockID || blockID == TContent.lavaTank.blockID) + { + TileEntity te = worldObj.getBlockTileEntity(x, y, z); + if (te == this) + { + tempBricks++; + } + else if (te instanceof MultiServantLogic) + { + MultiServantLogic servant = (MultiServantLogic) te; + if (servant.hasValidMaster()) + { + if (servant.verifyMaster(this.xCoord, this.yCoord, this.zCoord)) + tempBricks++; + } + else if (servant.setMaster(this.xCoord, this.yCoord, this.zCoord)) + { + tempBricks++; + } + + if (te instanceof LavaTankLogic) + { + lavaTanks.add(new CoordTuple(x, y, z)); + } + } + } + return tempBricks; + } + + public int getCapacity () + { + return maxLiquid; + } + + public int getTotalLiquid () + { + return currentLiquid; + } + + @Override + public FluidStack drain (int maxDrain, boolean doDrain) + { + if (moltenMetal.size() == 0) + return null; + + FluidStack liquid = moltenMetal.get(0); + if (liquid.amount - maxDrain <= 0) + { + FluidStack liq = liquid.copy(); + if (doDrain) + { + //liquid = null; + moltenMetal.remove(liquid); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + currentLiquid = 0; + needsUpdate = true; + } + return liq; + } + else + { + if (doDrain) + { + liquid.amount -= maxDrain; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + currentLiquid -= maxDrain; + needsUpdate = true; + } + return new FluidStack(liquid.fluidID, maxDrain, liquid.tag); + } + } + + @Override + public int fill (FluidStack resource, boolean doFill) + { + if (resource != null && resource.amount + currentLiquid < maxLiquid) + { + int amount = resource.amount; + if (doFill) + { + if (addMoltenMetal(resource, false)) + { + ArrayList alloys = Smeltery.mixMetals(moltenMetal); + for (int al = 0; al < alloys.size(); al++) + { + FluidStack liquid = (FluidStack) alloys.get(al); + addMoltenMetal(liquid, true); + } + } + needsUpdate = true; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + return amount; + } + else + return 0; + } + + @Override + public FluidStack getFluid () + { + if (moltenMetal.size() == 0) + return null; + return moltenMetal.get(0); + } + + @Override + public int getFluidAmount () + { + return currentLiquid; + } + + @Override + public FluidTankInfo getInfo () + { + //TODO: This + return null; + } + + /* NBT */ + + @Override + public void readFromNBT (NBTTagCompound tags) + { + layers = tags.getInteger("Layers"); + inventory = new ItemStack[layers * 9]; + super.readFromNBT(tags); + + //validStructure = tags.getBoolean("ValidStructure"); + internalTemp = tags.getInteger("InternalTemp"); + inUse = tags.getBoolean("InUse"); + + int[] center = tags.getIntArray("CenterPos"); + if (center.length > 2) + centerPos = new CoordTuple(center[0], center[1], center[2]); + else + centerPos = new CoordTuple(xCoord, yCoord, zCoord); + + direction = tags.getByte("Direction"); + useTime = tags.getInteger("UseTime"); + currentLiquid = tags.getInteger("CurrentLiquid"); + maxLiquid = tags.getInteger("MaxLiquid"); + meltingTemps = tags.getIntArray("MeltingTemps"); + activeTemps = tags.getIntArray("ActiveTemps"); + + NBTTagList liquidTag = tags.getTagList("Liquids"); + moltenMetal.clear(); + + for (int iter = 0; iter < liquidTag.tagCount(); iter++) + { + NBTTagCompound nbt = (NBTTagCompound) liquidTag.tagAt(iter); + FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt); + moltenMetal.add(fluid); + } + //adjustLayers(layers, true); + //checkValidPlacement(); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + + //tags.setBoolean("ValidStructure", validStructure); + tags.setInteger("InternalTemp", internalTemp); + tags.setBoolean("InUse", inUse); + + int[] center = new int[3];// { centerPos.x, centerPos.y, centerPos.z }; + if (centerPos == null) + center = new int[] { xCoord, yCoord, zCoord }; + else + center = new int[] { centerPos.x, centerPos.y, centerPos.z }; + tags.setIntArray("CenterPos", center); + + tags.setByte("Direction", direction); + tags.setInteger("UseTime", useTime); + tags.setInteger("CurrentLiquid", currentLiquid); + tags.setInteger("MaxLiquid", maxLiquid); + tags.setInteger("Layers", layers); + tags.setIntArray("MeltingTemps", meltingTemps); + tags.setIntArray("ActiveTemps", activeTemps); + + NBTTagList taglist = new NBTTagList(); + for (FluidStack liquid : moltenMetal) + { + NBTTagCompound nbt = new NBTTagCompound(); + liquid.writeToNBT(nbt); + taglist.appendTag(nbt); + } + + tags.setTag("Liquids", taglist); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readFromNBT(packet.customParam1); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } +} diff --git a/tconstruct/blocks/logic/StencilTableLogic.java b/tconstruct/blocks/logic/StencilTableLogic.java new file mode 100644 index 00000000..59461544 --- /dev/null +++ b/tconstruct/blocks/logic/StencilTableLogic.java @@ -0,0 +1,122 @@ +package tconstruct.blocks.logic; + +import tconstruct.common.TContent; +import tconstruct.inventory.PatternShaperContainer; +import tconstruct.library.blocks.InventoryLogic; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class StencilTableLogic extends InventoryLogic implements ISidedInventory +{ + public StencilTableLogic() + { + super(2); + } + + public boolean canUpdate () + { + return false; + } + + @Override + public String getDefaultName () + { + return "toolstation.PatternShaper"; + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return new PatternShaperContainer(inventoryplayer, this); + } + + /*@Override + public void onInventoryChanged() + { + if (inventory[0] == null) + inventory[1] = null; + super.onInventoryChanged(); + }*/ + + @Override + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + super.setInventorySlotContents(slot, itemstack); + if (slot == 0 && itemstack != null && itemstack.getItem() instanceof tconstruct.items.Pattern) + { + if (itemstack.getItemDamage() == 0) + setInventorySlotContents(1, new ItemStack(TContent.woodPattern, 1, 1)); + else if (itemstack.getItemDamage() == 1) + setInventorySlotContents(1, new ItemStack(TContent.metalPattern, 1, 0)); + } + } + + @Override + public ItemStack decrStackSize (int slot, int quantity) + { + if (slot == 1) + { + super.decrStackSize(0, 1); + if (inventory[0] == null) + return super.decrStackSize(slot, quantity); + else + return inventory[1].copy(); + } + else + { + ItemStack ret = super.decrStackSize(slot, quantity); + if (inventory[0] == null) + super.decrStackSize(1, 1); + return ret; + } + } + + public void altDecrStackSize (int slot, int quantity) + { + if (inventory[slot] != null) + { + if (inventory[slot].stackSize <= quantity) + { + ItemStack stack = inventory[slot]; + inventory[slot] = null; + return; + } + ItemStack split = inventory[slot].splitStack(quantity); + if (inventory[slot].stackSize == 0) + { + inventory[slot] = null; + } + return; + } + } + + @Override + public boolean canDropInventorySlot (int slot) + { + if (slot == 0) + return true; + else + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide (int side) + { + return new int[0]; + } + + @Override + public boolean canInsertItem (int i, ItemStack itemstack, int j) + { + return false; + } + + @Override + public boolean canExtractItem (int i, ItemStack itemstack, int j) + { + return false; + } +} diff --git a/tconstruct/blocks/logic/ToolForgeLogic.java b/tconstruct/blocks/logic/ToolForgeLogic.java new file mode 100644 index 00000000..472e6cc3 --- /dev/null +++ b/tconstruct/blocks/logic/ToolForgeLogic.java @@ -0,0 +1,53 @@ +package tconstruct.blocks.logic; + +import tconstruct.inventory.ToolForgeContainer; +import tconstruct.library.crafting.ToolBuilder; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +/* Simple class for storing items in the block + */ + +public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory +{ + ItemStack previousTool; + String toolName; + + public ToolForgeLogic() + { + super(6); + toolName = ""; + } + + @Override + public String getDefaultName () + { + return "toolforge.crafting"; + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return new ToolForgeContainer(inventoryplayer, this); + } + + public void buildTool (String name) + { + toolName = name; + ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name); + if (inventory[0] == null) + inventory[0] = tool; + else + { + NBTTagCompound tags = inventory[0].getTagCompound(); + if (!tags.getCompoundTag("InfiTool").hasKey("Built")) + { + inventory[0] = tool; + } + } + } +} diff --git a/tconstruct/blocks/logic/ToolStationLogic.java b/tconstruct/blocks/logic/ToolStationLogic.java new file mode 100644 index 00000000..9af58d5a --- /dev/null +++ b/tconstruct/blocks/logic/ToolStationLogic.java @@ -0,0 +1,112 @@ +package tconstruct.blocks.logic; + +import tconstruct.inventory.ToolStationContainer; +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.library.crafting.ToolBuilder; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +/* Simple class for storing items in the block + */ + +public class ToolStationLogic extends InventoryLogic implements ISidedInventory +{ + public ItemStack previousTool; + public String toolName; + + public ToolStationLogic() + { + super(4); + toolName = ""; + } + + public ToolStationLogic(int slots) + { + super(slots); + toolName = ""; + } + + public boolean canDropInventorySlot (int slot) + { + if (slot == 0) + return false; + return true; + } + + @Override + public ItemStack getStackInSlotOnClosing (int var1) + { + return null; + } + + @Override + public String getDefaultName () + { + return "toolstation.crafting"; + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return new ToolStationContainer(inventoryplayer, this); + } + + public void onInventoryChanged () + { + buildTool(toolName); + if (this.worldObj != null) + { + this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); + this.worldObj.updateTileEntityChunkAndDoNothing(this.xCoord, this.yCoord, this.zCoord, this); + } + } + + public void buildTool (String name) + { + toolName = name; + ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], name); + if (inventory[0] == null) + inventory[0] = tool; + else + { + NBTTagCompound tags = inventory[0].getTagCompound(); + if (!tags.getCompoundTag("InfiTool").hasKey("Built")) + { + inventory[0] = tool; + } + } + } + + public void setToolname (String name) + { + toolName = name; + buildTool(name); + } + + public boolean canUpdate () + { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide (int side) + { + return new int[0]; + } + + @Override + public boolean canInsertItem (int i, ItemStack itemstack, int j) + { + return false; + } + + @Override + public boolean canExtractItem (int i, ItemStack itemstack, int j) + { + return false; + } +} diff --git a/tconstruct/blocks/traps/BarricadeBlock.java b/tconstruct/blocks/traps/BarricadeBlock.java new file mode 100644 index 00000000..f247c1db --- /dev/null +++ b/tconstruct/blocks/traps/BarricadeBlock.java @@ -0,0 +1,92 @@ +package tconstruct.blocks.traps; + +import tconstruct.client.block.BarricadeRender; +import tconstruct.library.TConstructRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BarricadeBlock extends Block +{ + public BarricadeBlock(int blockID)//, String name, int texture) + { + super(blockID, Material.wood); + setHardness(4.0F); + this.setCreativeTab(TConstructRegistry.blockTab); + //setUnlocalizedName("barricade" + name); + //GameRegistry.addName(this, name + " Barricade"); + } + + public Icon getIcon (int side, int meta) + { + return Block.wood.getIcon(2, meta % 4); + } + + public boolean renderAsNormalBlock () + { + return false; + } + + public boolean isOpaqueCube () + { + return false; + } + + public int getRenderType () + { + return BarricadeRender.model; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int x, int y, int z) + { + return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); + } + + public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int x, int y, int z) + { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta) + { + if (meta % 4 > 0) + { + world.setBlock(x, y, z, this.blockID, meta - 1, 3); + dropBlockAsItem_do(world, x, y, z, new ItemStack(this)); + } + else + { + dropBlockAsItem_do(world, x, y, z, new ItemStack(this)); + } + } + + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) + { + ItemStack stack = player.getCurrentEquippedItem(); + if ((stack != null) && (stack.itemID == this.blockID) && (!player.isSneaking())) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta % 4 != 3) + { + world.setBlock(x, y, z, this.blockID, meta + 1, 3); + Block.blocksList[this.blockID].onBlockPlacedBy(world, x, y, z, player, stack); + Block.blocksList[this.blockID].onPostBlockPlaced(world, x, y, z, meta); + + Block var9 = Block.blocksList[this.blockID]; + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, var9.stepSound.getStepSound(), (var9.stepSound.getVolume() + 1.0F) / 2.0F, var9.stepSound.getPitch() * 0.8F); + player.swingItem(); + if (!player.capabilities.isCreativeMode) + stack.stackSize -= 1; + + return true; + } + } + return false; + } +} \ No newline at end of file diff --git a/tconstruct/blocks/traps/Landmine.java b/tconstruct/blocks/traps/Landmine.java new file mode 100644 index 00000000..89555aa8 --- /dev/null +++ b/tconstruct/blocks/traps/Landmine.java @@ -0,0 +1,280 @@ +package tconstruct.blocks.traps; + +import java.util.Iterator; +import java.util.List; +import java.util.Random; + +import tconstruct.library.TConstructRegistry; + + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFence; +import net.minecraft.block.EnumMobType; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class Landmine extends Block +{ + /** The mob type that can trigger this pressure plate. */ + private EnumMobType triggerMobType; + + public Landmine(int par1, EnumMobType par3EnumMobType, Material par4Material) + { + super(par1, par4Material); + this.triggerMobType = EnumMobType.mobs; + this.setCreativeTab(TConstructRegistry.blockTab); + this.setTickRandomly(true); + float var5 = 0.0625F; + this.setBlockBounds(var5, 0.0F, var5, 1.0F - var5, 0.03125F, 1.0F - var5); + } + + public Icon getBlockTexture (IBlockAccess world, int x, int y, int z, int side) + { + Block block = Block.blocksList[world.getBlockId(x, y - 1, z)]; + if (block != null) + { + return block.getBlockTexture(world, x, y - 1, z, side); + } + return Block.sponge.getIcon(side, world.getBlockMetadata(x, y, z)); + } + + public Icon getIcon (int side, int meta) + { + return Block.sponge.getIcon(1, meta); + } + + public void registerIcons (IconRegister par1IconRegister) + { + + } + + /** + * How many world ticks before ticking + */ + public int tickRate () + { + return 20; + } + + /** + * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been + * cleared to be reused) + */ + public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int par2, int par3, int par4) + { + return null; + } + + /** + * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two + * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. + */ + public boolean isOpaqueCube () + { + return false; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + public boolean renderAsNormalBlock () + { + return false; + } + + public boolean getBlocksMovement (IBlockAccess par1IBlockAccess, int par2, int par3, int par4) + { + return true; + } + + /** + * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z + */ + public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4) + { + return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4)); + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are + * their own) Args: x, y, z, neighbor blockID + */ + public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, int par5) + { + boolean var6 = false; + + if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4))) + { + var6 = true; + } + + if (var6) + { + this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); + //par1World.setBlock(par2, par3, par4, 0); + } + } + + /** + * Ticks the block if it's been scheduled + */ + public void updateTick (World par1World, int par2, int par3, int par4, Random par5Random) + { + if (!par1World.isRemote) + { + if (par1World.getBlockMetadata(par2, par3, par4) != 0) + { + this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4); + } + } + } + + /** + * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity + */ + public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity) + { + if (!par1World.isRemote) + { + if (par1World.getBlockMetadata(par2, par3, par4) != 1) + { + this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4); + } + } + } + + /** + * Checks if there are mobs on the plate. If a mob is on the plate and it is off, it turns it on, and vice versa. + */ + private void setStateIfMobInteractsWithPlate (World world, int posX, int posY, int posZ) + { + boolean var5 = world.getBlockMetadata(posX, posY, posZ) == 1; + boolean var6 = false; + float var7 = 0.125F; + List var8 = null; + + if (this.triggerMobType == EnumMobType.everything) + { + var8 = world.getEntitiesWithinAABBExcludingEntity( + (Entity) null, + AxisAlignedBB.getAABBPool().getAABB((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D, + (double) ((float) (posZ + 1) - var7))); + } + + if (this.triggerMobType == EnumMobType.mobs) + { + var8 = world.getEntitiesWithinAABB( + EntityLiving.class, + AxisAlignedBB.getAABBPool().getAABB((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D, + (double) ((float) (posZ + 1) - var7))); + } + + if (this.triggerMobType == EnumMobType.players) + { + var8 = world.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getAABBPool().getAABB((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D, + (double) ((float) (posZ + 1) - var7))); + } + + if (!var8.isEmpty()) + { + Iterator var9 = var8.iterator(); + + while (var9.hasNext()) + { + Entity var10 = (Entity) var9.next(); + + if (!var10.doesEntityNotTriggerPressurePlate()) + { + var6 = true; + break; + } + } + } + + if (var6 && !var5) + { + world.setBlock(posX, posY, posZ, 0); + world.createExplosion((Entity) null, posX, posY, posZ, 2.0F, true); + /*par1World.setBlockMetadataWithNotify(posX, posY, posZ, 1); + par1World.notifyBlocksOfNeighborChange(posX, posY, posZ, this.blockID); + par1World.notifyBlocksOfNeighborChange(posX, posY - 1, posZ, this.blockID); + par1World.markBlockRangeForRenderUpdate(posX, posY, posZ, posX, posY, posZ); + par1World.playSoundEffect((double)posX + 0.5D, (double)posY + 0.1D, (double)posZ + 0.5D, "random.click", 0.3F, 0.6F);*/ + } + + /*if (!var6 && var5) + { + par1World.setBlockMetadataWithNotify(posX, posY, posZ, 0); + par1World.notifyBlocksOfNeighborChange(posX, posY, posZ, this.blockID); + par1World.notifyBlocksOfNeighborChange(posX, posY - 1, posZ, this.blockID); + par1World.markBlockRangeForRenderUpdate(posX, posY, posZ, posX, posY, posZ); + par1World.playSoundEffect((double)posX + 0.5D, (double)posY + 0.1D, (double)posZ + 0.5D, "random.click", 0.3F, 0.5F); + } + + if (var6) + { + par1World.scheduleBlockUpdate(posX, posY, posZ, this.blockID, this.tickRate()); + }*/ + } + + /** + * ejects contained items into the world, and notifies neighbours of an update, as appropriate + */ + public void breakBlock (World par1World, int par2, int par3, int par4, int par5, int par6) + { + if (par6 > 0) + { + par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID); + par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + /** + * Updates the blocks bounds based on its current state. Args: world, x, y, z + */ + public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4) + { + boolean var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 1; + float var6 = 0.0625F; + + if (var5) + { + this.setBlockBounds(var6, 0.0F, var6, 1.0F - var6, 0.03125F, 1.0F - var6); + } + else + { + this.setBlockBounds(var6, 0.0F, var6, 1.0F - var6, 0.0625F, 1.0F - var6); + } + } + + /** + * Sets the block's bounds for rendering it as an item + */ + public void setBlockBoundsForItemRender () + { + float var1 = 0.5F; + float var2 = 0.125F; + float var3 = 0.5F; + this.setBlockBounds(0.5F - var1, 0.5F - var2, 0.5F - var3, 0.5F + var1, 0.5F + var2, 0.5F + var3); + } + + /** + * Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility + * and stop pistons + */ + public int getMobilityFlag () + { + return 1; + } +} diff --git a/tconstruct/blocks/traps/Punji.java b/tconstruct/blocks/traps/Punji.java new file mode 100644 index 00000000..ae95bd3d --- /dev/null +++ b/tconstruct/blocks/traps/Punji.java @@ -0,0 +1,22 @@ +package tconstruct.blocks.traps; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; + +public class Punji extends Block +{ + + public Punji(int id) + { + super(id, Material.circuits); + } + + @Override + public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity) + { + entity.fallDistance *= 2.0F; + } + +} diff --git a/tconstruct/client/CustomBowRenderer.java b/tconstruct/client/CustomBowRenderer.java new file mode 100644 index 00000000..4d3ea38d --- /dev/null +++ b/tconstruct/client/CustomBowRenderer.java @@ -0,0 +1,151 @@ +package tconstruct.client; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +public class CustomBowRenderer implements IItemRenderer +{ + Minecraft mc = Minecraft.getMinecraft(); + private RenderBlocks renderBlocksInstance = new RenderBlocks(); + + @Override + public boolean handleRenderType (ItemStack item, ItemRenderType type) + { + return type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON; + } + + @Override + public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper) + { + return true; + } + + @Override + public void renderItem (ItemRenderType type, ItemStack item, Object... data) + { + EntityLivingBase living = (EntityLivingBase) data[1]; + ItemRenderer renderer = RenderManager.instance.itemRenderer; + for (int i = 0; i < item.getItem().getRenderPasses(item.getItemDamage()) + 1; i++) + renderItem(living, item, i, type); + } + + public void renderItem (EntityLivingBase living, ItemStack stack, int renderPass, ItemRenderType type) + { + GL11.glPushMatrix(); + + Block block = null; + if (stack.getItem() instanceof ItemBlock && stack.itemID < Block.blocksList.length) + { + block = Block.blocksList[stack.itemID]; + } + + Icon icon = null; //living.getItemIcon(stack, renderPass); + if (living instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) living; + if (player.getItemInUse() != null) + icon = stack.getItem().getIcon(stack, renderPass, player, player.getItemInUse(), player.getItemInUseCount()); + else + icon = living.getItemIcon(stack, renderPass); + } + else + { + icon = living.getItemIcon(stack, renderPass); + } + + if (icon == null) + { + GL11.glPopMatrix(); + return; + } + + /*if (stack.getItemSpriteNumber() == 0) + { + this.mc.renderEngine.bindTexture("/terrain.png"); + } + else + { + this.mc.renderEngine.bindTexture("/gui/items.png"); + }*/ + TextureManager texturemanager = this.mc.func_110434_K(); + texturemanager.func_110577_a(texturemanager.func_130087_a(stack.getItemSpriteNumber())); + + if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) + { + GL11.glTranslatef(0.6F, 0.5F, 0.5F); + } + else + { + GL11.glRotatef(180.0F, 0F, 0F, 1.0F); + GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.75F); + GL11.glTranslatef(-0.6F, -0.25F, 1.0F); + GL11.glScalef(1.75F, 1.75F, 1.75F); + } + + Tessellator tessellator = Tessellator.instance; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float f4 = 0.0F; + float f5 = 0.3F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glTranslatef(-f4, -f5, 0.0F); + float f6 = 1.5F; + GL11.glScalef(f6, f6, f6); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); + ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getOriginX(), icon.getOriginY(), 0.0625F); + + /*if (stack != null && stack.hasEffect() && renderPass == 0) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + this.mc.renderEngine.bindTexture("%blur%/misc/glint.png"); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f7 = 0.76F; + GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f8 = 0.125F; + GL11.glScalef(f8, f8, f8); + float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f9, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f8, f8, f8); + f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f9, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + }*/ + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + + GL11.glPopMatrix(); + } + +} diff --git a/tconstruct/client/CustomFont.java b/tconstruct/client/CustomFont.java new file mode 100644 index 00000000..938ce882 --- /dev/null +++ b/tconstruct/client/CustomFont.java @@ -0,0 +1,283 @@ +package tconstruct.client; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.InputStream; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.Tessellator; + +import org.lwjgl.opengl.GL11; + +/** + * + * @author TheObliterator + * + * A class to create and draw true type + * fonts onto the Minecraft game engine. + */ +public class CustomFont +{ + private int texID; + private int[] xPos; + private int[] yPos; + private int startChar; + private int endChar; + private FontMetrics metrics; + + /** + * Instantiates the font, filling in default start + * and end character parameters. + * + * 'new CustomFont(ModLoader.getMinecraftInstance(), + * "Arial", 12); + * + * @param mc The Minecraft instance for the font to be bound to. + * @param fontName The name of the font to be drawn. + * @param size The size of the font to be drawn. + */ + public CustomFont(Minecraft mc, Object font, int size) + { + this(mc, font, size, 0, 4000); + } + + /** + * Instantiates the font, pre-rendering a sprite + * font image by using a true type font on a + * bitmap. Then allocating that bitmap to the + * Minecraft rendering engine for later use. + * + * 'new CustomFont(ModLoader.getMinecraftInstance(), + * "Arial", 12, 32, 126);' + * + * @param mc The Minecraft instance for the font to be bound to. + * @param fontName The name of the font to be drawn. + * @param size The size of the font to be drawn. + * @param startChar The starting ASCII character id to be drawable. (Default 32) + * @param endChar The ending ASCII character id to be drawable. (Default 126) + */ + public CustomFont(Minecraft mc, Object font, int size, int startChar, int endChar) + { + this.startChar = startChar; + this.endChar = endChar; + xPos = new int[endChar - startChar]; + yPos = new int[endChar - startChar]; + + // Create a bitmap and fill it with a transparent color as well + // as obtain a Graphics instance which can be drawn on. + // NOTE: It is CRUICIAL that the size of the image is 256x256, if + // it is not the Minecraft engine will not draw it properly. + BufferedImage img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB); + Graphics g = img.getGraphics(); + try + { + if (font instanceof String) + { + String fontName = (String) font; + if (fontName.contains("/")) + g.setFont(Font.createFont(Font.TRUETYPE_FONT, new File(fontName)).deriveFont((float) size)); + else + g.setFont(new Font(fontName, 0, size)); + } + else if (font instanceof InputStream) + { + g.setFont(Font.createFont(Font.TRUETYPE_FONT, (InputStream) font).deriveFont((float) size)); + } + else if (font instanceof File) + { + g.setFont(Font.createFont(Font.TRUETYPE_FONT, (File) font).deriveFont((float) size)); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + + g.setColor(new Color(255, 255, 255, 0)); + g.fillRect(0, 0, 256, 256); + g.setColor(Color.white); + metrics = g.getFontMetrics(); + + // Draw the specified range of characters onto + // the new bitmap, spacing according to the font + // widths. Also allocating positions of characters + // on the bitmap to two arrays which will be used + // later when drawing. + int x = 2; + int y = 2; + for (int i = startChar; i < endChar; i++) + { + g.drawString("" + ((char) i), x, y + g.getFontMetrics().getAscent()); + xPos[i - startChar] = x; + yPos[i - startChar] = y - metrics.getMaxDescent(); + x += metrics.stringWidth("" + (char) i) + 2; + if (x >= 250 - metrics.getMaxAdvance()) + { + x = 2; + y += metrics.getMaxAscent() + metrics.getMaxDescent() + size / 2; + } + } + + // Render the finished bitmap into the Minecraft + // graphics engine. + // Sadly broken by 1.6 + //texID = mc.renderEngine.allocateAndSetupTexture(img); + } + + /** + * Draws a given string with an automatically + * calculated shadow below it. + * @param gui The gui/subclass to be drawn on + * @param text The string to be drawn + * @param x The x position to start drawing + * @param y The y position to start drawing + * @param color The color of the non-shadowed text (Hex) + */ + public void drawStringS (Gui gui, String text, int x, int y, int color) + { + int l = color & 0xff000000; + int shade = (color & 0xfcfcfc) >> 2; + shade += l; + drawString(gui, text, x + 1, y + 1, shade); + drawString(gui, text, x, y, color); + } + + /** + * Draws a given string onto a gui/subclass. + * @param gui The gui/subclass to be drawn on + * @param text The string to be drawn + * @param x The x position to start drawing + * @param y The y position to start drawing + * @param color The color of the non-shadowed text (Hex) + */ + public void drawString (Gui gui, String text, int x, int y, int color) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(3553 /*GL_TEXTURE_2D*/); + GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, texID); + float red = (float) (color >> 16 & 0xff) / 255F; + float green = (float) (color >> 8 & 0xff) / 255F; + float blue = (float) (color & 0xff) / 255F; + float alpha = (float) (color >> 24 & 0xff) / 255F; + GL11.glColor4f(red, green, blue, alpha); + int startX = x; + for (int i = 0; i < text.length(); i++) + { + char c = text.charAt(i); + if (c == '\\') + { + char type = text.charAt(i + 1); + if (type == 'n') + { + y += metrics.getAscent() + 2; + x = startX; + } + i++; + continue; + } + drawChar(gui, c, x, y); + x += metrics.getStringBounds("" + c, null).getWidth(); + } + } + + /** + * Returns the created FontMetrics + * which is used to retrive various + * information about the True Type Font + * @return FontMetrics of the created font. + */ + public FontMetrics getMetrics () + { + return metrics; + } + + /** + * Gets the drawing width of a given + * string of string. + * @param text The string to be measured + * @return The width of the given string. + */ + public int getStringWidth (String text) + { + return (int) getBounds(text).getWidth(); + } + + /** + * Gets the drawing height of a given + * string of string. + * @param text The string to be measured + * @return The height of the given string. + */ + public int getStringHeight (String text) + { + return (int) getBounds(text).getHeight(); + } + + /** + * A method that returns a Rectangle that + * contains the width and height demensions + * of the given string. + * @param text The string to be measured + * @return Rectangle containing width and height that + * the text will consume when drawn. + */ + private Rectangle getBounds (String text) + { + int w = 0; + int h = 0; + int tw = 0; + for (int i = 0; i < text.length(); i++) + { + char c = text.charAt(i); + if (c == '\\') + { + char type = text.charAt(i + 1); + + if (type == 'n') + { + h += metrics.getAscent() + 2; + if (tw > w) + w = tw; + tw = 0; + } + i++; + continue; + } + tw += metrics.stringWidth("" + c); + } + if (tw > w) + w = tw; + h += metrics.getAscent(); + return new Rectangle(0, 0, w, h); + } + + /** + * Private drawing method used within other + * drawing methods. + */ + private void drawChar (Gui gui, char c, int x, int y) + { + Rectangle2D bounds = metrics.getStringBounds("" + c, null); + drawTexturedModalRect(x, y, xPos[(byte) c - startChar], yPos[(byte) c - startChar], (int) bounds.getWidth(), (int) bounds.getHeight() + metrics.getMaxDescent()); + } + + public void drawTexturedModalRect (int x, int y, int u, int v, int width, int height) + { + float offsetWidth = 0.00390625F; + float offsetHeight = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((x + 0), (y + height), 0, ((u + 0) * offsetWidth), ((v + height) * offsetHeight)); + tessellator.addVertexWithUV((x + width), (y + height), 0, ((u + width) * offsetWidth), ((v + height) * offsetHeight)); + tessellator.addVertexWithUV((x + width), (y + 0), 0, ((u + width) * offsetWidth), ((v + 0) * offsetHeight)); + tessellator.addVertexWithUV((x + 0), (y + 0), 0, ((u + 0) * offsetWidth), ((v + 0) * offsetHeight)); + tessellator.draw(); + } +} \ No newline at end of file diff --git a/tconstruct/client/RenderItemCopy.java b/tconstruct/client/RenderItemCopy.java new file mode 100644 index 00000000..302eb657 --- /dev/null +++ b/tconstruct/client/RenderItemCopy.java @@ -0,0 +1,669 @@ +package tconstruct.client; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import tconstruct.client.block.SmallFontRenderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class RenderItemCopy extends Render +{ + private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private RenderBlocks itemRenderBlocks = new RenderBlocks(); + + /** The RNG used in RenderItem (for bobbing itemstacks on the ground) */ + private Random random = new Random(); + public boolean renderWithColor = true; + + /** Defines the zLevel of rendering of item on GUI. */ + public float zLevel; + public static boolean renderInFrame; + + public RenderItemCopy() + { + this.shadowSize = 0.15F; + this.shadowOpaque = 0.75F; + } + + /** + * Renders the item + */ + public void doRenderItem (EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9) + { + this.func_110777_b(par1EntityItem); + this.random.setSeed(187L); + ItemStack itemstack = par1EntityItem.getEntityItem(); + + if (itemstack.getItem() != null) + { + GL11.glPushMatrix(); + float f2 = shouldBob() ? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F; + float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI); + byte b0 = getMiniBlockCount(itemstack); + + GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f4; + float f5; + float f6; + int i; + + Block block = null; + if (itemstack.itemID < Block.blocksList.length) + { + block = Block.blocksList[itemstack.itemID]; + } + + if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, renderBlocks)) + { + ; + } + else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType())) + { + GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); + + if (renderInFrame) + { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glTranslatef(0.0F, 0.05F, 0.0F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + + float f7 = 0.25F; + int j = block.getRenderType(); + + if (j == 1 || j == 19 || j == 12 || j == 2) + { + f7 = 0.5F; + } + + GL11.glScalef(f7, f7, f7); + + for (i = 0; i < b0; ++i) + { + GL11.glPushMatrix(); + + if (i > 0) + { + f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + GL11.glTranslatef(f5, f4, f6); + } + + f5 = 1.0F; + this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5); + GL11.glPopMatrix(); + } + } + else + { + float f8; + + if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses()) + { + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) + { + this.random.setSeed(187L); + Icon icon = itemstack.getItem().getIcon(itemstack, k); + f8 = 1.0F; + + if (this.renderWithColor) + { + i = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, k); + f5 = (float) (i >> 16 & 255) / 255.0F; + f4 = (float) (i >> 8 & 255) / 255.0F; + f6 = (float) (i & 255) / 255.0F; + GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F); + this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k); + } + else + { + this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F, k); + } + } + } + else + { + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + Icon icon1 = itemstack.getIconIndex(); + + if (this.renderWithColor) + { + int l = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, 0); + f8 = (float) (l >> 16 & 255) / 255.0F; + float f9 = (float) (l >> 8 & 255) / 255.0F; + f5 = (float) (l & 255) / 255.0F; + f4 = 1.0F; + this.renderDroppedItem(par1EntityItem, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4); + } + else + { + this.renderDroppedItem(par1EntityItem, icon1, b0, par9, 1.0F, 1.0F, 1.0F); + } + } + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation func_110796_a (EntityItem par1EntityItem) + { + return this.renderManager.renderEngine.func_130087_a(par1EntityItem.getEntityItem().getItemSpriteNumber()); + } + + /** + * Renders a dropped item + */ + private void renderDroppedItem (EntityItem par1EntityItem, Icon par2Icon, int par3, float par4, float par5, float par6, float par7) + { + renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0); + } + + private void renderDroppedItem (EntityItem par1EntityItem, Icon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass) + { + Tessellator tessellator = Tessellator.instance; + + if (par2Icon == null) + { + TextureManager texturemanager = Minecraft.getMinecraft().func_110434_K(); + ResourceLocation resourcelocation = texturemanager.func_130087_a(par1EntityItem.getEntityItem().getItemSpriteNumber()); + par2Icon = ((TextureMap) texturemanager.func_110581_b(resourcelocation)).func_110572_b("missingno"); + } + + float f4 = ((Icon) par2Icon).getMinU(); + float f5 = ((Icon) par2Icon).getMaxU(); + float f6 = ((Icon) par2Icon).getMinV(); + float f7 = ((Icon) par2Icon).getMaxV(); + float f8 = 1.0F; + float f9 = 0.5F; + float f10 = 0.25F; + float f11; + + if (this.renderManager.options.fancyGraphics) + { + GL11.glPushMatrix(); + + if (renderInFrame) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + else + { + GL11.glRotatef((((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); + } + + float f12 = 0.0625F; + f11 = 0.021875F; + ItemStack itemstack = par1EntityItem.getEntityItem(); + int j = itemstack.stackSize; + byte b0 = getMiniItemCount(itemstack); + + GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F)); + + for (int k = 0; k < b0; ++k) + { + // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... + if (k > 0 && shouldSpreadItems()) + { + float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + GL11.glTranslatef(x, y, f12 + f11); + } + else + { + GL11.glTranslatef(0f, 0f, f12 + f11); + } + + if (itemstack.getItemSpriteNumber() == 0) + { + this.func_110776_a(TextureMap.field_110575_b); + } + else + { + this.func_110776_a(TextureMap.field_110576_c); + } + + GL11.glColor4f(par5, par6, par7, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((Icon) par2Icon).getOriginX(), ((Icon) par2Icon).getOriginY(), f12); + + if (itemstack.hasEffect(pass)) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + this.renderManager.renderEngine.func_110577_a(field_110798_h); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f13 = 0.76F; + GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f14 = 0.125F; + GL11.glScalef(f14, f14, f14); + float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f15, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f14, f14, f14); + f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f15, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + GL11.glPopMatrix(); + } + else + { + for (int l = 0; l < par3; ++l) + { + GL11.glPushMatrix(); + + if (l > 0) + { + f11 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + GL11.glTranslatef(f11, f16, f17); + } + + if (!renderInFrame) + { + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + } + + GL11.glColor4f(par5, par6, par7, 1.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double) (0.0F - f9), (double) (0.0F - f10), 0.0D, (double) f4, (double) f7); + tessellator.addVertexWithUV((double) (f8 - f9), (double) (0.0F - f10), 0.0D, (double) f5, (double) f7); + tessellator.addVertexWithUV((double) (f8 - f9), (double) (1.0F - f10), 0.0D, (double) f5, (double) f6); + tessellator.addVertexWithUV((double) (0.0F - f9), (double) (1.0F - f10), 0.0D, (double) f4, (double) f6); + tessellator.draw(); + GL11.glPopMatrix(); + } + } + } + + /** + * Renders the item's icon or block into the UI at the specified position. + */ + public void renderItemIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false); + } + + public void renderItemIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect) + { + int k = par3ItemStack.itemID; + int l = par3ItemStack.getItemDamage(); + Object object = par3ItemStack.getIconIndex(); + float f; + int i1; + float f1; + float f2; + + Block block = (k < Block.blocksList.length ? Block.blocksList[k] : null); + if (par3ItemStack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[k].getRenderType())) + { + par2TextureManager.func_110577_a(TextureMap.field_110575_b); + GL11.glPushMatrix(); + GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel); + GL11.glScalef(10.0F, 10.0F, 10.0F); + GL11.glTranslatef(1.0F, 0.5F, 1.0F); + GL11.glScalef(1.0F, 1.0F, -1.0F); + GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); + f = (float) (i1 >> 16 & 255) / 255.0F; + f1 = (float) (i1 >> 8 & 255) / 255.0F; + f2 = (float) (i1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f, f1, f2, 1.0F); + } + + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + this.itemRenderBlocks.useInventoryTint = this.renderWithColor; + this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F); + this.itemRenderBlocks.useInventoryTint = true; + GL11.glPopMatrix(); + } + else if (Item.itemsList[k].requiresMultipleRenderPasses()) + { + GL11.glDisable(GL11.GL_LIGHTING); + + for (int j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1) + { + par2TextureManager.func_110577_a(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.field_110575_b : TextureMap.field_110576_c); + Icon icon = Item.itemsList[k].getIcon(par3ItemStack, j1); + int k1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, j1); + f1 = (float) (k1 >> 16 & 255) / 255.0F; + f2 = (float) (k1 >> 8 & 255) / 255.0F; + float f3 = (float) (k1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f1, f2, f3, 1.0F); + } + + this.renderIcon(par4, par5, icon, 16, 16); + + if (par3ItemStack.hasEffect(j1)) + { + renderEffect(par2TextureManager, par4, par5); + } + } + + GL11.glEnable(GL11.GL_LIGHTING); + } + else + { + GL11.glDisable(GL11.GL_LIGHTING); + ResourceLocation resourcelocation = par2TextureManager.func_130087_a(par3ItemStack.getItemSpriteNumber()); + par2TextureManager.func_110577_a(resourcelocation); + + if (object == null) + { + object = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(resourcelocation)).func_110572_b("missingno"); + } + + i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); + f = (float) (i1 >> 16 & 255) / 255.0F; + f1 = (float) (i1 >> 8 & 255) / 255.0F; + f2 = (float) (i1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f, f1, f2, 1.0F); + } + + this.renderIcon(par4, par5, (Icon) object, 16, 16); + GL11.glEnable(GL11.GL_LIGHTING); + + if (par3ItemStack.hasEffect(0)) + { + renderEffect(par2TextureManager, par4, par5); + } + } + + GL11.glEnable(GL11.GL_CULL_FACE); + } + + private void renderEffect (TextureManager manager, int x, int y) + { + GL11.glDepthFunc(GL11.GL_GREATER); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + manager.func_110577_a(field_110798_h); + this.zLevel -= 50.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + this.zLevel += 50.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + /** + * Render the item's icon or block into the GUI, including the glint effect. + */ + public void renderItemAndEffectIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + if (par3ItemStack != null) + { + if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5)) + { + this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true); + } + + /* Modders must handle this themselves if they use custom renderers! + if (par3ItemStack.hasEffect()) + { + GL11.glDepthFunc(GL11.GL_GREATER); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + par2TextureManager.func_110577_a(field_110798_h); + this.zLevel -= 50.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + this.zLevel += 50.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + */ + } + } + + private void renderGlint (int par1, int par2, int par3, int par4, int par5) + { + for (int j1 = 0; j1 < 2; ++j1) + { + if (j1 == 0) + { + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + } + + if (j1 == 1) + { + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + } + + float f = 0.00390625F; + float f1 = 0.00390625F; + float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F; + float f3 = 0.0F; + Tessellator tessellator = Tessellator.instance; + float f4 = 4.0F; + + if (j1 == 1) + { + f4 = -1.0F; + } + + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); + tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f), + (double) ((f3 + (float) par5) * f1)); + tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.draw(); + } + } + + /** + * Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the + * specified position. + */ + public void renderItemOverlayIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String) null); + } + + public void renderItemOverlayIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str) + { + if (par3ItemStack != null) + { + if (par3ItemStack.stackSize > 1 || par6Str != null) + { + String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + if (par3ItemStack.isItemDamaged()) + { + int k = (int) Math.round(13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage()); + int l = (int) Math.round(255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage()); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + Tessellator tessellator = Tessellator.instance; + int i1 = 255 - l << 16 | l << 8; + int j1 = (255 - l) / 4 << 16 | 16128; + this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); + this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1); + this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + } + + /** + * Adds a quad to the tesselator at the specified position with the set width and height and color. Args: + * tessellator, x, y, width, height, color + */ + private void renderQuad (Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6) + { + par1Tessellator.startDrawingQuads(); + par1Tessellator.setColorOpaque_I(par6); + par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + 0), 0.0D); + par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + par5), 0.0D); + par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D); + par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + 0), 0.0D); + par1Tessellator.draw(); + } + + public void renderIcon (int par1, int par2, Icon par3Icon, int par4, int par5) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV()); + tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV()); + tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV()); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); + tessellator.draw(); + } + + protected ResourceLocation func_110775_a (Entity par1Entity) + { + return this.func_110796_a((EntityItem) par1Entity); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render 1) + ret = 2; + if (stack.stackSize > 5) + ret = 3; + if (stack.stackSize > 20) + ret = 4; + if (stack.stackSize > 40) + ret = 5; + return ret; + } + + /** + * Allows for a subclass to override how many rendered items appear in a + * "mini item 3d stack" + * @param stack + * @return + */ + public byte getMiniItemCount (ItemStack stack) + { + byte ret = 1; + if (stack.stackSize > 1) + ret = 2; + if (stack.stackSize > 15) + ret = 3; + if (stack.stackSize > 31) + ret = 4; + return ret; + } +} diff --git a/tconstruct/client/SuperSoakerRender.java b/tconstruct/client/SuperSoakerRender.java new file mode 100644 index 00000000..debc1a89 --- /dev/null +++ b/tconstruct/client/SuperSoakerRender.java @@ -0,0 +1,43 @@ +package tconstruct.client; + +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; + +public class SuperSoakerRender implements IItemRenderer +{ + + @Override + public boolean handleRenderType (ItemStack item, ItemRenderType type) + { + return type != ItemRenderType.INVENTORY; + } + + @Override + public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper) + { + return true; + } + + @Override + public void renderItem (ItemRenderType type, ItemStack item, Object... data) + { + if (type == ItemRenderType.EQUIPPED) + renderEquippedItem(item, (RenderBlocks) data[0], (EntityLiving) data[1]); + if (type == ItemRenderType.ENTITY) + renderEntityItem(item, (RenderBlocks) data[0], (EntityItem) data[1]); + } + + void renderEquippedItem (ItemStack item, RenderBlocks renderBlocks, EntityLiving entityLiving) + { + + } + + void renderEntityItem (ItemStack item, RenderBlocks renderBlocks, EntityItem entityItem) + { + + } + +} diff --git a/tconstruct/client/TClientEvents.java b/tconstruct/client/TClientEvents.java new file mode 100644 index 00000000..21d70db4 --- /dev/null +++ b/tconstruct/client/TClientEvents.java @@ -0,0 +1,187 @@ +package tconstruct.client; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.EntityLiving; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.client.event.sound.SoundLoadEvent; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import tconstruct.TConstruct; +import tconstruct.blocks.LiquidMetalFinite; +import tconstruct.client.armor.WingModel; +import tconstruct.common.TContent; +import tconstruct.util.player.TPlayerStats; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class TClientEvents +{ + Minecraft mc = Minecraft.getMinecraft(); + + /*@ForgeSubscribe + public void interact (PlayerInteractEvent event) + { + if (event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote) + { + System.out.println("Fired"); + List skills = TProxyClient.skillList; + if (skills.size() > 0) + { + Skill walls = TConstruct.playerTracker.getPlayerStats(event.entityPlayer.username).skillList.get(0); + walls.rightClickActivate(event.entityPlayer, event.entityPlayer.worldObj); + } + } + }*/ + + /* Sounds */ + /*@ForgeSubscribe + public void onSound (SoundLoadEvent event) + { + try + { + event.manager.soundPoolSounds.addSound("sounds/frypan_hit.ogg", TConstruct.class.getResource("/sounds/frypan_hit.ogg")); + event.manager.soundPoolSounds.addSound("sounds/little_saw.ogg", TConstruct.class.getResource("/sounds/little_saw.ogg")); + event.manager.soundPoolSounds.addSound("sounds/launcher_clank.ogg", TConstruct.class.getResource("/sounds/launcher_clank.ogg")); + System.out.println("[TConstruct] Successfully loaded sounds."); + } + catch (Exception e) + { + System.err.println("[TConstruct] Failed to register one or more sounds"); + } + }*/ + + /* Liquids */ + @ForgeSubscribe + public void postStitch (TextureStitchEvent.Post event) + { + for (int i = 0; i < TContent.fluids.length; i++) + { + if (TContent.fluidBlocks[i] instanceof LiquidMetalFinite) + { + LiquidMetalFinite block = (LiquidMetalFinite) TContent.fluidBlocks[i]; + TContent.fluids[i].setIcons(block.stillIcon, block.flowIcon); + } + Fluid lava = FluidRegistry.getFluid("lava"); + lava.setIcons(Block.lavaStill.getIcon(0, 0), Block.lavaStill.getIcon(2, 0)); + Fluid lavawater = FluidRegistry.getFluid("water"); + lava.setIcons(Block.waterStill.getIcon(0, 0), Block.waterStill.getIcon(2, 0)); + } + } + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/newhearts.png"); + + /* HUD */ + @ForgeSubscribe + public void renderHealthbar (RenderGameOverlayEvent.Post event) + { + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + int scaledWidth = scaledresolution.getScaledWidth(); + int scaledHeight = scaledresolution.getScaledHeight(); + int xBasePos = scaledWidth / 2 - 91; + int yBasePos = scaledHeight - 39; + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(mc.thePlayer.username); + + PotionEffect potion = mc.thePlayer.getActivePotionEffect(Potion.wither); + if (potion != null) + return; + potion = mc.thePlayer.getActivePotionEffect(Potion.poison); + if (potion != null) + return; + + /*if (event.type == RenderGameOverlayEvent.ElementType.HEALTH) + { + this.mc.func_110434_K().func_110577_a(background); + + int hp = mc.thePlayer.getHealth(); + for (int iter = 0; iter < hp / 20; iter++) + { + int renderHearts = (hp - 20 * (iter + 1)) / 2; + if (renderHearts > 10) + renderHearts = 10; + for (int i = 0; i < renderHearts; i++) + { + this.drawTexturedModalRect(xBasePos + 8 * i, yBasePos, 0 + 18 * iter, 0, 8, 8); + } + if (hp % 2 == 1 && renderHearts < 10) + { + this.drawTexturedModalRect(xBasePos + 8 * renderHearts, yBasePos, 9 + 18 * iter, 0, 8, 8); + } + } + + this.mc.renderEngine.bindTexture("/gui/icons.png"); + }*/ + + /*if (event.type == RenderGameOverlayEvent.ElementType.HOTBAR) + { + if (stats.skillList == null) + return; + + int amount = 0; + GL11.glScalef(1/16f, 1/16f, 1/16f); + for (Skill skill : stats.skillList) + { + if (!skill.getActive()) + GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0F); + this.mc.renderEngine.bindTexture(skill.getTextureFile(scaledresolution.getScaleFactor())); + this.drawTexturedModalRect((2+amount*18)*16, 32, 0, 0, 256, 256); + amount++; + } + GL11.glScalef(16f, 16f, 16f); + }*/ + } + + public void drawTexturedModalRect (int par1, int par2, int par3, int par4, int par5, int par6) + { + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + par6) * f1)); + tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + par6) * f1)); + tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + 0) * f1)); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + 0) * f1)); + tessellator.draw(); + } + + double zLevel = 0; + + /* Armor */ + ModelBiped model = new ModelBiped(5f); + WingModel wings = new WingModel(); + + /*static + { + model.bipedHead.showModel = false; + }*/ + + private float interpolateRotation (float par1, float par2, float par3) + { + float f3; + + for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F) + { + ; + } + + while (f3 >= 180.0F) + { + f3 -= 360.0F; + } + + return par1 + par3 * f3; + } + + protected float handleRotationFloat (EntityLiving par1EntityLiving, float par2) + { + return (float) par1EntityLiving.ticksExisted + par2; + } +} diff --git a/tconstruct/client/TClientTickHandler.java b/tconstruct/client/TClientTickHandler.java new file mode 100644 index 00000000..255aebdd --- /dev/null +++ b/tconstruct/client/TClientTickHandler.java @@ -0,0 +1,88 @@ +package tconstruct.client; + +import java.util.EnumSet; + +import tconstruct.common.TContent; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.player.EntityPlayer; +import cpw.mods.fml.common.ITickHandler; +import cpw.mods.fml.common.TickType; + +public class TClientTickHandler implements ITickHandler +{ + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayer player; + int zLevel = 0; + int ticks = 0; + + @Override + public void tickEnd (EnumSet type, Object... tickData) + { + TContent.oreBerry.setGraphicsLevel(Block.leaves.graphicsLevel); + TContent.oreBerrySecond.setGraphicsLevel(Block.leaves.graphicsLevel); + + /*player = mc.thePlayer; + if (player == null || player.capabilities.isCreativeMode) + return; + + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + int scaledWidth = scaledresolution.getScaledWidth(); + int scaledHeight = scaledresolution.getScaledHeight(); + int xBasePos = scaledWidth / 2 - 91; + int yBasePos = scaledHeight - 39; + this.mc.renderEngine.bindTexture("/mods/tinker/textures/gui/newhearts.png"); + + int hp = player.getHealth(); + for (int iter = 0; iter < hp / 20; iter++) + { + int renderHearts = (hp - 20*(iter+1)) / 2; + if (renderHearts > 10) + renderHearts = 10; + for (int i = 0; i < renderHearts; i++) + { + this.drawTexturedModalRect(xBasePos + 8*i, yBasePos, 0 + 18*iter, 0, 8, 8); + } + if (hp % 2 == 1 && renderHearts < 10) + { + this.drawTexturedModalRect(xBasePos + 8*renderHearts, yBasePos, 9 + 18*iter, 0, 8, 8); + } + }*/ + } + + @Override + public EnumSet ticks () + { + return EnumSet.of(TickType.RENDER); + //return EnumSet.of(TickType.PLAYER); + } + + public void drawTexturedModalRect (int par1, int par2, int par3, int par4, int par5, int par6) + { + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + par6) * f1)); + tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + par6) * f1)); + tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + 0) * f1)); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + 0) * f1)); + tessellator.draw(); + } + + @Override + public void tickStart (EnumSet type, Object... tickData) + { + // TODO Auto-generated method stub + + } + + @Override + public String getLabel () + { + // TODO Auto-generated method stub + return null; + } +} diff --git a/tconstruct/client/TControls.java b/tconstruct/client/TControls.java new file mode 100644 index 00000000..9f575835 --- /dev/null +++ b/tconstruct/client/TControls.java @@ -0,0 +1,297 @@ +package tconstruct.client; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.util.EnumSet; + +import tconstruct.TConstruct; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.server.MinecraftServer; +import cpw.mods.fml.common.TickType; +import cpw.mods.fml.common.network.PacketDispatcher; + +public class TControls extends TKeyHandler +{ + //static KeyBinding grabKey = new KeyBinding("key.grab", 29); + //static KeyBinding stiltsKey = new KeyBinding("key.stilts", 46); + public static KeyBinding armorKey = new KeyBinding("key.tarmor", 24); + /*public static KeyBinding skillOne = new KeyBinding("key.skill.one", 44); + public static KeyBinding skillTwo = new KeyBinding("key.skill.two", 45); + public static KeyBinding skillThree = new KeyBinding("key.skill.three", 46); + public static KeyBinding skillFour = new KeyBinding("key.skill.four", 47); + public static KeyBinding skillFive = new KeyBinding("key.skill.five", 48);*/ + static KeyBinding jumpKey; + static KeyBinding invKey; + static Minecraft mc; + + boolean jumping; + boolean doubleJump = true; + boolean climbing = false; + boolean onGround = false; + boolean onStilts = false; + + int currentTab = 1; + + //boolean onStilts = false; + + public TControls() + { + super(new KeyBinding[] { armorKey /*, skillOne, skillTwo, skillThree, skillFour, skillFive*/}, new boolean[] { false /*, false, false, false, false, false*/}, getVanillaKeyBindings(), + new boolean[] { false, false }); + //System.out.println("Controls registered");Natura + } + + private static KeyBinding[] getVanillaKeyBindings () + { + mc = Minecraft.getMinecraft(); + jumpKey = mc.gameSettings.keyBindJump; + invKey = mc.gameSettings.keyBindInventory; + return new KeyBinding[] { jumpKey, invKey }; + } + + @Override + public String getLabel () + { + return null; + } + + @Override + public void keyDown (EnumSet types, KeyBinding kb, boolean tickEnd, boolean isRepeat) + { + if (tickEnd && mc.theWorld != null) + { + if (kb == armorKey && mc.currentScreen == null) //Extended Armor + { + openArmorGui();//mc.thePlayer.username); + } + if (kb == invKey && mc.currentScreen != null && mc.currentScreen.getClass() == GuiInventory.class)// && !mc.playerController.isInCreativeMode()) + { + TProxyClient.addTabsToInventory((GuiContainer) mc.currentScreen); + } + /*if (kb == skillOne) + { + sendSkillkey(mc.thePlayer, (byte) 0);//, mc.thePlayer.dimension, mc.thePlayer.entityId); + } + if (kb == skillTwo) + { + sendSkillkey(mc.thePlayer, (byte) 1);//, mc.thePlayer.dimension, mc.thePlayer.entityId); + } + if (kb == skillThree) + { + sendSkillkey(mc.thePlayer, (byte) 2);//, mc.thePlayer.dimension, mc.thePlayer.entityId); + } + if (kb == skillFour) + { + sendSkillkey(mc.thePlayer, (byte) 3);//, mc.thePlayer.dimension, mc.thePlayer.entityId); + } + if (kb == skillFive) + { + sendSkillkey(mc.thePlayer, (byte) 4);//, mc.thePlayer.dimension, mc.thePlayer.entityId); + }*/ + /*if (kb == jumpKey) //Double jump + { + if (jumping && !doubleJump) + { + //if (player == null) + //player = mc.thePlayer; + + mc.thePlayer.motionY = 0.42D; + mc.thePlayer.fallDistance = 0; + + if (mc.thePlayer.isPotionActive(Potion.jump)) + { + mc.thePlayer.motionY += (double) ((float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); + } + + doubleJump = true; + resetFallDamage(mc.thePlayer.username); + } + + if (!jumping) + jumping = mc.thePlayer.isAirBorne; + }*/ + } + /*else if (kb == stiltsKey) //Stilts + { + float size = 1.8F; + if (!onStilts) + size = 0.8F; + TConstruct.playerTracker.updateSize(mc.thePlayer.username, size); + onStilts = !onStilts; + //updateServer(mc.thePlayer.username, (byte) 11); + if (onStilts) + { + onStilts = false; + } + else + { + onStilts = true; + } + }*/ + } + + @Override + public void keyUp (EnumSet types, KeyBinding kb, boolean tickEnd) + { + //landOnGround(); + } + + @Override + public EnumSet ticks () + { + return EnumSet.of(TickType.CLIENT); + } + + public void landOnGround () + { + doubleJump = false; + jumping = false; + } + + public void resetControls () + { + doubleJump = false; + jumping = false; + climbing = false; + onGround = false; + onStilts = false; + } + + void resetFallDamage (String name) + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(10); + outputStream.writeUTF(name); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + updateServer(bos); + } + + void updateSize (String name, float size) + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(11); + outputStream.writeUTF(name); + outputStream.writeFloat(size); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + updateServer(bos); + } + + public static void openInventoryGui () + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(3); + outputStream.writeByte(0); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + updateServer(bos); + } + + public static void openArmorGui () + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(3); + outputStream.writeByte(1); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + updateServer(bos); + } + + public static void openKnapsackGui () + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(3); + outputStream.writeByte(2); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + updateServer(bos); + } + + /*public void activateSkill (EntityPlayer player, int slot) + { + if (TProxyClient.skillList.size() > slot) + { + Skill skill = TProxyClient.skillList.get(slot); + if (skill != null) + { + skill.activate(player, player.worldObj); + } + } + }*/ + + public void sendSkillkey (EntityPlayer player, byte key) + { + TConstruct.playerTracker.activateSkill(player, key); + + System.out.println(MinecraftServer.getServer()); + if (MinecraftServer.getServer().isDedicatedServer()) + { + System.out.println("Send"); + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(4); + outputStream.writeByte(key); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + updateServer(bos); + } + } + + static void updateServer (ByteArrayOutputStream bos) + { + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "TConstruct"; + packet.data = bos.toByteArray(); + packet.length = bos.size(); + + PacketDispatcher.sendPacketToServer(packet); + } +} diff --git a/tconstruct/client/TKeyHandler.java b/tconstruct/client/TKeyHandler.java new file mode 100644 index 00000000..e93f9b3a --- /dev/null +++ b/tconstruct/client/TKeyHandler.java @@ -0,0 +1,149 @@ +package tconstruct.client; + +import java.util.EnumSet; + +import net.minecraft.client.settings.KeyBinding; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +import cpw.mods.fml.common.ITickHandler; +import cpw.mods.fml.common.TickType; + +public abstract class TKeyHandler implements ITickHandler +{ + public KeyBinding[] keyBindings; + public KeyBinding[] vKeyBindings; + public boolean[] keyDown; + public boolean[] repeatings; + public boolean[] vRepeatings; + public boolean isDummy; + + /** + * Pass an array of keybindings and a repeat flag for each one + * + * @param keyBindings + * @param repeatings + */ + public TKeyHandler(KeyBinding[] keyBindings, boolean[] repeatings, KeyBinding[] vanillaKeys, boolean[] vanillaRepeatings) + { + assert keyBindings.length == repeatings.length : "You need to pass two arrays of identical length"; + assert vanillaKeys.length == vanillaRepeatings.length : "You need to pass two arrays of identical length"; + this.keyBindings = keyBindings; + this.repeatings = repeatings; + this.vKeyBindings = vanillaKeys; + this.vRepeatings = vanillaRepeatings; + this.keyDown = new boolean[keyBindings.length + vanillaKeys.length]; + } + + /** + * Register the keys into the system. You will do your own keyboard management elsewhere. No events will fire + * if you use this method + * + * @param keyBindings + */ + public TKeyHandler(KeyBinding[] keyBindings) + { + this.keyBindings = keyBindings; + this.isDummy = true; + } + + public KeyBinding[] getKeyBindings () + { + return this.keyBindings; + } + + /** + * Not to be overridden - KeyBindings are tickhandlers under the covers + */ + @Override + public final void tickStart (EnumSet type, Object... tickData) + { + keyTick(type, false); + } + + /** + * Not to be overridden - KeyBindings are tickhandlers under the covers + */ + @Override + public final void tickEnd (EnumSet type, Object... tickData) + { + keyTick(type, true); + } + + public void keyTick (EnumSet type, boolean tickEnd) + { + for (int i = 0; i < keyBindings.length; i++) + { + KeyBinding keyBinding = keyBindings[i]; + int keyCode = keyBinding.keyCode; + boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode)); + if (state != keyDown[i] || (state && repeatings[i])) + { + if (state) + { + keyDown(type, keyBinding, tickEnd, state != keyDown[i]); + } + else + { + keyUp(type, keyBinding, tickEnd); + } + if (tickEnd) + { + keyDown[i] = state; + } + } + } + for (int i = 0; i < vKeyBindings.length; i++) + { + KeyBinding keyBinding = vKeyBindings[i]; + int keyCode = keyBinding.keyCode; + boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode)); + if (state != keyDown[i + keyBindings.length] || (state && vRepeatings[i])) + { + if (state) + { + keyDown(type, keyBinding, tickEnd, state != keyDown[i + keyBindings.length]); + } + else + { + keyUp(type, keyBinding, tickEnd); + } + if (tickEnd) + { + keyDown[i + keyBindings.length] = state; + } + } + } + } + + /** + * Called when the key is first in the down position on any tick from the {@link #ticks()} + * set. Will be called subsequently with isRepeat set to true + * + * @see #keyUp(EnumSet, KeyBinding, boolean) + * + * @param types the type(s) of tick that fired when this key was first down + * @param tickEnd was it an end or start tick which fired the key + * @param isRepeat is it a repeat key event + */ + public abstract void keyDown (EnumSet types, KeyBinding kb, boolean tickEnd, boolean isRepeat); + + /** + * Fired once when the key changes state from down to up + * + * @see #keyDown(EnumSet, KeyBinding, boolean, boolean) + * + * @param types the type(s) of tick that fired when this key was first down + * @param tickEnd was it an end or start tick which fired the key + */ + public abstract void keyUp (EnumSet types, KeyBinding kb, boolean tickEnd); + + /** + * This is the list of ticks for which the key binding should trigger. The only + * valid ticks are client side ticks, obviously. + * + * @see cpw.mods.fml.common.ITickHandler#ticks() + */ + public abstract EnumSet ticks (); +} diff --git a/tconstruct/client/TProxyClient.java b/tconstruct/client/TProxyClient.java new file mode 100644 index 00000000..6946ef79 --- /dev/null +++ b/tconstruct/client/TProxyClient.java @@ -0,0 +1,1056 @@ +package tconstruct.client; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.model.ModelSlime; +import net.minecraft.client.particle.EntityAuraFX; +import net.minecraft.client.particle.EntityBreakingFX; +import net.minecraft.client.particle.EntityBubbleFX; +import net.minecraft.client.particle.EntityCloudFX; +import net.minecraft.client.particle.EntityCritFX; +import net.minecraft.client.particle.EntityDropParticleFX; +import net.minecraft.client.particle.EntityEnchantmentTableParticleFX; +import net.minecraft.client.particle.EntityExplodeFX; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.particle.EntityFireworkSparkFX; +import net.minecraft.client.particle.EntityFlameFX; +import net.minecraft.client.particle.EntityFootStepFX; +import net.minecraft.client.particle.EntityHeartFX; +import net.minecraft.client.particle.EntityHugeExplodeFX; +import net.minecraft.client.particle.EntityLargeExplodeFX; +import net.minecraft.client.particle.EntityLavaFX; +import net.minecraft.client.particle.EntityNoteFX; +import net.minecraft.client.particle.EntityPortalFX; +import net.minecraft.client.particle.EntityReddustFX; +import net.minecraft.client.particle.EntitySmokeFX; +import net.minecraft.client.particle.EntitySnowShovelFX; +import net.minecraft.client.particle.EntitySpellParticleFX; +import net.minecraft.client.particle.EntitySplashFX; +import net.minecraft.client.particle.EntitySuspendFX; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.common.MinecraftForge; + +import org.lwjgl.opengl.GL11; +import org.w3c.dom.Document; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.CastingBasinLogic; +import tconstruct.blocks.logic.CastingTableLogic; +import tconstruct.blocks.logic.DrawbridgeLogic; +import tconstruct.blocks.logic.DryingRackLogic; +import tconstruct.blocks.logic.FrypanLogic; +import tconstruct.blocks.logic.GlowstoneAggregator; +import tconstruct.blocks.logic.PartCrafterLogic; +import tconstruct.blocks.logic.PatternChestLogic; +import tconstruct.blocks.logic.SmelteryLogic; +import tconstruct.blocks.logic.StencilTableLogic; +import tconstruct.blocks.logic.ToolForgeLogic; +import tconstruct.blocks.logic.ToolStationLogic; +import tconstruct.client.block.BarricadeRender; +import tconstruct.client.block.CastingBasinSpecialRender; +import tconstruct.client.block.CastingTableSpecialRenderer; +import tconstruct.client.block.CrystalBlockRender; +import tconstruct.client.block.DryingRackRender; +import tconstruct.client.block.DryingRackSpecialRender; +import tconstruct.client.block.FrypanRender; +import tconstruct.client.block.MachineRender; +import tconstruct.client.block.OreberryRender; +import tconstruct.client.block.PaneConnectedRender; +import tconstruct.client.block.PaneRender; +import tconstruct.client.block.SearedRender; +import tconstruct.client.block.SmallFontRenderer; +import tconstruct.client.block.SmelteryRender; +import tconstruct.client.block.TableForgeRender; +import tconstruct.client.block.TableRender; +import tconstruct.client.block.TankRender; +import tconstruct.client.entity.CartRender; +import tconstruct.client.entity.CloneHeadModel; +import tconstruct.client.entity.CrystalGuardianRender; +import tconstruct.client.entity.CrystalRender; +import tconstruct.client.entity.FancyItemRender; +import tconstruct.client.entity.MiniGardyRender; +import tconstruct.client.entity.SlimeCloneRender; +import tconstruct.client.entity.SlimeRender; +import tconstruct.client.entity.projectile.ArrowRender; +import tconstruct.client.entity.projectile.DaggerRender; +import tconstruct.client.entity.projectile.LaunchedItemRender; +import tconstruct.client.gui.ArmorExtendedGui; +import tconstruct.client.gui.DrawbridgeGui; +import tconstruct.client.gui.FrypanGui; +import tconstruct.client.gui.GlowstoneAggregatorGui; +import tconstruct.client.gui.GuiManual; +import tconstruct.client.gui.InventoryTab; +import tconstruct.client.gui.KnapsackGui; +import tconstruct.client.gui.MiniGardyGui; +import tconstruct.client.gui.PartCrafterGui; +import tconstruct.client.gui.PatternChestGui; +import tconstruct.client.gui.SmelteryGui; +import tconstruct.client.gui.StencilTableGui; +import tconstruct.client.gui.ToolForgeGui; +import tconstruct.client.gui.ToolStationGui; +import tconstruct.client.pages.BlankPage; +import tconstruct.client.pages.BlockCastPage; +import tconstruct.client.pages.BookPage; +import tconstruct.client.pages.ContentsTablePage; +import tconstruct.client.pages.CraftingPage; +import tconstruct.client.pages.FurnacePage; +import tconstruct.client.pages.MaterialPage; +import tconstruct.client.pages.ModifierPage; +import tconstruct.client.pages.PicturePage; +import tconstruct.client.pages.SectionPage; +import tconstruct.client.pages.SidebarPage; +import tconstruct.client.pages.TextPage; +import tconstruct.client.pages.TitlePage; +import tconstruct.client.pages.ToolPage; +import tconstruct.common.TContent; +import tconstruct.common.TProxyCommon; +import tconstruct.entity.Automaton; +import tconstruct.entity.BlueSlime; +import tconstruct.entity.CartEntity; +import tconstruct.entity.Crystal; +import tconstruct.entity.FancyEntityItem; +import tconstruct.entity.MiniGardy; +import tconstruct.entity.SlimeClone; +import tconstruct.entity.projectile.ArrowEntity; +import tconstruct.entity.projectile.DaggerEntity; +import tconstruct.entity.projectile.LaunchedPotion; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.client.TConstructClientRegistry; +import tconstruct.library.client.ToolGuiElement; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.tools.ToolCore; +import tconstruct.util.player.ArmorExtended; +import tconstruct.util.player.KnapsackInventory; + +import com.google.common.collect.Lists; + +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.registry.TickRegistry; +import cpw.mods.fml.relauncher.Side; + +public class TProxyClient extends TProxyCommon +{ + public static SmallFontRenderer smallFontRenderer; + public static Icon metalBall; + public static Minecraft mc; + public static RenderItem itemRenderer = new RenderItem(); + + public static ArmorExtended armorExtended = new ArmorExtended(); + public static KnapsackInventory knapsack = new KnapsackInventory(); + + @Override + public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) + { + if (ID == stationGuiID) + return new ToolStationGui(player.inventory, (ToolStationLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); + if (ID == partGuiID) + return new PartCrafterGui(player.inventory, (PartCrafterLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); + if (ID == pchestGuiID) + return new PatternChestGui(player.inventory, (PatternChestLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); + if (ID == frypanGuiID) + return new FrypanGui(player.inventory, (FrypanLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); + if (ID == smelteryGuiID) + return new SmelteryGui(player.inventory, (SmelteryLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); + if (ID == pshaperGuiID) + return new StencilTableGui(player.inventory, (StencilTableLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); + if (ID == toolForge) + return new ToolForgeGui(player.inventory, (ToolForgeLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); + if (ID == glowstoneAggregatorGui) + return new GlowstoneAggregatorGui(player.inventory, (GlowstoneAggregator) world.getBlockTileEntity(x, y, z), world, x, y, z); + if (ID == drawbridgeGui) + return new DrawbridgeGui(player.inventory, (DrawbridgeLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); + + if (ID == manualGuiID) + { + ItemStack stack = player.getCurrentEquippedItem(); + return new GuiManual(stack, TProxyClient.getManualFromStack(stack)); + } + if (ID == inventoryGui) + { + GuiInventory inventory = new GuiInventory(player); + addTabsToInventory(inventory); + return inventory; + } + if (ID == armorGuiID) + { + TProxyClient.armorExtended.init(Minecraft.getMinecraft().thePlayer); + return new ArmorExtendedGui(player.inventory, TProxyClient.armorExtended); + } + if (ID == knapsackGuiID) + { + TProxyClient.knapsack.init(Minecraft.getMinecraft().thePlayer); + return new KnapsackGui(player.inventory, TProxyClient.knapsack); + } + if (ID == miniGardyGui) + { + for (Object o : world.loadedEntityList) + { + Entity entity = (Entity) o; + if (entity.entityId == x) + { + return new MiniGardyGui(player.inventory, (MiniGardy) entity); + } + } + return null; + } + return null; + } + + public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta) + { + Tessellator tessellator = Tessellator.instance; + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1F, 0.0F); + renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + public static void renderInvBlockFace (RenderBlocks renderblocks, Block block, int meta) + { + Tessellator tessellator = Tessellator.instance; + GL11.glScalef(2f, 2f, 2f); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glRotatef(45, 0, 1, 0); + GL11.glRotatef(60, 1, 0, 0); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1F, 0.0F); + renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + public static void openInventoryGui () + { + //controlInstance.openInventoryGui(); + if (mc == null) + mc = Minecraft.getMinecraft(); + GuiInventory inventory = new GuiInventory(mc.thePlayer); + mc.displayGuiScreen(inventory); + addTabsToInventory(inventory); + } + + public static void addTabsToInventory (GuiContainer gui) + { + /*if (mc == null) + mc = Minecraft.getMinecraft();*/ + if (gui.getClass() == GuiInventory.class || classMatches(gui, "micdoodle8.mods.galacticraft.core.client.gui.GCCoreGuiInventory")) + { + int cornerX = gui.guiLeft; + int cornerY = (gui.height - gui.ySize) / 2; + gui.buttonList.clear(); + + InventoryTab tab = new InventoryTab(2, cornerX, cornerY - 28, new ItemStack(Block.workbench), 0); + tab.enabled = false; + gui.buttonList.add(tab); + tab = new InventoryTab(3, cornerX + 28, cornerY - 28, new ItemStack(Item.plateDiamond), 1); + gui.buttonList.add(tab); + if (armorExtended.inventory[2] != null && armorExtended.inventory[2].getItem() == TContent.knapsack) + { + if (gui.buttonList.size() < 3) + { + tab = new InventoryTab(4, cornerX + 56, cornerY - 28, new ItemStack(TContent.knapsack), 1); + gui.buttonList.add(tab); + } + } + } + } + + public static boolean classMatches (Object paramObject, String paramString) + { + try + { + return paramObject.getClass().getName().equals(paramString); + } + catch (Exception localException) + { + return false; + } + } + + public void registerTickHandler () + { + TickRegistry.registerTickHandler(new TClientTickHandler(), Side.CLIENT); + //TickRegistry.registerTickHandler(new TimeTicker(), Side.CLIENT); + //TickRegistry.registerTickHandler(new TCommonTickHandler(), Side.CLIENT); + } + + /* Registers any rendering code. */ + public void registerRenderer () + { + Minecraft mc = Minecraft.getMinecraft(); + MinecraftForge.EVENT_BUS.register(new TClientEvents()); + smallFontRenderer = new SmallFontRenderer(mc.gameSettings, new ResourceLocation("/font/default.png"), mc.renderEngine, false); + RenderingRegistry.registerBlockHandler(new TableRender()); + RenderingRegistry.registerBlockHandler(new TableForgeRender()); + RenderingRegistry.registerBlockHandler(new FrypanRender()); + RenderingRegistry.registerBlockHandler(new SmelteryRender()); + RenderingRegistry.registerBlockHandler(new TankRender()); + RenderingRegistry.registerBlockHandler(new SearedRender()); + //RenderingRegistry.registerBlockHandler(new GolemCoreRender()); + RenderingRegistry.registerBlockHandler(new OreberryRender()); + RenderingRegistry.registerBlockHandler(new BarricadeRender()); + RenderingRegistry.registerBlockHandler(new CrystalBlockRender()); + RenderingRegistry.registerBlockHandler(new MachineRender()); + RenderingRegistry.registerBlockHandler(new DryingRackRender()); + RenderingRegistry.registerBlockHandler(new PaneRender()); + RenderingRegistry.registerBlockHandler(new PaneConnectedRender()); + //RenderingRegistry.registerBlockHandler(new BrickRender()); + //RenderingRegistry.registerBlockHandler(new BallRepeaterRender()); + + //Special Renderers + ClientRegistry.bindTileEntitySpecialRenderer(CastingTableLogic.class, new CastingTableSpecialRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(CastingBasinLogic.class, new CastingBasinSpecialRender()); + ClientRegistry.bindTileEntitySpecialRenderer(DryingRackLogic.class, new DryingRackSpecialRender()); + //ClientRegistry.bindTileEntitySpecialRenderer(GolemCoreLogic.class, new GolemCoreSpecialRender()); + + //Entities + RenderingRegistry.registerEntityRenderingHandler(FancyEntityItem.class, new FancyItemRender()); + RenderingRegistry.registerEntityRenderingHandler(BlueSlime.class, new SlimeRender(new ModelSlime(16), new ModelSlime(0), 0.25F)); + RenderingRegistry.registerEntityRenderingHandler(SlimeClone.class, new SlimeCloneRender(new CloneHeadModel(0), new CloneHeadModel(1f), 0.25F)); + + RenderingRegistry.registerEntityRenderingHandler(CartEntity.class, new CartRender()); + RenderingRegistry.registerEntityRenderingHandler(DaggerEntity.class, new DaggerRender()); + RenderingRegistry.registerEntityRenderingHandler(Crystal.class, new CrystalRender()); + // RenderingRegistry.registerEntityRenderingHandler(Skyla.class, new SkylaRender()); + RenderingRegistry.registerEntityRenderingHandler(MiniGardy.class, new MiniGardyRender()); + RenderingRegistry.registerEntityRenderingHandler(Automaton.class, new CrystalGuardianRender()); + RenderingRegistry.registerEntityRenderingHandler(LaunchedPotion.class, new LaunchedItemRender(Item.potion, 16384)); + RenderingRegistry.registerEntityRenderingHandler(ArrowEntity.class, new ArrowRender()); + //RenderingRegistry.registerEntityRenderingHandler(net.minecraft.entity.player.EntityPlayer.class, new PlayerArmorRender()); // <-- Works, woo! + + MinecraftForgeClient.registerItemRenderer(TContent.shortbow.itemID, new CustomBowRenderer()); + + addRenderMappings(); + addToolButtons(); + } + + public static Document diary; + public static Document volume1; + public static Document volume2; + public static Document smelter; + + public void readManuals () + { + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + diary = readManual("/assets/tinker/manuals/diary.xml", dbFactory); + volume1 = readManual("/assets/tinker/manuals/firstday.xml", dbFactory); + volume2 = readManual("/assets/tinker/manuals/materials.xml", dbFactory); + smelter = readManual("/assets/tinker/manuals/smeltery.xml", dbFactory); + initManualIcons(); + initManualRecipes(); + initManualPages(); + } + + Document readManual (String location, DocumentBuilderFactory dbFactory) + { + try + { + InputStream stream = TConstruct.class.getResourceAsStream(location); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + Document doc = dBuilder.parse(stream); + doc.getDocumentElement().normalize(); + return doc; + } + catch (Exception e) + { + e.printStackTrace(); + return null; + } + } + + public void initManualIcons () + { + TConstructClientRegistry.registerManualIcon("smelterybook", new ItemStack(TContent.manualBook, 1, 2)); + TConstructClientRegistry.registerManualIcon("smeltery", new ItemStack(TContent.smeltery)); + TConstructClientRegistry.registerManualIcon("blankcast", new ItemStack(TContent.blankPattern, 1, 1)); + TConstructClientRegistry.registerManualIcon("castingtable", new ItemStack(TContent.searedBlock)); + //TConstructClientRegistry.registerManualIcon("liquidiron", new ItemStack(TContent.liquidMetalStill)); + TConstructClientRegistry.registerManualIcon("lavatank", new ItemStack(TContent.lavaTank)); + TConstructClientRegistry.registerManualIcon("searedbrick", new ItemStack(TContent.smeltery, 1, 2)); + TConstructClientRegistry.registerManualIcon("drain", new ItemStack(TContent.smeltery, 1, 1)); + TConstructClientRegistry.registerManualIcon("faucet", new ItemStack(TContent.searedBlock, 1, 1)); + TConstructClientRegistry.registerManualIcon("bronzeingot", new ItemStack(TContent.materials, 1, 13)); + TConstructClientRegistry.registerManualIcon("alubrassingot", new ItemStack(TContent.materials, 1, 14)); + TConstructClientRegistry.registerManualIcon("manyullyningot", new ItemStack(TContent.materials, 1, 5)); + TConstructClientRegistry.registerManualIcon("alumiteingot", new ItemStack(TContent.materials, 1, 15)); + TConstructClientRegistry.registerManualIcon("blankpattern", new ItemStack(TContent.blankPattern, 1, 0)); + TConstructClientRegistry.registerManualIcon("toolstation", new ItemStack(TContent.toolStationWood, 1, 0)); + TConstructClientRegistry.registerManualIcon("partcrafter", new ItemStack(TContent.toolStationWood, 1, 1)); + TConstructClientRegistry.registerManualIcon("patternchest", new ItemStack(TContent.toolStationWood, 1, 5)); + TConstructClientRegistry.registerManualIcon("stenciltable", new ItemStack(TContent.toolStationWood, 1, 10)); + TConstructClientRegistry.registerManualIcon("torch", new ItemStack(Block.torchWood)); + TConstructClientRegistry.registerManualIcon("sapling", new ItemStack(Block.sapling)); + TConstructClientRegistry.registerManualIcon("workbench", new ItemStack(Block.workbench)); + TConstructClientRegistry.registerManualIcon("coal", new ItemStack(Item.coal)); + + TConstructClientRegistry.registerManualIcon("obsidianingot", new ItemStack(TContent.materials, 1, 18)); + TConstructClientRegistry.registerManualIcon("lavacrystal", new ItemStack(TContent.materials, 1, 7)); + + //Tool Materials + TConstructClientRegistry.registerManualIcon("woodplanks", new ItemStack(Block.planks)); + TConstructClientRegistry.registerManualIcon("stoneblock", new ItemStack(Block.stone)); + TConstructClientRegistry.registerManualIcon("ironingot", new ItemStack(Item.ingotIron)); + TConstructClientRegistry.registerManualIcon("flint", new ItemStack(Item.flint)); + TConstructClientRegistry.registerManualIcon("cactus", new ItemStack(Block.cactus)); + TConstructClientRegistry.registerManualIcon("bone", new ItemStack(Item.bone)); + TConstructClientRegistry.registerManualIcon("obsidian", new ItemStack(Block.obsidian)); + TConstructClientRegistry.registerManualIcon("netherrack", new ItemStack(Block.netherrack)); + TConstructClientRegistry.registerManualIcon("blueslimecrystal", new ItemStack(TContent.materials, 1, 17)); + TConstructClientRegistry.registerManualIcon("slimecrystal", new ItemStack(TContent.materials, 1, 1)); + TConstructClientRegistry.registerManualIcon("paperstack", new ItemStack(TContent.materials, 1, 0)); + TConstructClientRegistry.registerManualIcon("cobaltingot", new ItemStack(TContent.materials, 1, 3)); + TConstructClientRegistry.registerManualIcon("arditeingot", new ItemStack(TContent.materials, 1, 4)); + TConstructClientRegistry.registerManualIcon("copperingot", new ItemStack(TContent.materials, 1, 9)); + TConstructClientRegistry.registerManualIcon("steelingot", new ItemStack(TContent.materials, 1, 16)); + + //Tool parts + TConstructClientRegistry.registerManualIcon("pickhead", new ItemStack(TContent.pickaxeHead, 1, 2)); + TConstructClientRegistry.registerManualIcon("shovelhead", new ItemStack(TContent.shovelHead, 1, 2)); + TConstructClientRegistry.registerManualIcon("axehead", new ItemStack(TContent.hatchetHead, 1, 2)); + TConstructClientRegistry.registerManualIcon("swordblade", new ItemStack(TContent.swordBlade, 1, 2)); + TConstructClientRegistry.registerManualIcon("pan", new ItemStack(TContent.frypanHead, 1, 2)); + TConstructClientRegistry.registerManualIcon("board", new ItemStack(TContent.signHead, 1, 2)); + TConstructClientRegistry.registerManualIcon("knifeblade", new ItemStack(TContent.knifeBlade, 1, 2)); + TConstructClientRegistry.registerManualIcon("chiselhead", new ItemStack(TContent.chiselHead, 1, 2)); + + TConstructClientRegistry.registerManualIcon("hammerhead", new ItemStack(TContent.hammerHead, 1, 2)); + TConstructClientRegistry.registerManualIcon("excavatorhead", new ItemStack(TContent.excavatorHead, 1, 2)); + TConstructClientRegistry.registerManualIcon("scythehead", new ItemStack(TContent.scytheBlade, 1, 2)); + TConstructClientRegistry.registerManualIcon("broadaxehead", new ItemStack(TContent.broadAxeHead, 1, 2)); + TConstructClientRegistry.registerManualIcon("largeswordblade", new ItemStack(TContent.largeSwordBlade, 1, 2)); + + TConstructClientRegistry.registerManualIcon("toolrod", new ItemStack(Item.stick)); + + TConstructClientRegistry.registerManualIcon("binding", new ItemStack(TContent.binding, 1, 4)); + TConstructClientRegistry.registerManualIcon("wideguard", new ItemStack(TContent.wideGuard, 1, 4)); + TConstructClientRegistry.registerManualIcon("handguard", new ItemStack(TContent.handGuard, 1, 4)); + TConstructClientRegistry.registerManualIcon("crossbar", new ItemStack(TContent.crossbar, 1, 4)); + + TConstructClientRegistry.registerManualIcon("toughrod", new ItemStack(TContent.toughRod, 1, 0)); + TConstructClientRegistry.registerManualIcon("toughbinding", new ItemStack(TContent.toughBinding, 1, 17)); + TConstructClientRegistry.registerManualIcon("largeplate", new ItemStack(TContent.heavyPlate, 1, 17)); + + //ToolIcons + TConstructClientRegistry.registerManualIcon("pickicon", + ToolBuilder.instance.buildTool(new ItemStack(TContent.pickaxeHead, 1, 10), new ItemStack(TContent.toolRod, 1, 11), new ItemStack(TContent.binding, 1, 12), "")); + TConstructClientRegistry.registerManualIcon("shovelicon", ToolBuilder.instance.buildTool(new ItemStack(TContent.shovelHead, 1, 10), new ItemStack(TContent.toolRod, 1, 11), null, "")); + TConstructClientRegistry.registerManualIcon("axeicon", ToolBuilder.instance.buildTool(new ItemStack(TContent.hatchetHead, 1, 10), new ItemStack(TContent.toolRod, 1, 11), null, "")); + TConstructClientRegistry.registerManualIcon("mattockicon", + ToolBuilder.instance.buildTool(new ItemStack(TContent.hatchetHead, 1, 10), new ItemStack(TContent.toolRod, 1, 11), new ItemStack(TContent.shovelHead, 1, 12), "")); + TConstructClientRegistry.registerManualIcon("swordicon", + ToolBuilder.instance.buildTool(new ItemStack(TContent.swordBlade, 1, 10), new ItemStack(TContent.toolRod, 1, 11), new ItemStack(TContent.wideGuard, 1, 12), "")); + TConstructClientRegistry.registerManualIcon("longswordicon", + ToolBuilder.instance.buildTool(new ItemStack(TContent.swordBlade, 1, 10), new ItemStack(TContent.toolRod, 1, 11), new ItemStack(TContent.handGuard, 1, 12), "")); + TConstructClientRegistry.registerManualIcon("rapiericon", + ToolBuilder.instance.buildTool(new ItemStack(TContent.swordBlade, 1, 10), new ItemStack(TContent.toolRod, 1, 11), new ItemStack(TContent.crossbar, 1, 12), "")); + TConstructClientRegistry.registerManualIcon("daggerIcon", + ToolBuilder.instance.buildTool(new ItemStack(TContent.knifeBlade, 1, 10), new ItemStack(TContent.toolRod, 1, 11), new ItemStack(TContent.crossbar, 1, 12), "")); + TConstructClientRegistry.registerManualIcon("frypanicon", ToolBuilder.instance.buildTool(new ItemStack(TContent.frypanHead, 1, 10), new ItemStack(TContent.toolRod, 1, 11), null, "")); + TConstructClientRegistry.registerManualIcon("battlesignicon", ToolBuilder.instance.buildTool(new ItemStack(TContent.signHead, 1, 10), new ItemStack(TContent.toolRod, 1, 11), null, "")); + TConstructClientRegistry.registerManualIcon("chiselicon", ToolBuilder.instance.buildTool(new ItemStack(TContent.chiselHead, 1, 10), new ItemStack(TContent.toolRod, 1, 11), null, "")); + + TConstructClientRegistry.registerManualIcon("hammericon", ToolBuilder.instance.buildTool(new ItemStack(TContent.hammerHead, 1, 10), new ItemStack(TContent.toughRod, 1, 11), new ItemStack( + TContent.heavyPlate, 1, 12), new ItemStack(TContent.heavyPlate, 8), "")); + TConstructClientRegistry.registerManualIcon("lumbericon", ToolBuilder.instance.buildTool(new ItemStack(TContent.broadAxeHead, 1, 10), new ItemStack(TContent.toughRod, 1, 11), new ItemStack( + TContent.heavyPlate, 1, 12), new ItemStack(TContent.toughBinding, 8), "")); + TConstructClientRegistry.registerManualIcon("excavatoricon", ToolBuilder.instance.buildTool(new ItemStack(TContent.excavatorHead, 1, 10), new ItemStack(TContent.toughRod, 1, 11), + new ItemStack(TContent.heavyPlate, 1, 12), new ItemStack(TContent.toughBinding, 8), "")); + TConstructClientRegistry.registerManualIcon("scytheicon", ToolBuilder.instance.buildTool(new ItemStack(TContent.scytheBlade, 1, 10), new ItemStack(TContent.toughRod, 1, 11), new ItemStack( + TContent.toughBinding, 1, 12), new ItemStack(TContent.toughRod, 8), "")); + TConstructClientRegistry.registerManualIcon("cleavericon", ToolBuilder.instance.buildTool(new ItemStack(TContent.largeSwordBlade, 1, 10), new ItemStack(TContent.toughRod, 1, 11), + new ItemStack(TContent.heavyPlate, 1, 12), new ItemStack(TContent.toughRod, 8), "")); + TConstructClientRegistry.registerManualIcon("battleaxeicon", ToolBuilder.instance.buildTool(new ItemStack(TContent.broadAxeHead, 1, 10), new ItemStack(TContent.toughRod, 1, 11), + new ItemStack(TContent.broadAxeHead, 1, 12), new ItemStack(TContent.toughBinding, 8), "")); + } + + public void initManualRecipes () + { + ItemStack pattern = new ItemStack(TContent.blankPattern, 1, 0); + + ItemStack stick = new ItemStack(Item.stick, 1, 0); + ItemStack plank = new ItemStack(Block.planks, 1, 0); + ItemStack workbench = new ItemStack(Block.workbench, 1, 0); + ItemStack chest = new ItemStack(Block.chest, 1, 0); + ItemStack log = new ItemStack(Block.wood, 1, 0); + ItemStack mossycobble = new ItemStack(Block.cobblestoneMossy); + ItemStack netherrack = new ItemStack(Block.netherrack); + + ItemStack dirt = new ItemStack(Block.dirt, 1, 0); + ItemStack sand = new ItemStack(Block.sand, 1, 0); + ItemStack gravel = new ItemStack(Block.gravel, 1, 0); + ItemStack clay = new ItemStack(Item.clay, 1, 0); + ItemStack glass = new ItemStack(Block.glass, 1, 0); + ItemStack ironblock = new ItemStack(Block.blockIron, 1, 0); + + ItemStack grout = new ItemStack(TContent.craftedSoil, 2, 1); + ItemStack searedbrick = new ItemStack(TContent.materials, 1, 2); + ItemStack searedbrickBlock = new ItemStack(TContent.smeltery, 1, 2); + + ItemStack coal = new ItemStack(Item.coal); + ItemStack paper = new ItemStack(Item.paper); + ItemStack slimeball = new ItemStack(Item.slimeBall); + ItemStack slimyMud = new ItemStack(TContent.craftedSoil); + ItemStack blazerod = new ItemStack(Item.blazeRod); + ItemStack firecharge = new ItemStack(Item.fireballCharge); + ItemStack string = new ItemStack(Item.silk); + + ItemStack silkyCloth = new ItemStack(TContent.materials, 1, 25); + + ItemStack graveyardsoil = new ItemStack(TContent.craftedSoil, 1, 3); + ItemStack consecratedsoil = new ItemStack(TContent.craftedSoil, 1, 4); + + //TConstruct recipes + TConstructClientRegistry.registerManualSmallRecipe("patternbook1", new ItemStack(TContent.manualBook, 1, 0), new ItemStack(Item.paper), pattern, null, null); + TConstructClientRegistry.registerManualSmallRecipe("patternbook2", new ItemStack(TContent.manualBook, 1, 1), new ItemStack(TContent.manualBook, 1, 0), null, null, null); + TConstructClientRegistry.registerManualSmallRecipe("patternbook3", new ItemStack(TContent.manualBook, 1, 2), new ItemStack(TContent.manualBook, 1, 1), null, null, null); + TConstructClientRegistry.registerManualSmallRecipe("blankpattern", pattern, plank, stick, stick, plank); + TConstructClientRegistry.registerManualSmallRecipe("toolstation", new ItemStack(TContent.toolStationWood, 1, 0), null, pattern, null, workbench); + TConstructClientRegistry.registerManualSmallRecipe("partcrafter", new ItemStack(TContent.toolStationWood, 1, 1), null, pattern, null, log); + TConstructClientRegistry.registerManualSmallRecipe("patternchest", new ItemStack(TContent.toolStationWood, 1, 5), null, pattern, null, chest); + TConstructClientRegistry.registerManualSmallRecipe("stenciltable", new ItemStack(TContent.toolStationWood, 1, 10), null, pattern, null, plank); + TConstructClientRegistry.registerManualLargeRecipe("toolforge", new ItemStack(TContent.toolForge, 1, 0), searedbrickBlock, searedbrickBlock, searedbrickBlock, ironblock, new ItemStack( + TContent.toolStationWood, 1, 0), ironblock, ironblock, null, ironblock); + + TConstructClientRegistry.registerManualLargeRecipe("slimymud", slimyMud, null, slimeball, slimeball, null, slimeball, slimeball, null, dirt, sand); + TConstructClientRegistry.registerManualFurnaceRecipe("slimecrystal", new ItemStack(TContent.materials, 1, 1), slimyMud); + TConstructClientRegistry.registerManualSmallRecipe("paperstack", new ItemStack(TContent.materials, 1, 0), paper, paper, paper, paper); + TConstructClientRegistry.registerManualLargeRecipe("mossball", new ItemStack(TContent.materials, 1, 6), mossycobble, mossycobble, mossycobble, mossycobble, mossycobble, mossycobble, + mossycobble, mossycobble, mossycobble); + TConstructClientRegistry.registerManualLargeRecipe("lavacrystal", new ItemStack(TContent.materials, 1, 7), blazerod, firecharge, blazerod, firecharge, new ItemStack(Item.bucketLava), + firecharge, blazerod, firecharge, blazerod); + TConstructClientRegistry.registerManualLargeRecipe("silkycloth", silkyCloth, string, string, string, string, new ItemStack(TContent.materials, 1, 24), string, string, string, string); + TConstructClientRegistry.registerManualLargeRecipe("silkyjewel", new ItemStack(TContent.materials, 1, 26), null, silkyCloth, null, silkyCloth, new ItemStack(Item.emerald), silkyCloth, null, + silkyCloth, null); + + TConstructClientRegistry.registerManualSmallRecipe("graveyardsoil", graveyardsoil, new ItemStack(Block.dirt), new ItemStack(Item.rottenFlesh), new ItemStack(Item.dyePowder, 1, 15), null); + TConstructClientRegistry.registerManualFurnaceRecipe("consecratedsoil", consecratedsoil, graveyardsoil); + + TConstructClientRegistry.registerManualSmallRecipe("grout", grout, sand, gravel, null, clay); + TConstructClientRegistry.registerManualFurnaceRecipe("searedbrick", searedbrick, grout); + TConstructClientRegistry.registerManualSmallRecipe("searedbricks", new ItemStack(TContent.smeltery, 1, 2), searedbrick, searedbrick, searedbrick, searedbrick); + TConstructClientRegistry.registerManualLargeRecipe("smelterycontroller", new ItemStack(TContent.smeltery, 1, 0), searedbrick, searedbrick, searedbrick, searedbrick, null, searedbrick, + searedbrick, searedbrick, searedbrick); + TConstructClientRegistry.registerManualLargeRecipe("smelterydrain", new ItemStack(TContent.smeltery, 1, 1), searedbrick, null, searedbrick, searedbrick, null, searedbrick, searedbrick, null, + searedbrick); + + TConstructClientRegistry.registerManualLargeRecipe("smelterytank1", new ItemStack(TContent.lavaTank, 1, 0), searedbrick, searedbrick, searedbrick, searedbrick, glass, searedbrick, + searedbrick, searedbrick, searedbrick); + TConstructClientRegistry.registerManualLargeRecipe("smelterytank2", new ItemStack(TContent.lavaTank, 1, 1), searedbrick, glass, searedbrick, glass, glass, glass, searedbrick, glass, + searedbrick); + TConstructClientRegistry.registerManualLargeRecipe("smelterytank3", new ItemStack(TContent.lavaTank, 1, 2), searedbrick, glass, searedbrick, searedbrick, glass, searedbrick, searedbrick, + glass, searedbrick); + + TConstructClientRegistry.registerManualLargeRecipe("smelterytable", new ItemStack(TContent.searedBlock, 1, 0), searedbrick, searedbrick, searedbrick, searedbrick, null, searedbrick, + searedbrick, null, searedbrick); + TConstructClientRegistry.registerManualLargeRecipe("smelteryfaucet", new ItemStack(TContent.searedBlock, 1, 1), searedbrick, null, searedbrick, null, searedbrick, null, null, null, null); + TConstructClientRegistry.registerManualLargeRecipe("smelterybasin", new ItemStack(TContent.searedBlock, 1, 2), searedbrick, null, searedbrick, searedbrick, null, searedbrick, searedbrick, + searedbrick, searedbrick); + + //Modifier recipes + ItemStack ironpick = ToolBuilder.instance.buildTool(new ItemStack(TContent.pickaxeHead, 1, 6), new ItemStack(TContent.toolRod, 1, 2), new ItemStack(TContent.binding, 1, 6), ""); + TConstructClientRegistry.registerManualIcon("ironpick", ironpick); + ItemStack ironlongsword = ToolBuilder.instance.buildTool(new ItemStack(TContent.swordBlade, 1, 6), new ItemStack(TContent.toolRod, 1, 2), new ItemStack(TContent.handGuard, 1, 10), ""); + TConstructClientRegistry.registerManualIcon("ironlongsword", ironlongsword); + + TConstructClientRegistry.registerManualModifier("diamondmod", ironpick.copy(), new ItemStack(Item.diamond)); + TConstructClientRegistry.registerManualModifier("emeraldmod", ironpick.copy(), new ItemStack(Item.emerald)); + TConstructClientRegistry.registerManualModifier("redstonemod", ironpick.copy(), new ItemStack(Item.redstone), new ItemStack(Block.blockRedstone)); + TConstructClientRegistry.registerManualModifier("lavacrystalmod", ironpick.copy(), new ItemStack(TContent.materials, 1, 7)); + TConstructClientRegistry.registerManualModifier("lapismod", ironpick.copy(), new ItemStack(Item.dyePowder, 1, 4), new ItemStack(Block.blockLapis)); + TConstructClientRegistry.registerManualModifier("mossmod", ironpick.copy(), new ItemStack(TContent.materials, 1, 6)); + TConstructClientRegistry.registerManualModifier("quartzmod", ironlongsword.copy(), new ItemStack(Item.netherQuartz), new ItemStack(Block.blockNetherQuartz)); + TConstructClientRegistry.registerManualModifier("blazemod", ironlongsword.copy(), new ItemStack(Item.blazePowder)); + TConstructClientRegistry.registerManualModifier("necroticmod", ironlongsword.copy(), new ItemStack(TContent.materials, 1, 8)); + TConstructClientRegistry.registerManualModifier("silkymod", ironpick.copy(), new ItemStack(TContent.materials, 1, 26)); + TConstructClientRegistry.registerManualModifier("reinforcedmod", ironpick.copy(), new ItemStack(TContent.heavyPlate, 1, 6)); + + TConstructClientRegistry.registerManualModifier("pistonmod", ironlongsword.copy(), new ItemStack(Block.pistonBase)); + TConstructClientRegistry.registerManualModifier("beheadingmod", ironlongsword.copy(), new ItemStack(Item.enderPearl), new ItemStack(Block.obsidian)); + TConstructClientRegistry.registerManualModifier("spidermod", ironlongsword.copy(), new ItemStack(Item.fermentedSpiderEye)); + TConstructClientRegistry.registerManualModifier("smitemod", ironlongsword.copy(), new ItemStack(TContent.craftedSoil, 1, 4)); + + TConstructClientRegistry.registerManualModifier("electricmod", ironpick.copy(), new ItemStack(Block.dirt), new ItemStack(Block.dirt)); + TConstructClientRegistry.registerManualModifier("tier1free", ironpick.copy(), new ItemStack(Item.diamond), new ItemStack(Block.blockGold)); + TConstructClientRegistry.registerManualModifier("tier2free", ironpick.copy(), new ItemStack(Item.netherStar)); + + /*TConstructClientRegistry.registerManualSmeltery("brownstone", new ItemStack(TContent.speedBlock), new ItemStack(TContent.liquidMetalStill, 1, 3), new ItemStack(Block.gravel)); + TConstructClientRegistry.registerManualSmeltery("clearglass", new ItemStack(TContent.glass), new ItemStack(TContent.liquidMetalStill, 1, 13), null); + TConstructClientRegistry.registerManualSmeltery("searedstone", new ItemStack(TContent.smeltery, 1, 4), new ItemStack(TContent.liquidMetalStill, 1, 14), null);*/ + + } + + public static Map> pageClasses = new HashMap>(); + + public static void registerManualPage (String type, Class clazz) + { + pageClasses.put(type, clazz); + } + + public static Class getPageClass (String type) + { + return pageClasses.get(type); + } + + void initManualPages () + { + TProxyClient.registerManualPage("crafting", CraftingPage.class); + TProxyClient.registerManualPage("picture", PicturePage.class); + TProxyClient.registerManualPage("text", TextPage.class); + TProxyClient.registerManualPage("intro", TextPage.class); + TProxyClient.registerManualPage("sectionpage", SectionPage.class); + TProxyClient.registerManualPage("intro", TitlePage.class); + TProxyClient.registerManualPage("contents", ContentsTablePage.class); + TProxyClient.registerManualPage("furnace", FurnacePage.class); + TProxyClient.registerManualPage("sidebar", SidebarPage.class); + TProxyClient.registerManualPage("materialstats", MaterialPage.class); + TProxyClient.registerManualPage("toolpage", ToolPage.class); + TProxyClient.registerManualPage("modifier", ModifierPage.class); + TProxyClient.registerManualPage("blockcast", BlockCastPage.class); + + TProxyClient.registerManualPage("blank", BlankPage.class); + } + + public static Document getManualFromStack (ItemStack stack) + { + switch (stack.getItemDamage()) + { + case 0: + return volume1; + case 1: + return volume2; + case 2: + return smelter; + case 3: + return diary; + } + + return null; + } + + static int[][] itemIcons = { new int[] { 0, 3, 0 }, //Repair + new int[] { 1, 4, 0 }, //Pickaxe + new int[] { 2, 5, 0 }, //Shovel + new int[] { 2, 6, 0 }, //Axe + //new int[] {2, 9, 0}, //Lumber Axe + //new int[] {1, 7, 0}, //Ice Axe + new int[] { 3, 8, 0 }, //Mattock + new int[] { 1, 0, 1 }, //Broadsword + new int[] { 1, 1, 1 }, //Longsword + new int[] { 1, 2, 1 }, //Rapier + new int[] { 1, 5, 1 }, //Dagger + new int[] { 2, 3, 1 }, //Frying pan + new int[] { 2, 4, 1 }, //Battlesign + new int[] { 2, 6, 1 } //Chisel + }; + + static int[][] iconCoords = { new int[] { 0, 1, 2, 13 }, new int[] { 13, 13, 13, 13 }, //Repair + new int[] { 0, 0, 1, 13 }, new int[] { 2, 3, 3, 13 }, //Pickaxe + new int[] { 3, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, //Shovel + new int[] { 2, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, //Axe + //new int[] { 6, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, //Lumber Axe + //new int[] { 0, 0, 5, 13 }, new int[] { 2, 3, 3, 13 }, //Ice Axe + new int[] { 2, 0, 3, 13 }, new int[] { 2, 3, 2, 13 }, //Mattock + new int[] { 1, 0, 2, 13 }, new int[] { 2, 3, 3, 13 }, //Broadsword + new int[] { 1, 0, 3, 13 }, new int[] { 2, 3, 3, 13 }, //Longsword + new int[] { 1, 0, 4, 13 }, new int[] { 2, 3, 3, 13 }, //Rapier + new int[] { 7, 0, 4, 13 }, new int[] { 2, 3, 3, 13 }, //Dagger + new int[] { 4, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, //Frying Pan + new int[] { 5, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, //Battlesign + new int[] { 7, 0, 13, 13 }, new int[] { 3, 3, 13, 13 } //Chisel + }; + + static String[] toolNames = { "Repair and Modification", "Pickaxe", "Shovel", "Hatchet", + //"Lumber Axe", + //"Ice Axe", + "Mattock", "Broadsword", "Longsword", "Rapier", "Dagger", "Frying Pan", "Battlesign", "Chisel" }; + + static String[] toolDescriptions = { + "The main way to repair or change your tools. Place a tool and a material on the left to get started.", + "The Pickaxe is a precise mining tool. It is effective on stone and ores.\n\nRequired parts:\n- Pickaxe Head\n- Tool Binding\n- Handle", + "The Shovel is a precise digging tool. It is effective on dirt, sand, and snow.\n\nRequired parts:\n- Shovel Head\n- Handle", + "The Hatchet is a basic chopping tool. It is effective on wood and leaves.\n\nRequired parts:\n- Axe Head\n- Handle", + //"The Lumber Axe is a broad chopping tool. It harvests wood in a wide range and can fell entire trees.\n\nRequired parts:\n- Broad Axe Head\n- Handle", + //"The Ice Axe is a tool for harvesting ice, mining, and attacking foes.\n\nSpecial Ability:\n- Wall Climb\nNatural Ability:\n- Ice Harvest\nDamage: Moderate\n\nRequired parts:\n- Pickaxe Head\n- Spike\n- Handle", + "The Cutter Mattock is a versatile farming tool. It is effective on wood, dirt, and plants.\n\nSpecial Ability: Hoe\n\nRequired parts:\n- Axe Head\n- Shovel Head\n- Handle", + "The Broadsword is a defensive weapon. Blocking cuts damage in half.\n\nSpecial Ability: Block\nDamage: Moderate\nDurability: High\n\nRequired parts:\n- Sword Blade\n- Wide Guard\n- Handle", + "The Longsword is an offensive weapon. It is often used for charging into battle at full speed.\n\nNatural Ability:\n- Charge Boost\nSpecial Ability: Lunge\n\nDamage: Moderate\nDurability: Moderate", + "The Rapier is a special weapon that relies on quick strikes to defeat foes.\n\nNatural Abilities:\n- Armor Pierce\n- Quick Strike\n- Charge Boost\nSpecial Ability:\n- Backpedal\n\nDamage: Low\nDurability: Low", + "The Dagger is a short blade that can be thrown.\n\nSpecial Ability:\n- Throw Item\n\nDamage: Low\nDurability: Moderate\n\nRequired parts:\n- Knife Blade\n- Crossbar\n- Handle", + "The Frying is a heavy weapon that uses sheer weight to stun foes.\n\nSpecial Ability: Block\nNatural Ability: Heavy\nShift+rClick: Place Frying Pan\nDamage: Low\nDurability: High\n\nRequired parts:\n- Pan\n- Handle", + //"The Battlesign is an advance in weapon technology worthy of Zombie Pigmen everywhere.\n\nSpecial Ability: Block\nShift-rClick: Place sign\nDamage: Low\nDurability: Average\n\nRequired parts:\n- Board\n- Handle" + "The Battlesign is an advance in weapon technology worthy of Zombie Pigmen everywhere.\n\nSpecial Ability: Block\nDamage: Low\nDurability: Average\n\nRequired parts:\n- Sign Board\n- Handle", + "The Chisel is a utility tool that carves shapes into blocks.\n\nCrafting Grid:\n- Shape Items\nSpecial Ability: Chisel\nDurability: Average\n\nRequired parts:\n- Chisel Head\n- Handle" }; + + void addToolButtons () + { + for (int i = 0; i < toolNames.length; i++) + { + addToolButton(itemIcons[i][0], itemIcons[i][1], itemIcons[i][2], iconCoords[i * 2], iconCoords[i * 2 + 1], toolNames[i], toolDescriptions[i]); + } + + addToolButton(3, 9, 1, new int[] { 0, 10, 0, 13 }, new int[] { 3, 3, 3, 13 }, "Shortbow", + "The Shortbow is a ranged weapon. It fires arrows quickly and precisely at its foes.\n\nDraw Speed: Quick\n\nRequired parts:\n- Tool Rod\n- Bowstring\n- Tool Rod"); + addToolButton(7, 10, 1, new int[] { 11, 0, 12, 13 }, new int[] { 3, 3, 3, 13 }, "Arrow", + "Arrows are projectiles usually fired from bows.\n\nRequired parts:\n- Arrowhead\n- Tool Rod\n- Fletching"); + addTierTwoButton(6, 13, 0, new int[] { 11, 8, 9, 9 }, new int[] { 2, 3, 2, 2 }, "Hammer", + "The Hammer is a broad mining tool. It harvests blocks in a wide range and is effective against undead.\n\nNatural Abilities:\nArea of Effect\n- (3x3)\n- Smite\n\nDurability: High"); + addTierTwoButton(5, 11, 0, new int[] { 6, 8, 9, 9 }, new int[] { 2, 3, 2, 3 }, "Lumber Axe", + "The Lumber Axe is a broad chopping tool. It can fell entire trees or gather wood in a wide range.\n\nNatural Abilities:\nArea of Effect\n- Fell Trees\n- (3x3x3)\n\nDurability: Average"); + addTierTwoButton(5, 12, 0, new int[] { 10, 8, 9, 9 }, new int[] { 2, 3, 2, 3 }, "Excavator", + "The Excavator is a broad digging tool. It harvests soil and snow in a wide range.\n\nNatural Ability:\n- Area of Effect\n- (3x3)\n\nDurability: Average"); + addTierTwoButton(4, 10, 0, new int[] { 8, 8, 9, 8 }, new int[] { 2, 3, 3, 3 }, "Scythe", + "The Scythe is a broad reaping tool. It is effective on plants and attacks enemies in a wide range.\n\nNatural Ability:\nArea of Effect\n- (3x3x3)\n\nDurability: Average\nDamage: Low, AoE"); + addTierTwoButton(5, 7, 1, new int[] { 6, 8, 9, 8 }, new int[] { 3, 3, 2, 3 }, "Cleaver", + "The Cleaver is a heavy defensive weapon. It has powerful strikes, but is difficult to wield.\n\nSpecial Ability: Block\nNatural Ability:\n- Beheading\n\nDamage: High\nDurability: Average"); + addTierTwoButton(5, 8, 1, new int[] { 6, 8, 6, 9 }, new int[] { 2, 3, 2, 3 }, "Battleaxe", + "The Battleaxe is a heavy offensive weapon. It is capable of bringing down small trees and can send foes flying.\n\nSpecial Ability: Block\nNatural Abilities:" + + "\n- Knockback\n- Area of Effect\n- (1x9)\n\nDamage: Average\nDurability: Average"); + } + + void addToolButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body) + { + TConstructClientRegistry.addToolButton(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, "tinker", title, body, "/mods/tinker/textures/gui/icons.png")); + } + + void addTierTwoButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body) + { + TConstructClientRegistry.addTierTwoButton(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, "tinker", title, body, "/mods/tinker/textures/gui/icons.png")); + } + + void addRenderMappings () + { + String[] partTypes = { "wood", "stone", "iron", "flint", "cactus", "bone", "obsidian", "netherrack", "slime", "paper", "cobalt", "ardite", "manyullyn", "copper", "bronze", "alumite", "steel", + "blueslime" }; + //String[] modPartTypes = { "thaumium" }; + String[] effectTypes = { "diamond", "emerald", "redstone", "piston", "moss", "ice", "lava", "blaze", "necrotic", "electric", "lapis", "quartz", "silk", "beheading", "smite", "spider", + "reinforced" }; + int[] universalEffects = { 0, 1, 4, 9, 16 }; + int[] weaponEffects = { 3, 5, 7, 13, 14, 15 }; + int[] harvestEffects = { 2 }; + int[] nonUtility = { 6, 8, 10, 11, 12 }; + + for (int partIter = 0; partIter < partTypes.length; partIter++) + { + TConstructClientRegistry.addMaterialRenderMapping(partIter, "tinker", partTypes[partIter], true); + } + + /*for (int iter = 0; iter < modPartTypes.length; iter++) + { + TConstructClientRegistry.addMaterialRenderMapping(31 + iter, "tinker", modPartTypes[iter], true); + }*/ + + for (ToolCore tool : TConstructRegistry.getToolMapping()) + { + for (int i = 0; i < effectTypes.length; i++) + { + TConstructClientRegistry.addEffectRenderMapping(tool, i, "tinker", effectTypes[i], true); + } + } + + String[] bowstringTypes = { "string", "magicfabric" }; + for (int bowIter = 0; bowIter < bowstringTypes.length; bowIter++) + { + TConstructClientRegistry.addAlternateMaterialRenderMapping(TContent.shortbow, bowIter, "tinker", bowstringTypes[bowIter], true); + } + + String[] fletching = { "feather", "leaf", "slime", "blueslime" }; + for (int arrowIter = 0; arrowIter < fletching.length; arrowIter++) + { + TConstructClientRegistry.addAlternateMaterialRenderMapping(TContent.arrow, arrowIter, "tinker", fletching[arrowIter], true); + } + } + + /* Keybindings */ + public static TControls controlInstance; + + public void registerKeys () + { + controlInstance = new TControls(); + TickRegistry.registerTickHandler(controlInstance, Side.CLIENT); + uploadKeyBindingsToGame(Minecraft.getMinecraft().gameSettings, controlInstance); + } + + public void uploadKeyBindingsToGame (GameSettings settings, TKeyHandler keyhandler) + { + ArrayList harvestedBindings = Lists.newArrayList(); + for (KeyBinding kb : keyhandler.keyBindings) + { + harvestedBindings.add(kb); + } + + KeyBinding[] modKeyBindings = harvestedBindings.toArray(new KeyBinding[harvestedBindings.size()]); + KeyBinding[] allKeys = new KeyBinding[settings.keyBindings.length + modKeyBindings.length]; + System.arraycopy(settings.keyBindings, 0, allKeys, 0, settings.keyBindings.length); + System.arraycopy(modKeyBindings, 0, allKeys, settings.keyBindings.length, modKeyBindings.length); + settings.keyBindings = allKeys; + settings.loadOptions(); + } + + public void spawnParticle (String particle, double xPos, double yPos, double zPos, double velX, double velY, double velZ) + { + this.doSpawnParticle(particle, xPos, yPos, zPos, velX, velY, velZ); + } + + public EntityFX doSpawnParticle (String par1Str, double par2, double par4, double par6, double par8, double par10, double par12) + { + if (this.mc == null) + this.mc = Minecraft.getMinecraft(); + + if (this.mc.renderViewEntity != null && this.mc.effectRenderer != null) + { + int i = this.mc.gameSettings.particleSetting; + + if (i == 1 && mc.theWorld.rand.nextInt(3) == 0) + { + i = 2; + } + + double d6 = this.mc.renderViewEntity.posX - par2; + double d7 = this.mc.renderViewEntity.posY - par4; + double d8 = this.mc.renderViewEntity.posZ - par6; + EntityFX entityfx = null; + + if (par1Str.equals("hugeexplosion")) + { + this.mc.effectRenderer.addEffect(entityfx = new EntityHugeExplodeFX(mc.theWorld, par2, par4, par6, par8, par10, par12)); + } + else if (par1Str.equals("largeexplode")) + { + this.mc.effectRenderer.addEffect(entityfx = new EntityLargeExplodeFX(mc.renderEngine, mc.theWorld, par2, par4, par6, par8, par10, par12)); + } + else if (par1Str.equals("fireworksSpark")) + { + this.mc.effectRenderer.addEffect(entityfx = new EntityFireworkSparkFX(mc.theWorld, par2, par4, par6, par8, par10, par12, this.mc.effectRenderer)); + } + + if (entityfx != null) + { + return (EntityFX) entityfx; + } + else + { + double d9 = 16.0D; + + if (d6 * d6 + d7 * d7 + d8 * d8 > d9 * d9) + { + return null; + } + else if (i > 1) + { + return null; + } + else + { + if (par1Str.equals("bubble")) + { + entityfx = new EntityBubbleFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("suspended")) + { + entityfx = new EntitySuspendFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("depthsuspend")) + { + entityfx = new EntityAuraFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("townaura")) + { + entityfx = new EntityAuraFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("crit")) + { + entityfx = new EntityCritFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("smoke")) + { + entityfx = new EntitySmokeFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("mobSpell")) + { + entityfx = new EntitySpellParticleFX(mc.theWorld, par2, par4, par6, 0.0D, 0.0D, 0.0D); + ((EntityFX) entityfx).setRBGColorF((float) par8, (float) par10, (float) par12); + } + else if (par1Str.equals("mobSpellAmbient")) + { + entityfx = new EntitySpellParticleFX(mc.theWorld, par2, par4, par6, 0.0D, 0.0D, 0.0D); + ((EntityFX) entityfx).setAlphaF(0.15F); + ((EntityFX) entityfx).setRBGColorF((float) par8, (float) par10, (float) par12); + } + else if (par1Str.equals("spell")) + { + entityfx = new EntitySpellParticleFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("instantSpell")) + { + entityfx = new EntitySpellParticleFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + ((EntitySpellParticleFX) entityfx).setBaseSpellTextureIndex(144); + } + else if (par1Str.equals("witchMagic")) + { + entityfx = new EntitySpellParticleFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + ((EntitySpellParticleFX) entityfx).setBaseSpellTextureIndex(144); + float f = mc.theWorld.rand.nextFloat() * 0.5F + 0.35F; + ((EntityFX) entityfx).setRBGColorF(1.0F * f, 0.0F * f, 1.0F * f); + } + else if (par1Str.equals("note")) + { + entityfx = new EntityNoteFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("portal")) + { + entityfx = new EntityPortalFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("enchantmenttable")) + { + entityfx = new EntityEnchantmentTableParticleFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("explode")) + { + entityfx = new EntityExplodeFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("flame")) + { + entityfx = new EntityFlameFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("lava")) + { + entityfx = new EntityLavaFX(mc.theWorld, par2, par4, par6); + } + else if (par1Str.equals("footstep")) + { + entityfx = new EntityFootStepFX(mc.renderEngine, mc.theWorld, par2, par4, par6); + } + else if (par1Str.equals("splash")) + { + entityfx = new EntitySplashFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("largesmoke")) + { + entityfx = new EntitySmokeFX(mc.theWorld, par2, par4, par6, par8, par10, par12, 2.5F); + } + else if (par1Str.equals("cloud")) + { + entityfx = new EntityCloudFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("reddust")) + { + entityfx = new EntityReddustFX(mc.theWorld, par2, par4, par6, (float) par8, (float) par10, (float) par12); + } + else if (par1Str.equals("snowballpoof")) + { + entityfx = new EntityBreakingFX(mc.theWorld, par2, par4, par6, Item.snowball); + } + else if (par1Str.equals("dripWater")) + { + entityfx = new EntityDropParticleFX(mc.theWorld, par2, par4, par6, Material.water); + } + else if (par1Str.equals("dripLava")) + { + entityfx = new EntityDropParticleFX(mc.theWorld, par2, par4, par6, Material.lava); + } + else if (par1Str.equals("snowshovel")) + { + entityfx = new EntitySnowShovelFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("blueslime")) + { + entityfx = new EntityBreakingFX(mc.theWorld, par2, par4, par6, TContent.strangeFood); + } + else if (par1Str.equals("heart")) + { + entityfx = new EntityHeartFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("angryVillager")) + { + entityfx = new EntityHeartFX(mc.theWorld, par2, par4 + 0.5D, par6, par8, par10, par12); + ((EntityFX) entityfx).setParticleTextureIndex(81); + ((EntityFX) entityfx).setRBGColorF(1.0F, 1.0F, 1.0F); + } + else if (par1Str.equals("happyVillager")) + { + entityfx = new EntityAuraFX(mc.theWorld, par2, par4, par6, par8, par10, par12); + ((EntityFX) entityfx).setParticleTextureIndex(82); + ((EntityFX) entityfx).setRBGColorF(1.0F, 1.0F, 1.0F); + } + + if (entityfx != null) + { + this.mc.effectRenderer.addEffect((EntityFX) entityfx); + } + + return (EntityFX) entityfx; + } + } + } + else + { + return null; + } + } +} diff --git a/tconstruct/client/armor/WingModel.java b/tconstruct/client/armor/WingModel.java new file mode 100644 index 00000000..dc2f51d6 --- /dev/null +++ b/tconstruct/client/armor/WingModel.java @@ -0,0 +1,122 @@ +package tconstruct.client.armor; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class WingModel extends ModelBase +{ + ModelRenderer WingBaseRight; + ModelRenderer WingEdgeRight; + ModelRenderer WingInsetRight; + ModelRenderer WingCenterRight; + ModelRenderer WingFlangeRight; + ModelRenderer WingAuxRight; + ModelRenderer WingBaseLeft; + ModelRenderer WingEdgeLeft; + ModelRenderer WingInsetLeft; + ModelRenderer WingCenterLeft; + ModelRenderer WingFlangeLeft; + ModelRenderer WingAuxLeft; + + public WingModel() + { + textureWidth = 64; + textureHeight = 64; + + //Right Wing + WingBaseRight = new ModelRenderer(this, 0, 41); + WingBaseRight.addBox(-0.5F, -1F, 0F, 1, 2, 10); + WingBaseRight.setRotationPoint(-1F, 1F, 0F); + setRotation(WingBaseRight, 0.5235988F, -0.5235988F, 0F); + + WingEdgeRight = new ModelRenderer(this, 0, 53); //Texture position + WingEdgeRight.addBox(0F, 0F, -2F, 1, 9, 2); //Offset, Size + WingEdgeRight.setRotationPoint(-0.502F, -1F, 10F); //Negative x, y - 1, Position + setRotation(WingEdgeRight, 0.5235988F, 0F, 0F); //Angle in radians + + WingInsetRight = new ModelRenderer(this, 6, 53); + WingInsetRight.addBox(0F, 0F, -1F, 1, 9, 2); + WingInsetRight.setRotationPoint(-0.504F, 0F, 7.8F); + setRotation(WingInsetRight, 0.3490659F, 0F, 0F); + + WingCenterRight = new ModelRenderer(this, 12, 53); + WingCenterRight.addBox(0F, 0F, -1F, 1, 9, 2); + WingCenterRight.setRotationPoint(-0.506F, 0.3F, 6.3F); + setRotation(WingCenterRight, 0.1745329F, 0F, 0F); + + WingFlangeRight = new ModelRenderer(this, 18, 53); + WingFlangeRight.addBox(0F, 0F, -1F, 1, 8, 2); + WingFlangeRight.setRotationPoint(-0.508F, 0.3F, 5.1F); + setRotation(WingFlangeRight, 0F, 0F, 0F); + + WingAuxRight = new ModelRenderer(this, 24, 53); + WingAuxRight.addBox(0F, 0F, -1F, 1, 7, 2); + WingAuxRight.setRotationPoint(-0.51F, 0.1F, 4F); + setRotation(WingAuxRight, -0.1745329F, 0F, 0F); + + WingBaseRight.addChild(WingEdgeRight); + WingBaseRight.addChild(WingInsetRight); + WingBaseRight.addChild(WingCenterRight); + WingBaseRight.addChild(WingFlangeRight); + WingBaseRight.addChild(WingAuxRight); + + //Left Wing + WingBaseLeft = new ModelRenderer(this, 42, 41); + WingBaseLeft.addBox(-0.5F, -1F, 0F, 1, 2, 10); + WingBaseLeft.setRotationPoint(1F, 1F, 0F); + setRotation(WingBaseLeft, 0.5235988F, 0.5235988F, 0F); + + WingEdgeLeft = new ModelRenderer(this, 58, 53); + WingEdgeLeft.addBox(0F, 0F, -2F, 1, 9, 2); + WingEdgeLeft.setRotationPoint(-0.502F, -1F, 10F); + setRotation(WingEdgeLeft, 0.5235988F, 0F, 0F); + + WingInsetLeft = new ModelRenderer(this, 52, 53); + WingInsetLeft.addBox(0F, 0F, -1F, 1, 9, 2); + WingInsetLeft.setRotationPoint(-0.504F, 0F, 7.8F); + setRotation(WingInsetLeft, 0.3490659F, 0F, 0F); + + WingCenterLeft = new ModelRenderer(this, 46, 53); + WingCenterLeft.addBox(0F, 0F, -1F, 1, 9, 2); + WingCenterLeft.setRotationPoint(-0.506F, 0.3F, 6.3F); + setRotation(WingCenterLeft, 0.1745329F, 0F, 0F); + + WingFlangeLeft = new ModelRenderer(this, 40, 53); + WingFlangeLeft.addBox(0F, 0F, -1F, 1, 8, 2); + WingFlangeLeft.setRotationPoint(-0.508F, 0.3F, 5.1F); + setRotation(WingFlangeLeft, 0F, 0F, 0F); + + WingAuxLeft = new ModelRenderer(this, 34, 53); + WingAuxLeft.addBox(0F, 0F, -1F, 1, 7, 2); + WingAuxLeft.setRotationPoint(-0.51F, 0.1F, 4F); + setRotation(WingAuxLeft, -0.1745329F, 0F, 0F); + + WingBaseLeft.addChild(WingEdgeLeft); + WingBaseLeft.addChild(WingInsetLeft); + WingBaseLeft.addChild(WingCenterLeft); + WingBaseLeft.addChild(WingFlangeLeft); + WingBaseLeft.addChild(WingAuxLeft); + } + + public void render (Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + WingBaseRight.render(f5); + WingBaseLeft.render(f5); + } + + private void setRotation (ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles (float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } + +} diff --git a/tconstruct/client/block/BallRepeaterRender.java b/tconstruct/client/block/BallRepeaterRender.java new file mode 100644 index 00000000..4bc049bc --- /dev/null +++ b/tconstruct/client/block/BallRepeaterRender.java @@ -0,0 +1,263 @@ +package tconstruct.client.block; + +import tconstruct.blocks.RedstoneBallRepeater; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class BallRepeaterRender implements ISimpleBlockRenderingHandler +{ + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + //Inventory should be an item. This is not here! + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + return renderRedstoneBallRepeater(block, x, y, z, world); + } + + @Override + public boolean shouldRender3DInInventory () + { + return false; + } + + @Override + public int getRenderId () + { + return model; + } + + public boolean renderRedstoneBallRepeater (Block par1Block, int par2, int par3, int par4, IBlockAccess world) + { + Tessellator tessellator = Tessellator.instance; + int l = world.getBlockMetadata(par2, par3, par4); + Icon icon = RedstoneBallRepeater.func_94409_b("repeaterDust_cross"); + Icon icon1 = RedstoneBallRepeater.func_94409_b("repeaterDust_line"); + Icon icon2 = RedstoneBallRepeater.func_94409_b("repeaterDust_cross_overlay"); + Icon icon3 = RedstoneBallRepeater.func_94409_b("repeaterDust_line_overlay"); + tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(world, par2, par3, par4)); + float f = 1.0F; + float f1 = (float) l / 15.0F; + float f2 = f1 * 0.6F + 0.4F; + + if (l == 0) + { + f2 = 0.3F; + } + + float f3 = f1 * f1 * 0.7F - 0.5F; + float f4 = f1 * f1 * 0.6F - 0.7F; + + if (f3 < 0.0F) + { + f3 = 0.0F; + } + + if (f4 < 0.0F) + { + f4 = 0.0F; + } + + tessellator.setColorOpaque_F(f2, f3, f4); + boolean flag = RedstoneBallRepeater.isPowerProviderOrWire(world, par2 - 1, par3, par4, 1) || !world.isBlockNormalCube(par2 - 1, par3, par4) + && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 - 1, par3 - 1, par4, -1); + boolean flag1 = RedstoneBallRepeater.isPowerProviderOrWire(world, par2 + 1, par3, par4, 3) || !world.isBlockNormalCube(par2 + 1, par3, par4) + && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 + 1, par3 - 1, par4, -1); + boolean flag2 = RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3, par4 - 1, 2) || !world.isBlockNormalCube(par2, par3, par4 - 1) + && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 - 1, par4 - 1, -1); + boolean flag3 = RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3, par4 + 1, 0) || !world.isBlockNormalCube(par2, par3, par4 + 1) + && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 - 1, par4 + 1, -1); + + if (!world.isBlockNormalCube(par2, par3 + 1, par4)) + { + if (world.isBlockNormalCube(par2 - 1, par3, par4) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 - 1, par3 + 1, par4, -1)) + { + flag = true; + } + + if (world.isBlockNormalCube(par2 + 1, par3, par4) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 + 1, par3 + 1, par4, -1)) + { + flag1 = true; + } + + if (world.isBlockNormalCube(par2, par3, par4 - 1) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 + 1, par4 - 1, -1)) + { + flag2 = true; + } + + if (world.isBlockNormalCube(par2, par3, par4 + 1) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 + 1, par4 + 1, -1)) + { + flag3 = true; + } + } + + float f5 = (float) (par2 + 0); + float f6 = (float) (par2 + 1); + float f7 = (float) (par4 + 0); + float f8 = (float) (par4 + 1); + int i1 = 0; + + if ((flag || flag1) && !flag2 && !flag3) + { + i1 = 1; + } + + if ((flag2 || flag3) && !flag1 && !flag) + { + i1 = 2; + } + + if (i1 == 0) + { + int j1 = 0; + int k1 = 0; + int l1 = 16; + int i2 = 16; + + if (!flag) + { + f5 += 0.3125F; + } + + if (!flag) + { + j1 += 5; + } + + if (!flag1) + { + f6 -= 0.3125F; + } + + if (!flag1) + { + l1 -= 5; + } + + if (!flag2) + { + f7 += 0.3125F; + } + + if (!flag2) + { + k1 += 5; + } + + if (!flag3) + { + f8 -= 0.3125F; + } + + if (!flag3) + { + i2 -= 5; + } + + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon.getInterpolatedU((double) l1), (double) icon.getInterpolatedV((double) i2)); + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon.getInterpolatedU((double) l1), (double) icon.getInterpolatedV((double) k1)); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon.getInterpolatedU((double) j1), (double) icon.getInterpolatedV((double) k1)); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon.getInterpolatedU((double) j1), (double) icon.getInterpolatedV((double) i2)); + tessellator.setColorOpaque_F(f, f, f); + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon2.getInterpolatedU((double) l1), (double) icon2.getInterpolatedV((double) i2)); + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon2.getInterpolatedU((double) l1), (double) icon2.getInterpolatedV((double) k1)); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon2.getInterpolatedU((double) j1), (double) icon2.getInterpolatedV((double) k1)); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon2.getInterpolatedU((double) j1), (double) icon2.getInterpolatedV((double) i2)); + } + else if (i1 == 1) + { + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon1.getMaxU(), (double) icon1.getMaxV()); + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon1.getMaxU(), (double) icon1.getMinV()); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon1.getMinU(), (double) icon1.getMinV()); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon1.getMinU(), (double) icon1.getMaxV()); + tessellator.setColorOpaque_F(f, f, f); + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon3.getMaxU(), (double) icon3.getMaxV()); + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon3.getMaxU(), (double) icon3.getMinV()); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon3.getMinU(), (double) icon3.getMinV()); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon3.getMinU(), (double) icon3.getMaxV()); + } + else + { + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon1.getMaxU(), (double) icon1.getMaxV()); + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon1.getMinU(), (double) icon1.getMaxV()); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon1.getMinU(), (double) icon1.getMinV()); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon1.getMaxU(), (double) icon1.getMinV()); + tessellator.setColorOpaque_F(f, f, f); + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon3.getMaxU(), (double) icon3.getMaxV()); + tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon3.getMinU(), (double) icon3.getMaxV()); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon3.getMinU(), (double) icon3.getMinV()); + tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon3.getMaxU(), (double) icon3.getMinV()); + } + + if (!world.isBlockNormalCube(par2, par3 + 1, par4)) + { + if (world.isBlockNormalCube(par2 - 1, par3, par4) && world.getBlockId(par2 - 1, par3 + 1, par4) == Block.redstoneWire.blockID) + { + tessellator.setColorOpaque_F(f * f2, f * f3, f * f4); + tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1), (double) icon1.getMaxU(), (double) icon1.getMinV()); + tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) (par3 + 0), (double) (par4 + 1), (double) icon1.getMinU(), (double) icon1.getMinV()); + tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) (par3 + 0), (double) (par4 + 0), (double) icon1.getMinU(), (double) icon1.getMaxV()); + tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 0), (double) icon1.getMaxU(), (double) icon1.getMaxV()); + tessellator.setColorOpaque_F(f, f, f); + tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1), (double) icon3.getMaxU(), (double) icon3.getMinV()); + tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) (par3 + 0), (double) (par4 + 1), (double) icon3.getMinU(), (double) icon3.getMinV()); + tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) (par3 + 0), (double) (par4 + 0), (double) icon3.getMinU(), (double) icon3.getMaxV()); + tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 0), (double) icon3.getMaxU(), (double) icon3.getMaxV()); + } + + if (world.isBlockNormalCube(par2 + 1, par3, par4) && world.getBlockId(par2 + 1, par3 + 1, par4) == Block.redstoneWire.blockID) + { + tessellator.setColorOpaque_F(f * f2, f * f3, f * f4); + tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) (par3 + 0), (double) (par4 + 1), (double) icon1.getMinU(), (double) icon1.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1), (double) icon1.getMaxU(), (double) icon1.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 0), (double) icon1.getMaxU(), (double) icon1.getMinV()); + tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) (par3 + 0), (double) (par4 + 0), (double) icon1.getMinU(), (double) icon1.getMinV()); + tessellator.setColorOpaque_F(f, f, f); + tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) (par3 + 0), (double) (par4 + 1), (double) icon3.getMinU(), (double) icon3.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1), (double) icon3.getMaxU(), (double) icon3.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 0), (double) icon3.getMaxU(), (double) icon3.getMinV()); + tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) (par3 + 0), (double) (par4 + 0), (double) icon3.getMinU(), (double) icon3.getMinV()); + } + + if (world.isBlockNormalCube(par2, par3, par4 - 1) && world.getBlockId(par2, par3 + 1, par4 - 1) == Block.redstoneWire.blockID) + { + tessellator.setColorOpaque_F(f * f2, f * f3, f * f4); + tessellator.addVertexWithUV((double) (par2 + 1), (double) (par3 + 0), (double) par4 + 0.015625D, (double) icon1.getMinU(), (double) icon1.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 1), (double) ((float) (par3 + 1) + 0.021875F), (double) par4 + 0.015625D, (double) icon1.getMaxU(), (double) icon1.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 0), (double) ((float) (par3 + 1) + 0.021875F), (double) par4 + 0.015625D, (double) icon1.getMaxU(), (double) icon1.getMinV()); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) par4 + 0.015625D, (double) icon1.getMinU(), (double) icon1.getMinV()); + tessellator.setColorOpaque_F(f, f, f); + tessellator.addVertexWithUV((double) (par2 + 1), (double) (par3 + 0), (double) par4 + 0.015625D, (double) icon3.getMinU(), (double) icon3.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 1), (double) ((float) (par3 + 1) + 0.021875F), (double) par4 + 0.015625D, (double) icon3.getMaxU(), (double) icon3.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 0), (double) ((float) (par3 + 1) + 0.021875F), (double) par4 + 0.015625D, (double) icon3.getMaxU(), (double) icon3.getMinV()); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) par4 + 0.015625D, (double) icon3.getMinU(), (double) icon3.getMinV()); + } + + if (world.isBlockNormalCube(par2, par3, par4 + 1) && world.getBlockId(par2, par3 + 1, par4 + 1) == Block.redstoneWire.blockID) + { + tessellator.setColorOpaque_F(f * f2, f * f3, f * f4); + tessellator.addVertexWithUV((double) (par2 + 1), (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1) - 0.015625D, (double) icon1.getMaxU(), (double) icon1.getMinV()); + tessellator.addVertexWithUV((double) (par2 + 1), (double) (par3 + 0), (double) (par4 + 1) - 0.015625D, (double) icon1.getMinU(), (double) icon1.getMinV()); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) (par4 + 1) - 0.015625D, (double) icon1.getMinU(), (double) icon1.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 0), (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1) - 0.015625D, (double) icon1.getMaxU(), (double) icon1.getMaxV()); + tessellator.setColorOpaque_F(f, f, f); + tessellator.addVertexWithUV((double) (par2 + 1), (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1) - 0.015625D, (double) icon3.getMaxU(), (double) icon3.getMinV()); + tessellator.addVertexWithUV((double) (par2 + 1), (double) (par3 + 0), (double) (par4 + 1) - 0.015625D, (double) icon3.getMinU(), (double) icon3.getMinV()); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) (par4 + 1) - 0.015625D, (double) icon3.getMinU(), (double) icon3.getMaxV()); + tessellator.addVertexWithUV((double) (par2 + 0), (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1) - 0.015625D, (double) icon3.getMaxU(), (double) icon3.getMaxV()); + } + } + + return true; + } +} diff --git a/tconstruct/client/block/BarricadeRender.java b/tconstruct/client/block/BarricadeRender.java new file mode 100644 index 00000000..80100674 --- /dev/null +++ b/tconstruct/client/block/BarricadeRender.java @@ -0,0 +1,1135 @@ +package tconstruct.client.block; + +import tconstruct.client.TProxyClient; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Icon; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class BarricadeRender implements ISimpleBlockRenderingHandler +{ + public static int model; + + public BarricadeRender() + { + model = RenderingRegistry.getNextAvailableRenderId(); + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block barricade, int modelId, RenderBlocks renderer) + { + if (modelId == model) + { + int meta = world.getBlockMetadata(x, y, z); + Tessellator tessellator = Tessellator.instance; + + if ((meta < 4) || (meta == 10) || (meta == 11)) + { + renderInnerEast(renderer, world, x, y, z, (Block) barricade, tessellator); + } + + if (((meta < 4) && (meta > 0)) || (meta == 11)) + { + renderOuterEast(renderer, world, x, y, z, (Block) barricade, tessellator); + } + + if ((meta == 2) || (meta == 3) || ((meta >= 8) && (meta <= 11))) + { + renderInnerWest(renderer, world, x, y, z, (Block) barricade, tessellator); + } + + if ((meta == 3) || ((meta >= 9) && (meta <= 11))) + { + renderOuterWest(renderer, world, x, y, z, (Block) barricade, tessellator); + } + + if (((meta >= 4) && (meta <= 7)) || (meta >= 14)) + { + renderInnerSouth(renderer, world, x, y, z, (Block) barricade, tessellator); + } + + if (((meta >= 5) && (meta <= 7)) || (meta == 15)) + { + renderOuterSouth(renderer, world, x, y, z, (Block) barricade, tessellator); + } + + if ((meta == 6) || (meta == 7) || (meta >= 12)) + { + renderInnerNorth(renderer, world, x, y, z, (Block) barricade, tessellator); + } + + if ((meta == 7) || (meta >= 13)) + { + renderOuterNorth(renderer, world, x, y, z, (Block) barricade, tessellator); + } + + return true; + } + return false; + } + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + block.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + block.setBlockBounds(0.375F, 0.375F, 0.0F, 0.625F, 0.625F, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return model; + } + + private static void renderInnerWest (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, Block barricade, Tessellator tessellator) + { + tessellator.setBrightness(barricade.getMixedBrightnessForBlock(renderblocks.blockAccess, x, y, z)); + float f3 = 1.0F; + + if (Block.lightValue[barricade.blockID] > 0) + { + f3 = 1.0F; + } + + tessellator.setColorOpaque_F(f3, f3, f3); + Icon icon = renderblocks.getBlockIconFromSide(barricade, 0); + + if (renderblocks.hasOverrideBlockTexture()) + { + icon = renderblocks.overrideBlockTexture; + } + + double d0 = (double) icon.getMinU(); + double d1 = (double) icon.getMinV(); + double d2 = (double) icon.getMaxU(); + double d3 = (double) icon.getMaxV(); + Vec3[] vec1 = new Vec3[8]; + float minSize = 0.0625F; + float maxSize = 0.0625F; + float height = 0.625F; + vec1[0] = renderblocks.blockAccess.getWorldVec3Pool().getVecFromPool((double) (-minSize), 0.0D, (double) (-maxSize)); + vec1[1] = renderblocks.blockAccess.getWorldVec3Pool().getVecFromPool((double) minSize, 0.0D, (double) (-maxSize)); + vec1[2] = renderblocks.blockAccess.getWorldVec3Pool().getVecFromPool((double) minSize, 0.0D, (double) maxSize); + vec1[3] = renderblocks.blockAccess.getWorldVec3Pool().getVecFromPool((double) (-minSize), 0.0D, (double) maxSize); + vec1[4] = renderblocks.blockAccess.getWorldVec3Pool().getVecFromPool((double) (-minSize), (double) height, (double) (-maxSize)); + vec1[5] = renderblocks.blockAccess.getWorldVec3Pool().getVecFromPool((double) minSize, (double) height, (double) (-maxSize)); + vec1[6] = renderblocks.blockAccess.getWorldVec3Pool().getVecFromPool((double) minSize, (double) height, (double) maxSize); + vec1[7] = renderblocks.blockAccess.getWorldVec3Pool().getVecFromPool((double) (-minSize), (double) height, (double) maxSize); + + int l = renderblocks.blockAccess.getBlockMetadata(x, y, z); + int i1 = l & 7; + boolean flag = (l & 8) > 0; + + for (int j1 = 0; j1 < 8; ++j1) + { + if (flag) + { + vec1[j1].zCoord -= 0.0625D; + vec1[j1].rotateAroundX(((float) Math.PI * 2F / 9F)); + } + else + { + vec1[j1].zCoord += 0.0625D; + vec1[j1].rotateAroundX(-((float) Math.PI * 2F / 9F)); + } + + if (i1 == 0 || i1 == 7) + { + vec1[j1].rotateAroundZ((float) Math.PI); + } + + if (i1 == 6 || i1 == 0) + { + vec1[j1].rotateAroundY(((float) Math.PI / 2F)); + } + + if (i1 > 0 && i1 < 5) + { + vec1[j1].yCoord -= 0.375D; + vec1[j1].rotateAroundX(((float) Math.PI / 2F)); + + if (i1 == 4) + { + vec1[j1].rotateAroundY(0.0F); + } + + if (i1 == 3) + { + vec1[j1].rotateAroundY((float) Math.PI); + } + + if (i1 == 2) + { + vec1[j1].rotateAroundY(((float) Math.PI / 2F)); + } + + if (i1 == 1) + { + vec1[j1].rotateAroundY(-((float) Math.PI / 2F)); + } + + vec1[j1].xCoord += (double) x + 0.5D; + vec1[j1].yCoord += (double) ((float) y + 0.5F); + vec1[j1].zCoord += (double) z + 0.5D; + } + else if (i1 != 0 && i1 != 7) + { + vec1[j1].xCoord += (double) x + 0.5D; + vec1[j1].yCoord += (double) ((float) y + 0.125F); + vec1[j1].zCoord += (double) z + 0.5D; + } + else + { + vec1[j1].xCoord += (double) x + 0.5D; + vec1[j1].yCoord += (double) ((float) y + 0.875F); + vec1[j1].zCoord += (double) z + 0.5D; + } + } + + Vec3 vec3 = null; + Vec3 vec31 = null; + Vec3 vec32 = null; + Vec3 vec33 = null; + + for (int k1 = 0; k1 < 6; ++k1) + { + if (k1 == 0) + { + d0 = (double) icon.getInterpolatedU(7.0D); + d1 = (double) icon.getInterpolatedV(6.0D); + d2 = (double) icon.getInterpolatedU(9.0D); + d3 = (double) icon.getInterpolatedV(8.0D); + } + else if (k1 == 2) + { + d0 = (double) icon.getInterpolatedU(7.0D); + d1 = (double) icon.getInterpolatedV(6.0D); + d2 = (double) icon.getInterpolatedU(9.0D); + d3 = (double) icon.getMaxV(); + } + + if (k1 == 0) + { + vec3 = vec1[0]; + vec31 = vec1[1]; + vec32 = vec1[2]; + vec33 = vec1[3]; + } + else if (k1 == 1) + { + vec3 = vec1[7]; + vec31 = vec1[6]; + vec32 = vec1[5]; + vec33 = vec1[4]; + } + else if (k1 == 2) + { + vec3 = vec1[1]; + vec31 = vec1[0]; + vec32 = vec1[4]; + vec33 = vec1[5]; + } + else if (k1 == 3) + { + vec3 = vec1[2]; + vec31 = vec1[1]; + vec32 = vec1[5]; + vec33 = vec1[6]; + } + else if (k1 == 4) + { + vec3 = vec1[3]; + vec31 = vec1[2]; + vec32 = vec1[6]; + vec33 = vec1[7]; + } + else if (k1 == 5) + { + vec3 = vec1[0]; + vec31 = vec1[3]; + vec32 = vec1[7]; + vec33 = vec1[4]; + } + + tessellator.addVertexWithUV(vec3.xCoord, vec3.yCoord, vec3.zCoord, d0, d3); + tessellator.addVertexWithUV(vec31.xCoord, vec31.yCoord, vec31.zCoord, d2, d3); + tessellator.addVertexWithUV(vec32.xCoord, vec32.yCoord, vec32.zCoord, d2, d1); + tessellator.addVertexWithUV(vec33.xCoord, vec33.yCoord, vec33.zCoord, d0, d1); + } + + /*tessellator.setBrightness(barricade.getMixedBrightnessForBlock(iblockaccess, x, y, z)); + float color = 1.0F; + + tessellator.setColorOpaque_F(color, color, color); + Icon icon = renderblocks.getBlockIconFromSide(barricade, 0); + double tex1 = (double)icon.getMinU(); + double tex2 = (double)icon.getMinV(); + double tex3 = (double)icon.getMaxU(); + double tex4 = (double)icon.getMaxV(); + Vec3[] vec1 = new Vec3[8]; + float minSize = 0.125F; + float maxSize = 0.125F; + float height = 1.416F; + vec1[0] = Vec3.createVectorHelper(-minSize, 0.0D, -maxSize); + vec1[1] = Vec3.createVectorHelper(minSize, 0.0D, -maxSize); + vec1[2] = Vec3.createVectorHelper(minSize, 0.0D, maxSize); + vec1[3] = Vec3.createVectorHelper(-minSize, 0.0D, maxSize); + vec1[4] = Vec3.createVectorHelper(-minSize, height, -maxSize); + vec1[5] = Vec3.createVectorHelper(minSize, height, -maxSize); + vec1[6] = Vec3.createVectorHelper(minSize, height, maxSize); + vec1[7] = Vec3.createVectorHelper(-minSize, height, maxSize); + for (int var25 = 0; var25 < 8; var25++) + { + vec1[var25].zCoord -= 0.0625D; + vec1[var25].rotateAroundX(-0.7853982F); + vec1[var25].yCoord -= 0.5D; + vec1[var25].rotateAroundX(1.570796F); + + vec1[var25].xCoord += x + 0.625D; + vec1[var25].yCoord += y; + vec1[var25].zCoord += z + 0.5D; + } + + Vec3 vec1a = null; + Vec3 vec1b = null; + Vec3 vec1c = null; + Vec3 vec1d = null; + + for (int iter = 0; iter < 6; iter++) + { + if (iter == 0) + { + tex1 = (double)icon.getInterpolatedU(7.0D); + tex2 = (double)icon.getInterpolatedV(6.0D); + tex3 = (double)icon.getInterpolatedU(9.0D); + tex4 = (double)icon.getInterpolatedV(8.0D); + } + else if (iter == 2) + { + tex1 = (double)icon.getInterpolatedU(7.0D); + tex2 = (double)icon.getInterpolatedV(6.0D); + tex3 = (double)icon.getInterpolatedU(9.0D); + tex4 = (double)icon.getMaxV(); + } + + if (iter == 0) + { + vec1a = vec1[0]; + vec1b = vec1[1]; + vec1c = vec1[2]; + vec1d = vec1[3]; + } + else if (iter == 1) + { + vec1a = vec1[7]; + vec1b = vec1[6]; + vec1c = vec1[5]; + vec1d = vec1[4]; + } + else if (iter == 2) + { + vec1a = vec1[1]; + vec1b = vec1[0]; + vec1c = vec1[4]; + vec1d = vec1[5]; + } + else if (iter == 3) + { + vec1a = vec1[2]; + vec1b = vec1[1]; + vec1c = vec1[5]; + vec1d = vec1[6]; + } + else if (iter == 4) + { + vec1a = vec1[3]; + vec1b = vec1[2]; + vec1c = vec1[6]; + vec1d = vec1[7]; + } + else if (iter == 5) + { + vec1a = vec1[0]; + vec1b = vec1[3]; + vec1c = vec1[7]; + vec1d = vec1[4]; + } + + tessellator.addVertexWithUV(vec1a.xCoord, vec1a.yCoord, vec1a.zCoord, tex1, tex4); + tessellator.addVertexWithUV(vec1b.xCoord, vec1b.yCoord, vec1b.zCoord, tex2, tex4); + tessellator.addVertexWithUV(vec1c.xCoord, vec1c.yCoord, vec1c.zCoord, tex2, tex3); + tessellator.addVertexWithUV(vec1d.xCoord, vec1d.yCoord, vec1d.zCoord, tex1, tex3); + }*/ + } + + private static void renderOuterWest (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, Block barricade, Tessellator tessellator) + { + tessellator.setBrightness(barricade.getMixedBrightnessForBlock(iblockaccess, x, y, z)); + float color = 1.0F; + + tessellator.setColorOpaque_F(color, color, color); + Icon icon = renderblocks.getBlockIconFromSide(barricade, 0); + double tex1 = (double) icon.getMinU(); + double tex2 = (double) icon.getMinV(); + double tex3 = (double) icon.getMaxU(); + double tex4 = (double) icon.getMaxV(); + Vec3[] vec2 = new Vec3[8]; + float minSize = 0.125F; + float maxSize = 0.125F; + float height = 1.416F; + + vec2[0] = Vec3.createVectorHelper(-minSize, 0.0D, -maxSize); + vec2[1] = Vec3.createVectorHelper(minSize, 0.0D, -maxSize); + vec2[2] = Vec3.createVectorHelper(minSize, 0.0D, maxSize); + vec2[3] = Vec3.createVectorHelper(-minSize, 0.0D, maxSize); + vec2[4] = Vec3.createVectorHelper(-minSize, height, -maxSize); + vec2[5] = Vec3.createVectorHelper(minSize, height, -maxSize); + vec2[6] = Vec3.createVectorHelper(minSize, height, maxSize); + vec2[7] = Vec3.createVectorHelper(-minSize, height, maxSize); + + for (int var25 = 0; var25 < 8; var25++) + { + vec2[var25].zCoord -= 0.0625D; + vec2[var25].rotateAroundX(-0.7853982F); + vec2[var25].yCoord -= 0.5D; + vec2[var25].rotateAroundX(1.570796F); + + vec2[var25].xCoord += x + 0.125D; + vec2[var25].yCoord += y; + vec2[var25].zCoord += z + 0.5D; + } + Vec3 vec2a = null; + Vec3 vec2b = null; + Vec3 vec2c = null; + Vec3 vec2d = null; + + for (int iter = 0; iter < 6; iter++) + { + if (iter == 0) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getInterpolatedV(8.0D); + } + else if (iter == 2) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getMaxV(); + } + + if (iter == 0) + { + vec2a = vec2[0]; + vec2b = vec2[1]; + vec2c = vec2[2]; + vec2d = vec2[3]; + } + else if (iter == 1) + { + vec2a = vec2[7]; + vec2b = vec2[6]; + vec2c = vec2[5]; + vec2d = vec2[4]; + } + else if (iter == 2) + { + vec2a = vec2[1]; + vec2b = vec2[0]; + vec2c = vec2[4]; + vec2d = vec2[5]; + } + else if (iter == 3) + { + vec2a = vec2[2]; + vec2b = vec2[1]; + vec2c = vec2[5]; + vec2d = vec2[6]; + } + else if (iter == 4) + { + vec2a = vec2[3]; + vec2b = vec2[2]; + vec2c = vec2[6]; + vec2d = vec2[7]; + } + else if (iter == 5) + { + vec2a = vec2[0]; + vec2b = vec2[3]; + vec2c = vec2[7]; + vec2d = vec2[4]; + } + + tessellator.addVertexWithUV(vec2a.xCoord, vec2a.yCoord, vec2a.zCoord, tex1, tex4); + tessellator.addVertexWithUV(vec2b.xCoord, vec2b.yCoord, vec2b.zCoord, tex2, tex4); + tessellator.addVertexWithUV(vec2c.xCoord, vec2c.yCoord, vec2c.zCoord, tex2, tex3); + tessellator.addVertexWithUV(vec2d.xCoord, vec2d.yCoord, vec2d.zCoord, tex1, tex3); + } + } + + private static void renderInnerEast (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, Block barricade, Tessellator tessellator) + { + tessellator.setBrightness(barricade.getMixedBrightnessForBlock(iblockaccess, x, y, z)); + float color = 1.0F; + + tessellator.setColorOpaque_F(color, color, color); + Icon icon = renderblocks.getBlockIconFromSide(barricade, 0); + double tex1 = (double) icon.getMinU(); + double tex2 = (double) icon.getMinV(); + double tex3 = (double) icon.getMaxU(); + double tex4 = (double) icon.getMaxV(); + Vec3[] vec3 = new Vec3[8]; + float minSize = 0.125F; + float maxSize = 0.125F; + float height = 1.416F; + vec3[0] = Vec3.createVectorHelper(-minSize, 0.0D, -maxSize); + vec3[1] = Vec3.createVectorHelper(minSize, 0.0D, -maxSize); + vec3[2] = Vec3.createVectorHelper(minSize, 0.0D, maxSize); + vec3[3] = Vec3.createVectorHelper(-minSize, 0.0D, maxSize); + vec3[4] = Vec3.createVectorHelper(-minSize, height, -maxSize); + vec3[5] = Vec3.createVectorHelper(minSize, height, -maxSize); + vec3[6] = Vec3.createVectorHelper(minSize, height, maxSize); + vec3[7] = Vec3.createVectorHelper(-minSize, height, maxSize); + + for (int var25 = 0; var25 < 8; var25++) + { + vec3[var25].zCoord -= 0.0625D; + vec3[var25].rotateAroundX(-0.7853982F); + vec3[var25].yCoord -= 0.0625D; + vec3[var25].rotateAroundX(6.283186F); + + vec3[var25].xCoord += x + 0.375D; + vec3[var25].yCoord += y; + vec3[var25].zCoord += z; + } + + Vec3 vec3a = null; + Vec3 vec3b = null; + Vec3 vec3c = null; + Vec3 Vec3 = null; + + for (int iter = 0; iter < 6; iter++) + { + if (iter == 0) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getInterpolatedV(8.0D); + } + else if (iter == 2) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getMaxV(); + } + + if (iter == 0) + { + vec3a = vec3[0]; + vec3b = vec3[1]; + vec3c = vec3[2]; + Vec3 = vec3[3]; + } + else if (iter == 1) + { + vec3a = vec3[7]; + vec3b = vec3[6]; + vec3c = vec3[5]; + Vec3 = vec3[4]; + } + else if (iter == 2) + { + vec3a = vec3[1]; + vec3b = vec3[0]; + vec3c = vec3[4]; + Vec3 = vec3[5]; + } + else if (iter == 3) + { + vec3a = vec3[2]; + vec3b = vec3[1]; + vec3c = vec3[5]; + Vec3 = vec3[6]; + } + else if (iter == 4) + { + vec3a = vec3[2]; + vec3b = vec3[1]; + vec3c = vec3[5]; + Vec3 = vec3[6]; + } + else if (iter == 5) + { + vec3a = vec3[0]; + vec3b = vec3[3]; + vec3c = vec3[7]; + Vec3 = vec3[4]; + } + + tessellator.addVertexWithUV(vec3a.xCoord, vec3a.yCoord, vec3a.zCoord, tex1, tex4); + tessellator.addVertexWithUV(vec3b.xCoord, vec3b.yCoord, vec3b.zCoord, tex2, tex4); + tessellator.addVertexWithUV(vec3c.xCoord, vec3c.yCoord, vec3c.zCoord, tex2, tex3); + tessellator.addVertexWithUV(Vec3.xCoord, Vec3.yCoord, Vec3.zCoord, tex1, tex3); + } + } + + private static void renderOuterEast (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, Block barricade, Tessellator tessellator) + { + tessellator.setBrightness(barricade.getMixedBrightnessForBlock(iblockaccess, x, y, z)); + float color = 1.0F; + + tessellator.setColorOpaque_F(color, color, color); + Icon icon = renderblocks.getBlockIconFromSide(barricade, 0); + double tex1 = (double) icon.getMinU(); + double tex2 = (double) icon.getMinV(); + double tex3 = (double) icon.getMaxU(); + double tex4 = (double) icon.getMaxV(); + Vec3[] vec4 = new Vec3[8]; + float minSize = 0.125F; + float maxSize = 0.125F; + float height = 1.416F; + + vec4[0] = Vec3.createVectorHelper(-minSize, 0.0D, -maxSize); + vec4[1] = Vec3.createVectorHelper(minSize, 0.0D, -maxSize); + vec4[2] = Vec3.createVectorHelper(minSize, 0.0D, maxSize); + vec4[3] = Vec3.createVectorHelper(-minSize, 0.0D, maxSize); + vec4[4] = Vec3.createVectorHelper(-minSize, height, -maxSize); + vec4[5] = Vec3.createVectorHelper(minSize, height, -maxSize); + vec4[6] = Vec3.createVectorHelper(minSize, height, maxSize); + vec4[7] = Vec3.createVectorHelper(-minSize, height, maxSize); + + for (int var25 = 0; var25 < 8; var25++) + { + vec4[var25].zCoord -= 0.0625D; + vec4[var25].rotateAroundX(-0.7853982F); + vec4[var25].yCoord -= 0.0625D; + vec4[var25].rotateAroundX(6.283186F); + + vec4[var25].xCoord += x + 0.875D; + vec4[var25].yCoord += y; + vec4[var25].zCoord += z; + } + + Vec3 vec4a = null; + Vec3 vec4b = null; + Vec3 vec4c = null; + Vec3 vec4d = null; + + for (int iter = 0; iter < 6; iter++) + { + if (iter == 0) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getInterpolatedV(8.0D); + } + else if (iter == 2) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getMaxV(); + } + + if (iter == 0) + { + vec4a = vec4[0]; + vec4b = vec4[1]; + vec4c = vec4[2]; + vec4d = vec4[3]; + } + else if (iter == 1) + { + vec4a = vec4[7]; + vec4b = vec4[6]; + vec4c = vec4[5]; + vec4d = vec4[4]; + } + else if (iter == 2) + { + vec4a = vec4[1]; + vec4b = vec4[0]; + vec4c = vec4[4]; + vec4d = vec4[5]; + } + else if (iter == 3) + { + vec4a = vec4[2]; + vec4b = vec4[1]; + vec4c = vec4[5]; + vec4d = vec4[6]; + } + else if (iter == 4) + { + vec4a = vec4[2]; + vec4b = vec4[1]; + vec4c = vec4[5]; + vec4d = vec4[6]; + } + else if (iter == 5) + { + vec4a = vec4[0]; + vec4b = vec4[3]; + vec4c = vec4[7]; + vec4d = vec4[4]; + } + + tessellator.addVertexWithUV(vec4a.xCoord, vec4a.yCoord, vec4a.zCoord, tex1, tex4); + tessellator.addVertexWithUV(vec4b.xCoord, vec4b.yCoord, vec4b.zCoord, tex2, tex4); + tessellator.addVertexWithUV(vec4c.xCoord, vec4c.yCoord, vec4c.zCoord, tex2, tex3); + tessellator.addVertexWithUV(vec4d.xCoord, vec4d.yCoord, vec4d.zCoord, tex1, tex3); + } + } + + private static void renderInnerNorth (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, Block barricade, Tessellator tessellator) + { + tessellator.setBrightness(barricade.getMixedBrightnessForBlock(iblockaccess, x, y, z)); + float color = 1.0F; + + tessellator.setColorOpaque_F(color, color, color); + Icon icon = renderblocks.getBlockIconFromSide(barricade, 0); + double tex1 = (double) icon.getMinU(); + double tex2 = (double) icon.getMinV(); + double tex3 = (double) icon.getMaxU(); + double tex4 = (double) icon.getMaxV(); + Vec3[] vec1 = new Vec3[8]; + float minSize = 0.125F; + float maxSize = 0.125F; + float height = 1.416F; + vec1[0] = Vec3.createVectorHelper(-minSize, 0.0D, -maxSize); + vec1[1] = Vec3.createVectorHelper(minSize, 0.0D, -maxSize); + vec1[2] = Vec3.createVectorHelper(minSize, 0.0D, maxSize); + vec1[3] = Vec3.createVectorHelper(-minSize, 0.0D, maxSize); + vec1[4] = Vec3.createVectorHelper(-minSize, height, -maxSize); + vec1[5] = Vec3.createVectorHelper(minSize, height, -maxSize); + vec1[6] = Vec3.createVectorHelper(minSize, height, maxSize); + vec1[7] = Vec3.createVectorHelper(-minSize, height, maxSize); + + for (int var25 = 0; var25 < 8; var25++) + { + vec1[var25].zCoord -= 0.4375D; + vec1[var25].rotateAroundX(-0.7853982F); + vec1[var25].yCoord -= 0.5D; + vec1[var25].rotateAroundY(1.570796F); + + vec1[var25].xCoord += x + 0.375D; + vec1[var25].yCoord += y + 0.1875D; + vec1[var25].zCoord += z + 0.625D; + } + + Vec3 vec1a = null; + Vec3 vec1b = null; + Vec3 vec1c = null; + Vec3 vec1d = null; + + for (int iter = 0; iter < 6; iter++) + { + if (iter == 0) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getInterpolatedV(8.0D); + } + else if (iter == 2) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getMaxV(); + } + + if (iter == 0) + { + vec1a = vec1[0]; + vec1b = vec1[1]; + vec1c = vec1[2]; + vec1d = vec1[3]; + } + else if (iter == 1) + { + vec1a = vec1[7]; + vec1b = vec1[6]; + vec1c = vec1[5]; + vec1d = vec1[4]; + } + else if (iter == 2) + { + vec1a = vec1[1]; + vec1b = vec1[0]; + vec1c = vec1[4]; + vec1d = vec1[5]; + } + else if (iter == 3) + { + vec1a = vec1[2]; + vec1b = vec1[1]; + vec1c = vec1[5]; + vec1d = vec1[6]; + } + else if (iter == 4) + { + vec1a = vec1[3]; + vec1b = vec1[2]; + vec1c = vec1[6]; + vec1d = vec1[7]; + } + else if (iter == 5) + { + vec1a = vec1[0]; + vec1b = vec1[3]; + vec1c = vec1[7]; + vec1d = vec1[4]; + } + + tessellator.addVertexWithUV(vec1a.xCoord, vec1a.yCoord, vec1a.zCoord, tex1, tex4); + tessellator.addVertexWithUV(vec1b.xCoord, vec1b.yCoord, vec1b.zCoord, tex2, tex4); + tessellator.addVertexWithUV(vec1c.xCoord, vec1c.yCoord, vec1c.zCoord, tex2, tex3); + tessellator.addVertexWithUV(vec1d.xCoord, vec1d.yCoord, vec1d.zCoord, tex1, tex3); + } + } + + private static void renderOuterNorth (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, Block barricade, Tessellator tessellator) + { + tessellator.setBrightness(barricade.getMixedBrightnessForBlock(iblockaccess, x, y, z)); + float color = 1.0F; + + tessellator.setColorOpaque_F(color, color, color); + Icon icon = renderblocks.getBlockIconFromSide(barricade, 0); + double tex1 = (double) icon.getMinU(); + double tex2 = (double) icon.getMinV(); + double tex3 = (double) icon.getMaxU(); + double tex4 = (double) icon.getMaxV(); + Vec3[] vec2 = new Vec3[8]; + float minSize = 0.125F; + float maxSize = 0.125F; + float height = 1.416F; + vec2[0] = Vec3.createVectorHelper(-minSize, 0.0D, -maxSize); + vec2[1] = Vec3.createVectorHelper(minSize, 0.0D, -maxSize); + vec2[2] = Vec3.createVectorHelper(minSize, 0.0D, maxSize); + vec2[3] = Vec3.createVectorHelper(-minSize, 0.0D, maxSize); + vec2[4] = Vec3.createVectorHelper(-minSize, height, -maxSize); + vec2[5] = Vec3.createVectorHelper(minSize, height, -maxSize); + vec2[6] = Vec3.createVectorHelper(minSize, height, maxSize); + vec2[7] = Vec3.createVectorHelper(-minSize, height, maxSize); + + for (int var25 = 0; var25 < 8; var25++) + { + vec2[var25].zCoord -= 0.4375D; + vec2[var25].rotateAroundX(-0.7853982F); + vec2[var25].yCoord -= 0.5D; + vec2[var25].rotateAroundY(1.570796F); + + vec2[var25].xCoord += x + 0.375D; + vec2[var25].yCoord += y + 0.1875D; + vec2[var25].zCoord += z + 0.125D; + } + + Vec3 vec2a = null; + Vec3 vec2b = null; + Vec3 vec2c = null; + Vec3 vec2d = null; + + for (int iter = 0; iter < 6; iter++) + { + if (iter == 0) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getInterpolatedV(8.0D); + } + else if (iter == 2) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getMaxV(); + } + + if (iter == 0) + { + vec2a = vec2[0]; + vec2b = vec2[1]; + vec2c = vec2[2]; + vec2d = vec2[3]; + } + else if (iter == 1) + { + vec2a = vec2[7]; + vec2b = vec2[6]; + vec2c = vec2[5]; + vec2d = vec2[4]; + } + else if (iter == 2) + { + vec2a = vec2[1]; + vec2b = vec2[0]; + vec2c = vec2[4]; + vec2d = vec2[5]; + } + else if (iter == 3) + { + vec2a = vec2[2]; + vec2b = vec2[1]; + vec2c = vec2[5]; + vec2d = vec2[6]; + } + else if (iter == 4) + { + vec2a = vec2[3]; + vec2b = vec2[2]; + vec2c = vec2[6]; + vec2d = vec2[7]; + } + else if (iter == 5) + { + vec2a = vec2[0]; + vec2b = vec2[3]; + vec2c = vec2[7]; + vec2d = vec2[4]; + } + + tessellator.addVertexWithUV(vec2a.xCoord, vec2a.yCoord, vec2a.zCoord, tex1, tex4); + tessellator.addVertexWithUV(vec2b.xCoord, vec2b.yCoord, vec2b.zCoord, tex2, tex4); + tessellator.addVertexWithUV(vec2c.xCoord, vec2c.yCoord, vec2c.zCoord, tex2, tex3); + tessellator.addVertexWithUV(vec2d.xCoord, vec2d.yCoord, vec2d.zCoord, tex1, tex3); + } + } + + private static void renderInnerSouth (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, Block barricade, Tessellator tessellator) + { + tessellator.setBrightness(barricade.getMixedBrightnessForBlock(iblockaccess, x, y, z)); + float color = 1.0F; + + tessellator.setColorOpaque_F(color, color, color); + + Icon icon = renderblocks.getBlockIconFromSide(barricade, 0); + double tex1 = (double) icon.getMinU(); + double tex2 = (double) icon.getMinV(); + double tex3 = (double) icon.getMaxU(); + double tex4 = (double) icon.getMaxV(); + Vec3[] vec3 = new Vec3[8]; + float minSize = 0.125F; + float maxSize = 0.125F; + float height = 1.416F; + vec3[0] = Vec3.createVectorHelper(-minSize, 0.0D, -maxSize); + vec3[1] = Vec3.createVectorHelper(minSize, 0.0D, -maxSize); + vec3[2] = Vec3.createVectorHelper(minSize, 0.0D, maxSize); + vec3[3] = Vec3.createVectorHelper(-minSize, 0.0D, maxSize); + vec3[4] = Vec3.createVectorHelper(-minSize, height, -maxSize); + vec3[5] = Vec3.createVectorHelper(minSize, height, -maxSize); + vec3[6] = Vec3.createVectorHelper(minSize, height, maxSize); + vec3[7] = Vec3.createVectorHelper(-minSize, height, maxSize); + + for (int var25 = 0; var25 < 8; var25++) + { + vec3[var25].zCoord -= 0.4375D; + vec3[var25].rotateAroundX(-0.7853982F); + vec3[var25].yCoord -= 0.5D; + vec3[var25].rotateAroundY(4.712389F); + + vec3[var25].xCoord += x + 0.625D; + vec3[var25].yCoord += y + 0.1875D; + vec3[var25].zCoord += z + 0.375D; + } + Vec3 vec3a = null; + Vec3 vec3b = null; + Vec3 vec3c = null; + Vec3 Vec3 = null; + for (int iter = 0; iter < 6; iter++) + { + if (iter == 0) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getInterpolatedV(8.0D); + } + else if (iter == 2) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getMaxV(); + } + + if (iter == 0) + { + vec3a = vec3[0]; + vec3b = vec3[1]; + vec3c = vec3[2]; + Vec3 = vec3[3]; + } + else if (iter == 1) + { + vec3a = vec3[7]; + vec3b = vec3[6]; + vec3c = vec3[5]; + Vec3 = vec3[4]; + } + else if (iter == 2) + { + vec3a = vec3[1]; + vec3b = vec3[0]; + vec3c = vec3[4]; + Vec3 = vec3[5]; + } + else if (iter == 3) + { + vec3a = vec3[2]; + vec3b = vec3[1]; + vec3c = vec3[5]; + Vec3 = vec3[6]; + } + else if (iter == 4) + { + vec3a = vec3[2]; + vec3b = vec3[1]; + vec3c = vec3[5]; + Vec3 = vec3[6]; + } + else if (iter == 5) + { + vec3a = vec3[0]; + vec3b = vec3[3]; + vec3c = vec3[7]; + Vec3 = vec3[4]; + } + + tessellator.addVertexWithUV(vec3a.xCoord, vec3a.yCoord, vec3a.zCoord, tex1, tex4); + tessellator.addVertexWithUV(vec3b.xCoord, vec3b.yCoord, vec3b.zCoord, tex2, tex4); + tessellator.addVertexWithUV(vec3c.xCoord, vec3c.yCoord, vec3c.zCoord, tex2, tex3); + tessellator.addVertexWithUV(Vec3.xCoord, Vec3.yCoord, Vec3.zCoord, tex1, tex3); + } + } + + private static void renderOuterSouth (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, Block barricade, Tessellator tessellator) + { + tessellator.setBrightness(barricade.getMixedBrightnessForBlock(iblockaccess, x, y, z)); + float color = 1.0F; + + tessellator.setColorOpaque_F(color, color, color); + Icon icon = renderblocks.getBlockIconFromSide(barricade, 0); + double tex1 = (double) icon.getMinU(); + double tex2 = (double) icon.getMinV(); + double tex3 = (double) icon.getMaxU(); + double tex4 = (double) icon.getMaxV(); + Vec3[] vec4 = new Vec3[8]; + float minSize = 0.125F; + float maxSize = 0.125F; + float height = 1.416F; + vec4[0] = Vec3.createVectorHelper(-minSize, 0.0D, -maxSize); + vec4[1] = Vec3.createVectorHelper(minSize, 0.0D, -maxSize); + vec4[2] = Vec3.createVectorHelper(minSize, 0.0D, maxSize); + vec4[3] = Vec3.createVectorHelper(-minSize, 0.0D, maxSize); + vec4[4] = Vec3.createVectorHelper(-minSize, height, -maxSize); + vec4[5] = Vec3.createVectorHelper(minSize, height, -maxSize); + vec4[6] = Vec3.createVectorHelper(minSize, height, maxSize); + vec4[7] = Vec3.createVectorHelper(-minSize, height, maxSize); + + for (int var25 = 0; var25 < 8; var25++) + { + vec4[var25].zCoord -= 0.4375D; + vec4[var25].rotateAroundX(-0.7853982F); + vec4[var25].yCoord -= 0.5D; + vec4[var25].rotateAroundY(4.712389F); + + vec4[var25].xCoord += x + 0.625D; + vec4[var25].yCoord += y + 0.1875D; + vec4[var25].zCoord += z + 0.875D; + } + + Vec3 vec4a = null; + Vec3 vec4b = null; + Vec3 vec4c = null; + Vec3 vec4d = null; + + for (int iter = 0; iter < 6; iter++) + { + if (iter == 0) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getInterpolatedV(8.0D); + } + else if (iter == 2) + { + tex1 = (double) icon.getInterpolatedU(7.0D); + tex2 = (double) icon.getInterpolatedV(6.0D); + tex3 = (double) icon.getInterpolatedU(9.0D); + tex4 = (double) icon.getMaxV(); + } + + if (iter == 0) + { + vec4a = vec4[0]; + vec4b = vec4[1]; + vec4c = vec4[2]; + vec4d = vec4[3]; + } + else if (iter == 1) + { + vec4a = vec4[7]; + vec4b = vec4[6]; + vec4c = vec4[5]; + vec4d = vec4[4]; + } + else if (iter == 2) + { + vec4a = vec4[1]; + vec4b = vec4[0]; + vec4c = vec4[4]; + vec4d = vec4[5]; + } + else if (iter == 3) + { + vec4a = vec4[2]; + vec4b = vec4[1]; + vec4c = vec4[5]; + vec4d = vec4[6]; + } + else if (iter == 4) + { + vec4a = vec4[2]; + vec4b = vec4[1]; + vec4c = vec4[5]; + vec4d = vec4[6]; + } + else if (iter == 5) + { + vec4a = vec4[0]; + vec4b = vec4[3]; + vec4c = vec4[7]; + vec4d = vec4[4]; + } + + tessellator.addVertexWithUV(vec4a.xCoord, vec4a.yCoord, vec4a.zCoord, tex1, tex4); + tessellator.addVertexWithUV(vec4b.xCoord, vec4b.yCoord, vec4b.zCoord, tex2, tex4); + tessellator.addVertexWithUV(vec4c.xCoord, vec4c.yCoord, vec4c.zCoord, tex2, tex3); + tessellator.addVertexWithUV(vec4d.xCoord, vec4d.yCoord, vec4d.zCoord, tex1, tex3); + } + } +} diff --git a/tconstruct/client/block/BlockSkinRenderHelper.java b/tconstruct/client/block/BlockSkinRenderHelper.java new file mode 100644 index 00000000..0f0b1c6d --- /dev/null +++ b/tconstruct/client/block/BlockSkinRenderHelper.java @@ -0,0 +1,1685 @@ +package tconstruct.client.block; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; + +public class BlockSkinRenderHelper +{ + public static boolean renderMetadataBlock (Block block, int metadata, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) + { + int var5 = block.colorMultiplier(world, x, y, z); + float var6 = (float) (var5 >> 16 & 255) / 255.0F; + float var7 = (float) (var5 >> 8 & 255) / 255.0F; + float var8 = (float) (var5 & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float var9 = (var6 * 30.0F + var7 * 59.0F + var8 * 11.0F) / 100.0F; + float var10 = (var6 * 30.0F + var7 * 70.0F) / 100.0F; + float var11 = (var6 * 30.0F + var8 * 70.0F) / 100.0F; + var6 = var9; + var7 = var10; + var8 = var11; + } + + return Minecraft.isAmbientOcclusionEnabled() && Block.lightValue[block.blockID] == 0 ? renderMetadataBlockWithAmbientOcclusion(block, metadata, x, y, z, var6, var7, var8, renderer, world) + : renderMetadataBlockWithColorMultiplier(block, metadata, x, y, z, var6, var7, var8, renderer, world); + } + + static boolean renderMetadataBlockWithAmbientOcclusion (Block block, int metadata, int xPos, int yPos, int zPos, float colorRed, float colorGreen, float colorBlue, RenderBlocks render, + IBlockAccess world) + { + render.enableAO = true; + boolean flag = false; + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + boolean flag1 = true; + int l = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(983055); + + if (render.getBlockIcon(block).getIconName().equals("grass_top")) + { + flag1 = false; + } + else if (render.hasOverrideBlockTexture()) + { + flag1 = false; + } + + boolean flag2; + boolean flag3; + boolean flag4; + boolean flag5; + float f7; + int i1; + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos - 1, zPos, 0)) + { + if (render.renderMinY <= 0.0D) + { + --yPos; + } + + render.aoBrightnessXYNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + render.aoBrightnessYZNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + render.aoBrightnessYZNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + render.aoBrightnessXYPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + render.aoLightValueScratchXYNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + render.aoLightValueScratchYZNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + render.aoLightValueScratchYZNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + render.aoLightValueScratchXYPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos - 1, zPos)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos - 1, zPos)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos - 1, zPos + 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos - 1, zPos - 1)]; + + if (!flag4 && !flag2) + { + render.aoLightValueScratchXYZNNN = render.aoLightValueScratchXYNN; + render.aoBrightnessXYZNNN = render.aoBrightnessXYNN; + } + else + { + render.aoLightValueScratchXYZNNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos - 1); + render.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag5 && !flag2) + { + render.aoLightValueScratchXYZNNP = render.aoLightValueScratchXYNN; + render.aoBrightnessXYZNNP = render.aoBrightnessXYNN; + } + else + { + render.aoLightValueScratchXYZNNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos + 1); + render.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag4 && !flag3) + { + render.aoLightValueScratchXYZPNN = render.aoLightValueScratchXYPN; + render.aoBrightnessXYZPNN = render.aoBrightnessXYPN; + } + else + { + render.aoLightValueScratchXYZPNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos - 1); + render.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag5 && !flag3) + { + render.aoLightValueScratchXYZPNP = render.aoLightValueScratchXYPN; + render.aoBrightnessXYZPNP = render.aoBrightnessXYPN; + } + else + { + render.aoLightValueScratchXYZPNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos + 1); + render.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (render.renderMinY <= 0.0D) + { + ++yPos; + } + + i1 = l; + + if (render.renderMinY <= 0.0D || !render.blockAccess.isBlockOpaqueCube(xPos, yPos - 1, zPos)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + f3 = (render.aoLightValueScratchXYZNNP + render.aoLightValueScratchXYNN + render.aoLightValueScratchYZNP + f7) / 4.0F; + f6 = (render.aoLightValueScratchYZNP + f7 + render.aoLightValueScratchXYZPNP + render.aoLightValueScratchXYPN) / 4.0F; + f5 = (f7 + render.aoLightValueScratchYZNN + render.aoLightValueScratchXYPN + render.aoLightValueScratchXYZPNN) / 4.0F; + f4 = (render.aoLightValueScratchXYNN + render.aoLightValueScratchXYZNNN + f7 + render.aoLightValueScratchYZNN) / 4.0F; + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXYZNNP, render.aoBrightnessXYNN, render.aoBrightnessYZNP, i1); + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessYZNP, render.aoBrightnessXYZPNP, render.aoBrightnessXYPN, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessYZNN, render.aoBrightnessXYPN, render.aoBrightnessXYZPNN, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessXYNN, render.aoBrightnessXYZNNN, render.aoBrightnessYZNN, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.5F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.5F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.5F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.5F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.5F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.5F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + render.renderFaceYNeg(block, (double) xPos, (double) yPos, (double) zPos, block.getIcon(0, metadata)); + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos + 1, zPos, 1)) + { + if (render.renderMaxY >= 1.0D) + { + ++yPos; + } + + render.aoBrightnessXYNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + render.aoBrightnessXYPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + render.aoBrightnessYZPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + render.aoBrightnessYZPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + render.aoLightValueScratchXYNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + render.aoLightValueScratchXYPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + render.aoLightValueScratchYZPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + render.aoLightValueScratchYZPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos + 1, zPos)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos + 1, zPos)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos + 1, zPos + 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos + 1, zPos - 1)]; + + if (!flag4 && !flag2) + { + render.aoLightValueScratchXYZNPN = render.aoLightValueScratchXYNP; + render.aoBrightnessXYZNPN = render.aoBrightnessXYNP; + } + else + { + render.aoLightValueScratchXYZNPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos - 1); + render.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag4 && !flag3) + { + render.aoLightValueScratchXYZPPN = render.aoLightValueScratchXYPP; + render.aoBrightnessXYZPPN = render.aoBrightnessXYPP; + } + else + { + render.aoLightValueScratchXYZPPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos - 1); + render.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag5 && !flag2) + { + render.aoLightValueScratchXYZNPP = render.aoLightValueScratchXYNP; + render.aoBrightnessXYZNPP = render.aoBrightnessXYNP; + } + else + { + render.aoLightValueScratchXYZNPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos + 1); + render.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag5 && !flag3) + { + render.aoLightValueScratchXYZPPP = render.aoLightValueScratchXYPP; + render.aoBrightnessXYZPPP = render.aoBrightnessXYPP; + } + else + { + render.aoLightValueScratchXYZPPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos + 1); + render.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (render.renderMaxY >= 1.0D) + { + --yPos; + } + + i1 = l; + + if (render.renderMaxY >= 1.0D || !render.blockAccess.isBlockOpaqueCube(xPos, yPos + 1, zPos)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + f6 = (render.aoLightValueScratchXYZNPP + render.aoLightValueScratchXYNP + render.aoLightValueScratchYZPP + f7) / 4.0F; + f3 = (render.aoLightValueScratchYZPP + f7 + render.aoLightValueScratchXYZPPP + render.aoLightValueScratchXYPP) / 4.0F; + f4 = (f7 + render.aoLightValueScratchYZPN + render.aoLightValueScratchXYPP + render.aoLightValueScratchXYZPPN) / 4.0F; + f5 = (render.aoLightValueScratchXYNP + render.aoLightValueScratchXYZNPN + f7 + render.aoLightValueScratchYZPN) / 4.0F; + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessXYZNPP, render.aoBrightnessXYNP, render.aoBrightnessYZPP, i1); + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessYZPP, render.aoBrightnessXYZPPP, render.aoBrightnessXYPP, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessYZPN, render.aoBrightnessXYPP, render.aoBrightnessXYZPPN, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessXYNP, render.aoBrightnessXYZNPN, render.aoBrightnessYZPN, i1); + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue; + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + render.renderFaceYPos(block, (double) xPos, (double) yPos, (double) zPos, block.getIcon(1, metadata)); + flag = true; + } + + Icon icon; + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos, zPos - 1, 2)) + { + if (render.renderMinZ <= 0.0D) + { + --zPos; + } + + render.aoLightValueScratchXZNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + render.aoLightValueScratchYZNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + render.aoLightValueScratchYZPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + render.aoLightValueScratchXZPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + render.aoBrightnessXZNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + render.aoBrightnessYZNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + render.aoBrightnessYZPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + render.aoBrightnessXZPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos, zPos - 1)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos, zPos - 1)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos + 1, zPos - 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos - 1, zPos - 1)]; + + if (!flag2 && !flag4) + { + render.aoLightValueScratchXYZNNN = render.aoLightValueScratchXZNN; + render.aoBrightnessXYZNNN = render.aoBrightnessXZNN; + } + else + { + render.aoLightValueScratchXYZNNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos - 1, zPos); + render.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag2 && !flag5) + { + render.aoLightValueScratchXYZNPN = render.aoLightValueScratchXZNN; + render.aoBrightnessXYZNPN = render.aoBrightnessXZNN; + } + else + { + render.aoLightValueScratchXYZNPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos + 1, zPos); + render.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag3 && !flag4) + { + render.aoLightValueScratchXYZPNN = render.aoLightValueScratchXZPN; + render.aoBrightnessXYZPNN = render.aoBrightnessXZPN; + } + else + { + render.aoLightValueScratchXYZPNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos - 1, zPos); + render.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag3 && !flag5) + { + render.aoLightValueScratchXYZPPN = render.aoLightValueScratchXZPN; + render.aoBrightnessXYZPPN = render.aoBrightnessXZPN; + } + else + { + render.aoLightValueScratchXYZPPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos + 1, zPos); + render.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (render.renderMinZ <= 0.0D) + { + ++zPos; + } + + i1 = l; + + if (render.renderMinZ <= 0.0D || !render.blockAccess.isBlockOpaqueCube(xPos, yPos, zPos - 1)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + f3 = (render.aoLightValueScratchXZNN + render.aoLightValueScratchXYZNPN + f7 + render.aoLightValueScratchYZPN) / 4.0F; + f4 = (f7 + render.aoLightValueScratchYZPN + render.aoLightValueScratchXZPN + render.aoLightValueScratchXYZPPN) / 4.0F; + f5 = (render.aoLightValueScratchYZNN + f7 + render.aoLightValueScratchXYZPNN + render.aoLightValueScratchXZPN) / 4.0F; + f6 = (render.aoLightValueScratchXYZNNN + render.aoLightValueScratchXZNN + render.aoLightValueScratchYZNN + f7) / 4.0F; + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXZNN, render.aoBrightnessXYZNPN, render.aoBrightnessYZPN, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessYZPN, render.aoBrightnessXZPN, render.aoBrightnessXYZPPN, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessYZNN, render.aoBrightnessXYZPNN, render.aoBrightnessXZPN, i1); + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessXYZNNN, render.aoBrightnessXZNN, render.aoBrightnessYZNN, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.8F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.8F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.8F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.8F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.8F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.8F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + icon = block.getIcon(2, metadata); + render.renderFaceZNeg(block, (double) xPos, (double) yPos, (double) zPos, icon); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos, zPos + 1, 3)) + { + if (render.renderMaxZ >= 1.0D) + { + ++zPos; + } + + render.aoLightValueScratchXZNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + render.aoLightValueScratchXZPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + render.aoLightValueScratchYZNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + render.aoLightValueScratchYZPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + render.aoBrightnessXZNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + render.aoBrightnessXZPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + render.aoBrightnessYZNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + render.aoBrightnessYZPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos, zPos + 1)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos, zPos + 1)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos + 1, zPos + 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos - 1, zPos + 1)]; + + if (!flag2 && !flag4) + { + render.aoLightValueScratchXYZNNP = render.aoLightValueScratchXZNP; + render.aoBrightnessXYZNNP = render.aoBrightnessXZNP; + } + else + { + render.aoLightValueScratchXYZNNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos - 1, zPos); + render.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag2 && !flag5) + { + render.aoLightValueScratchXYZNPP = render.aoLightValueScratchXZNP; + render.aoBrightnessXYZNPP = render.aoBrightnessXZNP; + } + else + { + render.aoLightValueScratchXYZNPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos + 1, zPos); + render.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag3 && !flag4) + { + render.aoLightValueScratchXYZPNP = render.aoLightValueScratchXZPP; + render.aoBrightnessXYZPNP = render.aoBrightnessXZPP; + } + else + { + render.aoLightValueScratchXYZPNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos - 1, zPos); + render.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag3 && !flag5) + { + render.aoLightValueScratchXYZPPP = render.aoLightValueScratchXZPP; + render.aoBrightnessXYZPPP = render.aoBrightnessXZPP; + } + else + { + render.aoLightValueScratchXYZPPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos + 1, zPos); + render.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (render.renderMaxZ >= 1.0D) + { + --zPos; + } + + i1 = l; + + if (render.renderMaxZ >= 1.0D || !render.blockAccess.isBlockOpaqueCube(xPos, yPos, zPos + 1)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + f3 = (render.aoLightValueScratchXZNP + render.aoLightValueScratchXYZNPP + f7 + render.aoLightValueScratchYZPP) / 4.0F; + f6 = (f7 + render.aoLightValueScratchYZPP + render.aoLightValueScratchXZPP + render.aoLightValueScratchXYZPPP) / 4.0F; + f5 = (render.aoLightValueScratchYZNP + f7 + render.aoLightValueScratchXYZPNP + render.aoLightValueScratchXZPP) / 4.0F; + f4 = (render.aoLightValueScratchXYZNNP + render.aoLightValueScratchXZNP + render.aoLightValueScratchYZNP + f7) / 4.0F; + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXZNP, render.aoBrightnessXYZNPP, render.aoBrightnessYZPP, i1); + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessYZPP, render.aoBrightnessXZPP, render.aoBrightnessXYZPPP, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessYZNP, render.aoBrightnessXYZPNP, render.aoBrightnessXZPP, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessXYZNNP, render.aoBrightnessXZNP, render.aoBrightnessYZNP, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.8F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.8F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.8F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.8F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.8F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.8F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + icon = block.getIcon(3, metadata); + render.renderFaceZPos(block, (double) xPos, (double) yPos, (double) zPos, icon); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos - 1, yPos, zPos, 4)) + { + if (render.renderMinX <= 0.0D) + { + --xPos; + } + + render.aoLightValueScratchXYNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + render.aoLightValueScratchXZNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + render.aoLightValueScratchXZNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + render.aoLightValueScratchXYNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + render.aoBrightnessXYNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + render.aoBrightnessXZNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + render.aoBrightnessXZNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + render.aoBrightnessXYNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos + 1, zPos)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos - 1, zPos)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos, zPos - 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos, zPos + 1)]; + + if (!flag5 && !flag2) + { + render.aoLightValueScratchXYZNNN = render.aoLightValueScratchXZNN; + render.aoBrightnessXYZNNN = render.aoBrightnessXZNN; + } + else + { + render.aoLightValueScratchXYZNNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos - 1); + render.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag4 && !flag2) + { + render.aoLightValueScratchXYZNNP = render.aoLightValueScratchXZNP; + render.aoBrightnessXYZNNP = render.aoBrightnessXZNP; + } + else + { + render.aoLightValueScratchXYZNNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos + 1); + render.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag5 && !flag3) + { + render.aoLightValueScratchXYZNPN = render.aoLightValueScratchXZNN; + render.aoBrightnessXYZNPN = render.aoBrightnessXZNN; + } + else + { + render.aoLightValueScratchXYZNPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos - 1); + render.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag4 && !flag3) + { + render.aoLightValueScratchXYZNPP = render.aoLightValueScratchXZNP; + render.aoBrightnessXYZNPP = render.aoBrightnessXZNP; + } + else + { + render.aoLightValueScratchXYZNPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos + 1); + render.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (render.renderMinX <= 0.0D) + { + ++xPos; + } + + i1 = l; + + if (render.renderMinX <= 0.0D || !render.blockAccess.isBlockOpaqueCube(xPos - 1, yPos, zPos)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + f6 = (render.aoLightValueScratchXYNN + render.aoLightValueScratchXYZNNP + f7 + render.aoLightValueScratchXZNP) / 4.0F; + f3 = (f7 + render.aoLightValueScratchXZNP + render.aoLightValueScratchXYNP + render.aoLightValueScratchXYZNPP) / 4.0F; + f4 = (render.aoLightValueScratchXZNN + f7 + render.aoLightValueScratchXYZNPN + render.aoLightValueScratchXYNP) / 4.0F; + f5 = (render.aoLightValueScratchXYZNNN + render.aoLightValueScratchXYNN + render.aoLightValueScratchXZNN + f7) / 4.0F; + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessXYNN, render.aoBrightnessXYZNNP, render.aoBrightnessXZNP, i1); + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXZNP, render.aoBrightnessXYNP, render.aoBrightnessXYZNPP, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessXZNN, render.aoBrightnessXYZNPN, render.aoBrightnessXYNP, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessXYZNNN, render.aoBrightnessXYNN, render.aoBrightnessXZNN, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.6F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.6F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.6F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.6F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.6F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.6F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + icon = block.getIcon(4, metadata); + render.renderFaceXNeg(block, (double) xPos, (double) yPos, (double) zPos, icon); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos + 1, yPos, zPos, 5)) + { + if (render.renderMaxX >= 1.0D) + { + ++xPos; + } + + render.aoLightValueScratchXYPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + render.aoLightValueScratchXZPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + render.aoLightValueScratchXZPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + render.aoLightValueScratchXYPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + render.aoBrightnessXYPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + render.aoBrightnessXZPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + render.aoBrightnessXZPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + render.aoBrightnessXYPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos + 1, zPos)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos - 1, zPos)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos, zPos + 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos, zPos - 1)]; + + if (!flag2 && !flag4) + { + render.aoLightValueScratchXYZPNN = render.aoLightValueScratchXZPN; + render.aoBrightnessXYZPNN = render.aoBrightnessXZPN; + } + else + { + render.aoLightValueScratchXYZPNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos - 1); + render.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag2 && !flag5) + { + render.aoLightValueScratchXYZPNP = render.aoLightValueScratchXZPP; + render.aoBrightnessXYZPNP = render.aoBrightnessXZPP; + } + else + { + render.aoLightValueScratchXYZPNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos + 1); + render.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag3 && !flag4) + { + render.aoLightValueScratchXYZPPN = render.aoLightValueScratchXZPN; + render.aoBrightnessXYZPPN = render.aoBrightnessXZPN; + } + else + { + render.aoLightValueScratchXYZPPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos - 1); + render.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag3 && !flag5) + { + render.aoLightValueScratchXYZPPP = render.aoLightValueScratchXZPP; + render.aoBrightnessXYZPPP = render.aoBrightnessXZPP; + } + else + { + render.aoLightValueScratchXYZPPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos + 1); + render.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (render.renderMaxX >= 1.0D) + { + --xPos; + } + + i1 = l; + + if (render.renderMaxX >= 1.0D || !render.blockAccess.isBlockOpaqueCube(xPos + 1, yPos, zPos)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + f3 = (render.aoLightValueScratchXYPN + render.aoLightValueScratchXYZPNP + f7 + render.aoLightValueScratchXZPP) / 4.0F; + f4 = (render.aoLightValueScratchXYZPNN + render.aoLightValueScratchXYPN + render.aoLightValueScratchXZPN + f7) / 4.0F; + f5 = (render.aoLightValueScratchXZPN + f7 + render.aoLightValueScratchXYZPPN + render.aoLightValueScratchXYPP) / 4.0F; + f6 = (f7 + render.aoLightValueScratchXZPP + render.aoLightValueScratchXYPP + render.aoLightValueScratchXYZPPP) / 4.0F; + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXYPN, render.aoBrightnessXYZPNP, render.aoBrightnessXZPP, i1); + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessXZPP, render.aoBrightnessXYPP, render.aoBrightnessXYZPPP, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessXZPN, render.aoBrightnessXYZPPN, render.aoBrightnessXYPP, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessXYZPNN, render.aoBrightnessXYPN, render.aoBrightnessXZPN, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.6F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.6F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.6F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.6F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.6F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.6F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + icon = block.getIcon(5, metadata); + render.renderFaceXPos(block, (double) xPos, (double) yPos, (double) zPos, icon); + + flag = true; + } + + render.enableAO = false; + return flag; + } + + static boolean renderMetadataBlockWithColorMultiplier (Block block, int metadata, int xPos, int yPos, int zPos, float colorRed, float colorGreen, float colorBlue, RenderBlocks render, + IBlockAccess world) + { + render.enableAO = false; + Tessellator tessellator = Tessellator.instance; + boolean flag = false; + float f3 = 0.5F; + float f4 = 1.0F; + float f5 = 0.8F; + float f6 = 0.6F; + float f7 = f4 * colorRed; + float f8 = f4 * colorGreen; + float f9 = f4 * colorBlue; + float f10 = f3; + float f11 = f5; + float f12 = f6; + float f13 = f3; + float f14 = f5; + float f15 = f6; + float f16 = f3; + float f17 = f5; + float f18 = f6; + + if (block != Block.grass) + { + f10 = f3 * colorRed; + f11 = f5 * colorRed; + f12 = f6 * colorRed; + f13 = f3 * colorGreen; + f14 = f5 * colorGreen; + f15 = f6 * colorGreen; + f16 = f3 * colorBlue; + f17 = f5 * colorBlue; + f18 = f6 * colorBlue; + } + + int l = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos); + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos - 1, zPos, 0)) + { + tessellator.setBrightness(render.renderMinY > 0.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos)); + tessellator.setColorOpaque_F(f10, f13, f16); + render.renderFaceYNeg(block, (double) xPos, (double) yPos, (double) zPos, block.getIcon(0, metadata)); + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos + 1, zPos, 1)) + { + tessellator.setBrightness(render.renderMaxY < 1.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos)); + tessellator.setColorOpaque_F(f7, f8, f9); + render.renderFaceYPos(block, (double) xPos, (double) yPos, (double) zPos, block.getIcon(1, metadata)); + flag = true; + } + + Icon icon; + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos, zPos - 1, 2)) + { + tessellator.setBrightness(render.renderMinZ > 0.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1)); + tessellator.setColorOpaque_F(f11, f14, f17); + render.renderFaceZNeg(block, (double) xPos, (double) yPos, (double) zPos, block.getIcon(2, metadata)); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos, zPos + 1, 3)) + { + tessellator.setBrightness(render.renderMaxZ < 1.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1)); + tessellator.setColorOpaque_F(f11, f14, f17); + render.renderFaceZPos(block, (double) xPos, (double) yPos, (double) zPos, block.getIcon(3, metadata)); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos - 1, yPos, zPos, 4)) + { + tessellator.setBrightness(render.renderMinX > 0.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos)); + tessellator.setColorOpaque_F(f12, f15, f18); + render.renderFaceXNeg(block, (double) xPos, (double) yPos, (double) zPos, block.getIcon(4, metadata)); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos + 1, yPos, zPos, 5)) + { + tessellator.setBrightness(render.renderMaxX < 1.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos)); + tessellator.setColorOpaque_F(f12, f15, f18); + render.renderFaceXPos(block, (double) xPos, (double) yPos, (double) zPos, block.getIcon(5, metadata)); + + flag = true; + } + + return flag; + } + + public static boolean renderLiquidBlock (Icon stillIcon, Icon flowingIcon, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) + { + Block block = Block.stone; + int var5 = block.colorMultiplier(world, x, y, z); + float var6 = (float) (var5 >> 16 & 255) / 255.0F; + float var7 = (float) (var5 >> 8 & 255) / 255.0F; + float var8 = (float) (var5 & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float var9 = (var6 * 30.0F + var7 * 59.0F + var8 * 11.0F) / 100.0F; + float var10 = (var6 * 30.0F + var7 * 70.0F) / 100.0F; + float var11 = (var6 * 30.0F + var8 * 70.0F) / 100.0F; + var6 = var9; + var7 = var10; + var8 = var11; + } + + return Minecraft.isAmbientOcclusionEnabled() ? renderFakeBlockWithAmbientOcclusion(stillIcon, flowingIcon, x, y, z, var6, var7, var8, renderer, world) : renderFakeBlockWithColorMultiplier(stillIcon, flowingIcon, x, y, z, + var6, var7, var8, renderer, world); + } + + static boolean renderFakeBlockWithAmbientOcclusion (Icon stillIcon, Icon flowingIcon, int xPos, int yPos, int zPos, float colorRed, float colorGreen, float colorBlue, RenderBlocks render, IBlockAccess world) + { + Block block = Block.stone; + render.enableAO = true; + boolean flag = false; + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + boolean flag1 = true; + int l = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(983055); + + if (render.getBlockIcon(block).getIconName().equals("grass_top")) + { + flag1 = false; + } + else if (render.hasOverrideBlockTexture()) + { + flag1 = false; + } + + boolean flag2; + boolean flag3; + boolean flag4; + boolean flag5; + float f7; + int i1; + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos - 1, zPos, 0)) + { + if (render.renderMinY <= 0.0D) + { + --yPos; + } + + render.aoBrightnessXYNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + render.aoBrightnessYZNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + render.aoBrightnessYZNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + render.aoBrightnessXYPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + render.aoLightValueScratchXYNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + render.aoLightValueScratchYZNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + render.aoLightValueScratchYZNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + render.aoLightValueScratchXYPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos - 1, zPos)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos - 1, zPos)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos - 1, zPos + 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos - 1, zPos - 1)]; + + if (!flag4 && !flag2) + { + render.aoLightValueScratchXYZNNN = render.aoLightValueScratchXYNN; + render.aoBrightnessXYZNNN = render.aoBrightnessXYNN; + } + else + { + render.aoLightValueScratchXYZNNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos - 1); + render.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag5 && !flag2) + { + render.aoLightValueScratchXYZNNP = render.aoLightValueScratchXYNN; + render.aoBrightnessXYZNNP = render.aoBrightnessXYNN; + } + else + { + render.aoLightValueScratchXYZNNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos + 1); + render.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag4 && !flag3) + { + render.aoLightValueScratchXYZPNN = render.aoLightValueScratchXYPN; + render.aoBrightnessXYZPNN = render.aoBrightnessXYPN; + } + else + { + render.aoLightValueScratchXYZPNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos - 1); + render.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag5 && !flag3) + { + render.aoLightValueScratchXYZPNP = render.aoLightValueScratchXYPN; + render.aoBrightnessXYZPNP = render.aoBrightnessXYPN; + } + else + { + render.aoLightValueScratchXYZPNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos + 1); + render.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (render.renderMinY <= 0.0D) + { + ++yPos; + } + + i1 = l; + + if (render.renderMinY <= 0.0D || !render.blockAccess.isBlockOpaqueCube(xPos, yPos - 1, zPos)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + f3 = (render.aoLightValueScratchXYZNNP + render.aoLightValueScratchXYNN + render.aoLightValueScratchYZNP + f7) / 4.0F; + f6 = (render.aoLightValueScratchYZNP + f7 + render.aoLightValueScratchXYZPNP + render.aoLightValueScratchXYPN) / 4.0F; + f5 = (f7 + render.aoLightValueScratchYZNN + render.aoLightValueScratchXYPN + render.aoLightValueScratchXYZPNN) / 4.0F; + f4 = (render.aoLightValueScratchXYNN + render.aoLightValueScratchXYZNNN + f7 + render.aoLightValueScratchYZNN) / 4.0F; + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXYZNNP, render.aoBrightnessXYNN, render.aoBrightnessYZNP, i1); + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessYZNP, render.aoBrightnessXYZPNP, render.aoBrightnessXYPN, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessYZNN, render.aoBrightnessXYPN, render.aoBrightnessXYZPNN, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessXYNN, render.aoBrightnessXYZNNN, render.aoBrightnessYZNN, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.5F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.5F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.5F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.5F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.5F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.5F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + render.renderFaceYNeg(block, (double) xPos, (double) yPos, (double) zPos, stillIcon); + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos + 1, zPos, 1)) + { + if (render.renderMaxY >= 1.0D) + { + ++yPos; + } + + render.aoBrightnessXYNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + render.aoBrightnessXYPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + render.aoBrightnessYZPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + render.aoBrightnessYZPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + render.aoLightValueScratchXYNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + render.aoLightValueScratchXYPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + render.aoLightValueScratchYZPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + render.aoLightValueScratchYZPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos + 1, zPos)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos + 1, zPos)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos + 1, zPos + 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos + 1, zPos - 1)]; + + if (!flag4 && !flag2) + { + render.aoLightValueScratchXYZNPN = render.aoLightValueScratchXYNP; + render.aoBrightnessXYZNPN = render.aoBrightnessXYNP; + } + else + { + render.aoLightValueScratchXYZNPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos - 1); + render.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag4 && !flag3) + { + render.aoLightValueScratchXYZPPN = render.aoLightValueScratchXYPP; + render.aoBrightnessXYZPPN = render.aoBrightnessXYPP; + } + else + { + render.aoLightValueScratchXYZPPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos - 1); + render.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag5 && !flag2) + { + render.aoLightValueScratchXYZNPP = render.aoLightValueScratchXYNP; + render.aoBrightnessXYZNPP = render.aoBrightnessXYNP; + } + else + { + render.aoLightValueScratchXYZNPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos + 1); + render.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag5 && !flag3) + { + render.aoLightValueScratchXYZPPP = render.aoLightValueScratchXYPP; + render.aoBrightnessXYZPPP = render.aoBrightnessXYPP; + } + else + { + render.aoLightValueScratchXYZPPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos + 1); + render.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (render.renderMaxY >= 1.0D) + { + --yPos; + } + + i1 = l; + + if (render.renderMaxY >= 1.0D || !render.blockAccess.isBlockOpaqueCube(xPos, yPos + 1, zPos)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + f6 = (render.aoLightValueScratchXYZNPP + render.aoLightValueScratchXYNP + render.aoLightValueScratchYZPP + f7) / 4.0F; + f3 = (render.aoLightValueScratchYZPP + f7 + render.aoLightValueScratchXYZPPP + render.aoLightValueScratchXYPP) / 4.0F; + f4 = (f7 + render.aoLightValueScratchYZPN + render.aoLightValueScratchXYPP + render.aoLightValueScratchXYZPPN) / 4.0F; + f5 = (render.aoLightValueScratchXYNP + render.aoLightValueScratchXYZNPN + f7 + render.aoLightValueScratchYZPN) / 4.0F; + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessXYZNPP, render.aoBrightnessXYNP, render.aoBrightnessYZPP, i1); + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessYZPP, render.aoBrightnessXYZPPP, render.aoBrightnessXYPP, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessYZPN, render.aoBrightnessXYPP, render.aoBrightnessXYZPPN, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessXYNP, render.aoBrightnessXYZNPN, render.aoBrightnessYZPN, i1); + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue; + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + render.renderFaceYPos(block, (double) xPos, (double) yPos, (double) zPos, stillIcon); + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos, zPos - 1, 2)) + { + if (render.renderMinZ <= 0.0D) + { + --zPos; + } + + render.aoLightValueScratchXZNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + render.aoLightValueScratchYZNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + render.aoLightValueScratchYZPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + render.aoLightValueScratchXZPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + render.aoBrightnessXZNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + render.aoBrightnessYZNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + render.aoBrightnessYZPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + render.aoBrightnessXZPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos, zPos - 1)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos, zPos - 1)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos + 1, zPos - 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos - 1, zPos - 1)]; + + if (!flag2 && !flag4) + { + render.aoLightValueScratchXYZNNN = render.aoLightValueScratchXZNN; + render.aoBrightnessXYZNNN = render.aoBrightnessXZNN; + } + else + { + render.aoLightValueScratchXYZNNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos - 1, zPos); + render.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag2 && !flag5) + { + render.aoLightValueScratchXYZNPN = render.aoLightValueScratchXZNN; + render.aoBrightnessXYZNPN = render.aoBrightnessXZNN; + } + else + { + render.aoLightValueScratchXYZNPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos + 1, zPos); + render.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag3 && !flag4) + { + render.aoLightValueScratchXYZPNN = render.aoLightValueScratchXZPN; + render.aoBrightnessXYZPNN = render.aoBrightnessXZPN; + } + else + { + render.aoLightValueScratchXYZPNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos - 1, zPos); + render.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag3 && !flag5) + { + render.aoLightValueScratchXYZPPN = render.aoLightValueScratchXZPN; + render.aoBrightnessXYZPPN = render.aoBrightnessXZPN; + } + else + { + render.aoLightValueScratchXYZPPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos + 1, zPos); + render.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (render.renderMinZ <= 0.0D) + { + ++zPos; + } + + i1 = l; + + if (render.renderMinZ <= 0.0D || !render.blockAccess.isBlockOpaqueCube(xPos, yPos, zPos - 1)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + f3 = (render.aoLightValueScratchXZNN + render.aoLightValueScratchXYZNPN + f7 + render.aoLightValueScratchYZPN) / 4.0F; + f4 = (f7 + render.aoLightValueScratchYZPN + render.aoLightValueScratchXZPN + render.aoLightValueScratchXYZPPN) / 4.0F; + f5 = (render.aoLightValueScratchYZNN + f7 + render.aoLightValueScratchXYZPNN + render.aoLightValueScratchXZPN) / 4.0F; + f6 = (render.aoLightValueScratchXYZNNN + render.aoLightValueScratchXZNN + render.aoLightValueScratchYZNN + f7) / 4.0F; + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXZNN, render.aoBrightnessXYZNPN, render.aoBrightnessYZPN, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessYZPN, render.aoBrightnessXZPN, render.aoBrightnessXYZPPN, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessYZNN, render.aoBrightnessXYZPNN, render.aoBrightnessXZPN, i1); + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessXYZNNN, render.aoBrightnessXZNN, render.aoBrightnessYZNN, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.8F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.8F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.8F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.8F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.8F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.8F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + render.renderFaceZNeg(block, (double) xPos, (double) yPos, (double) zPos, flowingIcon); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos, zPos + 1, 3)) + { + if (render.renderMaxZ >= 1.0D) + { + ++zPos; + } + + render.aoLightValueScratchXZNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + render.aoLightValueScratchXZPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + render.aoLightValueScratchYZNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + render.aoLightValueScratchYZPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + render.aoBrightnessXZNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + render.aoBrightnessXZPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + render.aoBrightnessYZNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + render.aoBrightnessYZPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos, zPos + 1)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos, zPos + 1)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos + 1, zPos + 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos, yPos - 1, zPos + 1)]; + + if (!flag2 && !flag4) + { + render.aoLightValueScratchXYZNNP = render.aoLightValueScratchXZNP; + render.aoBrightnessXYZNNP = render.aoBrightnessXZNP; + } + else + { + render.aoLightValueScratchXYZNNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos - 1, zPos); + render.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag2 && !flag5) + { + render.aoLightValueScratchXYZNPP = render.aoLightValueScratchXZNP; + render.aoBrightnessXYZNPP = render.aoBrightnessXZNP; + } + else + { + render.aoLightValueScratchXYZNPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos + 1, zPos); + render.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag3 && !flag4) + { + render.aoLightValueScratchXYZPNP = render.aoLightValueScratchXZPP; + render.aoBrightnessXYZPNP = render.aoBrightnessXZPP; + } + else + { + render.aoLightValueScratchXYZPNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos - 1, zPos); + render.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag3 && !flag5) + { + render.aoLightValueScratchXYZPPP = render.aoLightValueScratchXZPP; + render.aoBrightnessXYZPPP = render.aoBrightnessXZPP; + } + else + { + render.aoLightValueScratchXYZPPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos + 1, zPos); + render.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (render.renderMaxZ >= 1.0D) + { + --zPos; + } + + i1 = l; + + if (render.renderMaxZ >= 1.0D || !render.blockAccess.isBlockOpaqueCube(xPos, yPos, zPos + 1)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + f3 = (render.aoLightValueScratchXZNP + render.aoLightValueScratchXYZNPP + f7 + render.aoLightValueScratchYZPP) / 4.0F; + f6 = (f7 + render.aoLightValueScratchYZPP + render.aoLightValueScratchXZPP + render.aoLightValueScratchXYZPPP) / 4.0F; + f5 = (render.aoLightValueScratchYZNP + f7 + render.aoLightValueScratchXYZPNP + render.aoLightValueScratchXZPP) / 4.0F; + f4 = (render.aoLightValueScratchXYZNNP + render.aoLightValueScratchXZNP + render.aoLightValueScratchYZNP + f7) / 4.0F; + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXZNP, render.aoBrightnessXYZNPP, render.aoBrightnessYZPP, i1); + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessYZPP, render.aoBrightnessXZPP, render.aoBrightnessXYZPPP, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessYZNP, render.aoBrightnessXYZPNP, render.aoBrightnessXZPP, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessXYZNNP, render.aoBrightnessXZNP, render.aoBrightnessYZNP, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.8F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.8F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.8F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.8F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.8F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.8F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + render.renderFaceZPos(block, (double) xPos, (double) yPos, (double) zPos, flowingIcon); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos - 1, yPos, zPos, 4)) + { + if (render.renderMinX <= 0.0D) + { + --xPos; + } + + render.aoLightValueScratchXYNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + render.aoLightValueScratchXZNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + render.aoLightValueScratchXZNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + render.aoLightValueScratchXYNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + render.aoBrightnessXYNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + render.aoBrightnessXZNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + render.aoBrightnessXZNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + render.aoBrightnessXYNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos + 1, zPos)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos - 1, zPos)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos, zPos - 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos - 1, yPos, zPos + 1)]; + + if (!flag5 && !flag2) + { + render.aoLightValueScratchXYZNNN = render.aoLightValueScratchXZNN; + render.aoBrightnessXYZNNN = render.aoBrightnessXZNN; + } + else + { + render.aoLightValueScratchXYZNNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos - 1); + render.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag4 && !flag2) + { + render.aoLightValueScratchXYZNNP = render.aoLightValueScratchXZNP; + render.aoBrightnessXYZNNP = render.aoBrightnessXZNP; + } + else + { + render.aoLightValueScratchXYZNNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos + 1); + render.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag5 && !flag3) + { + render.aoLightValueScratchXYZNPN = render.aoLightValueScratchXZNN; + render.aoBrightnessXYZNPN = render.aoBrightnessXZNN; + } + else + { + render.aoLightValueScratchXYZNPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos - 1); + render.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag4 && !flag3) + { + render.aoLightValueScratchXYZNPP = render.aoLightValueScratchXZNP; + render.aoBrightnessXYZNPP = render.aoBrightnessXZNP; + } + else + { + render.aoLightValueScratchXYZNPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos + 1); + render.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (render.renderMinX <= 0.0D) + { + ++xPos; + } + + i1 = l; + + if (render.renderMinX <= 0.0D || !render.blockAccess.isBlockOpaqueCube(xPos - 1, yPos, zPos)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos - 1, yPos, zPos); + f6 = (render.aoLightValueScratchXYNN + render.aoLightValueScratchXYZNNP + f7 + render.aoLightValueScratchXZNP) / 4.0F; + f3 = (f7 + render.aoLightValueScratchXZNP + render.aoLightValueScratchXYNP + render.aoLightValueScratchXYZNPP) / 4.0F; + f4 = (render.aoLightValueScratchXZNN + f7 + render.aoLightValueScratchXYZNPN + render.aoLightValueScratchXYNP) / 4.0F; + f5 = (render.aoLightValueScratchXYZNNN + render.aoLightValueScratchXYNN + render.aoLightValueScratchXZNN + f7) / 4.0F; + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessXYNN, render.aoBrightnessXYZNNP, render.aoBrightnessXZNP, i1); + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXZNP, render.aoBrightnessXYNP, render.aoBrightnessXYZNPP, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessXZNN, render.aoBrightnessXYZNPN, render.aoBrightnessXYNP, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessXYZNNN, render.aoBrightnessXYNN, render.aoBrightnessXZNN, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.6F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.6F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.6F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.6F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.6F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.6F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + render.renderFaceXNeg(block, (double) xPos, (double) yPos, (double) zPos, flowingIcon); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos + 1, yPos, zPos, 5)) + { + if (render.renderMaxX >= 1.0D) + { + ++xPos; + } + + render.aoLightValueScratchXYPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos); + render.aoLightValueScratchXZPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos - 1); + render.aoLightValueScratchXZPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos, zPos + 1); + render.aoLightValueScratchXYPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos); + render.aoBrightnessXYPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos); + render.aoBrightnessXZPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1); + render.aoBrightnessXZPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1); + render.aoBrightnessXYPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos); + flag3 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos + 1, zPos)]; + flag2 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos - 1, zPos)]; + flag5 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos, zPos + 1)]; + flag4 = Block.canBlockGrass[render.blockAccess.getBlockId(xPos + 1, yPos, zPos - 1)]; + + if (!flag2 && !flag4) + { + render.aoLightValueScratchXYZPNN = render.aoLightValueScratchXZPN; + render.aoBrightnessXYZPNN = render.aoBrightnessXZPN; + } + else + { + render.aoLightValueScratchXYZPNN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos - 1); + render.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag2 && !flag5) + { + render.aoLightValueScratchXYZPNP = render.aoLightValueScratchXZPP; + render.aoBrightnessXYZPNP = render.aoBrightnessXZPP; + } + else + { + render.aoLightValueScratchXYZPNP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos - 1, zPos + 1); + render.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag3 && !flag4) + { + render.aoLightValueScratchXYZPPN = render.aoLightValueScratchXZPN; + render.aoBrightnessXYZPPN = render.aoBrightnessXZPN; + } + else + { + render.aoLightValueScratchXYZPPN = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos - 1); + render.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag3 && !flag5) + { + render.aoLightValueScratchXYZPPP = render.aoLightValueScratchXZPP; + render.aoBrightnessXYZPPP = render.aoBrightnessXZPP; + } + else + { + render.aoLightValueScratchXYZPPP = block.getAmbientOcclusionLightValue(render.blockAccess, xPos, yPos + 1, zPos + 1); + render.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (render.renderMaxX >= 1.0D) + { + --xPos; + } + + i1 = l; + + if (render.renderMaxX >= 1.0D || !render.blockAccess.isBlockOpaqueCube(xPos + 1, yPos, zPos)) + { + i1 = block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos); + } + + f7 = block.getAmbientOcclusionLightValue(render.blockAccess, xPos + 1, yPos, zPos); + f3 = (render.aoLightValueScratchXYPN + render.aoLightValueScratchXYZPNP + f7 + render.aoLightValueScratchXZPP) / 4.0F; + f4 = (render.aoLightValueScratchXYZPNN + render.aoLightValueScratchXYPN + render.aoLightValueScratchXZPN + f7) / 4.0F; + f5 = (render.aoLightValueScratchXZPN + f7 + render.aoLightValueScratchXYZPPN + render.aoLightValueScratchXYPP) / 4.0F; + f6 = (f7 + render.aoLightValueScratchXZPP + render.aoLightValueScratchXYPP + render.aoLightValueScratchXYZPPP) / 4.0F; + render.brightnessTopLeft = render.getAoBrightness(render.aoBrightnessXYPN, render.aoBrightnessXYZPNP, render.aoBrightnessXZPP, i1); + render.brightnessTopRight = render.getAoBrightness(render.aoBrightnessXZPP, render.aoBrightnessXYPP, render.aoBrightnessXYZPPP, i1); + render.brightnessBottomRight = render.getAoBrightness(render.aoBrightnessXZPN, render.aoBrightnessXYZPPN, render.aoBrightnessXYPP, i1); + render.brightnessBottomLeft = render.getAoBrightness(render.aoBrightnessXYZPNN, render.aoBrightnessXYPN, render.aoBrightnessXZPN, i1); + + if (flag1) + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = colorRed * 0.6F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = colorGreen * 0.6F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = colorBlue * 0.6F; + } + else + { + render.colorRedTopLeft = render.colorRedBottomLeft = render.colorRedBottomRight = render.colorRedTopRight = 0.6F; + render.colorGreenTopLeft = render.colorGreenBottomLeft = render.colorGreenBottomRight = render.colorGreenTopRight = 0.6F; + render.colorBlueTopLeft = render.colorBlueBottomLeft = render.colorBlueBottomRight = render.colorBlueTopRight = 0.6F; + } + + render.colorRedTopLeft *= f3; + render.colorGreenTopLeft *= f3; + render.colorBlueTopLeft *= f3; + render.colorRedBottomLeft *= f4; + render.colorGreenBottomLeft *= f4; + render.colorBlueBottomLeft *= f4; + render.colorRedBottomRight *= f5; + render.colorGreenBottomRight *= f5; + render.colorBlueBottomRight *= f5; + render.colorRedTopRight *= f6; + render.colorGreenTopRight *= f6; + render.colorBlueTopRight *= f6; + render.renderFaceXPos(block, (double) xPos, (double) yPos, (double) zPos, flowingIcon); + + flag = true; + } + + render.enableAO = false; + return flag; + } + + static boolean renderFakeBlockWithColorMultiplier (Icon stillIcon, Icon flowingIcon, int xPos, int yPos, int zPos, float colorRed, float colorGreen, float colorBlue, RenderBlocks render, IBlockAccess world) + { + Block block = Block.stone; + render.enableAO = false; + Tessellator tessellator = Tessellator.instance; + boolean flag = false; + float f3 = 0.5F; + float f4 = 1.0F; + float f5 = 0.8F; + float f6 = 0.6F; + float f7 = f4 * colorRed; + float f8 = f4 * colorGreen; + float f9 = f4 * colorBlue; + float f10 = f3; + float f11 = f5; + float f12 = f6; + float f13 = f3; + float f14 = f5; + float f15 = f6; + float f16 = f3; + float f17 = f5; + float f18 = f6; + + if (block != Block.grass) + { + f10 = f3 * colorRed; + f11 = f5 * colorRed; + f12 = f6 * colorRed; + f13 = f3 * colorGreen; + f14 = f5 * colorGreen; + f15 = f6 * colorGreen; + f16 = f3 * colorBlue; + f17 = f5 * colorBlue; + f18 = f6 * colorBlue; + } + + int l = block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos); + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos - 1, zPos, 0)) + { + tessellator.setBrightness(render.renderMinY > 0.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos - 1, zPos)); + tessellator.setColorOpaque_F(f10, f13, f16); + render.renderFaceYNeg(block, (double) xPos, (double) yPos, (double) zPos, stillIcon); + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos + 1, zPos, 1)) + { + tessellator.setBrightness(render.renderMaxY < 1.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos + 1, zPos)); + tessellator.setColorOpaque_F(f7, f8, f9); + render.renderFaceYPos(block, (double) xPos, (double) yPos, (double) zPos, stillIcon); + flag = true; + } + + Icon icon; + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos, zPos - 1, 2)) + { + tessellator.setBrightness(render.renderMinZ > 0.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos - 1)); + tessellator.setColorOpaque_F(f11, f14, f17); + render.renderFaceZNeg(block, (double) xPos, (double) yPos, (double) zPos, flowingIcon); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos, yPos, zPos + 1, 3)) + { + tessellator.setBrightness(render.renderMaxZ < 1.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos, yPos, zPos + 1)); + tessellator.setColorOpaque_F(f11, f14, f17); + render.renderFaceZPos(block, (double) xPos, (double) yPos, (double) zPos, flowingIcon); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos - 1, yPos, zPos, 4)) + { + tessellator.setBrightness(render.renderMinX > 0.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos - 1, yPos, zPos)); + tessellator.setColorOpaque_F(f12, f15, f18); + render.renderFaceXNeg(block, (double) xPos, (double) yPos, (double) zPos, flowingIcon); + + flag = true; + } + + if (render.renderAllFaces || block.shouldSideBeRendered(render.blockAccess, xPos + 1, yPos, zPos, 5)) + { + tessellator.setBrightness(render.renderMaxX < 1.0D ? l : block.getMixedBrightnessForBlock(render.blockAccess, xPos + 1, yPos, zPos)); + tessellator.setColorOpaque_F(f12, f15, f18); + render.renderFaceXPos(block, (double) xPos, (double) yPos, (double) zPos, flowingIcon); + + flag = true; + } + + return flag; + } +} diff --git a/tconstruct/client/block/BreakingFX.java b/tconstruct/client/block/BreakingFX.java new file mode 100644 index 00000000..9e513ba5 --- /dev/null +++ b/tconstruct/client/block/BreakingFX.java @@ -0,0 +1,70 @@ +package tconstruct.client.block; + +import net.minecraft.block.Block; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.Item; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class BreakingFX extends EntityFX +{ + public BreakingFX(World par1World, double par2, double par4, double par6, Item par8Item) + { + this(par1World, par2, par4, par6, par8Item, 0); + } + + public BreakingFX(World par1World, double par2, double par4, double par6, Item par8Item, int par9) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.func_110125_a(par8Item.getIconFromDamage(par9)); + this.particleRed = this.particleGreen = this.particleBlue = 1.0F; + this.particleGravity = Block.blockSnow.blockParticleGravity; + this.particleScale /= 2.0F; + } + + public BreakingFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, Item par14Item, int par15) + { + this(par1World, par2, par4, par6, par14Item, par15); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + this.motionX += par8; + this.motionY += par10; + this.motionZ += par12; + } + + public int getFXLayer() + { + return 2; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleTextureIndexX + this.particleTextureJitterX / 4.0F) / 16.0F; + float f7 = f6 + 0.015609375F; + float f8 = ((float)this.particleTextureIndexY + this.particleTextureJitterY / 4.0F) / 16.0F; + float f9 = f8 + 0.015609375F; + float f10 = 0.1F * this.particleScale; + + if (this.particleIcon != null) + { + f6 = this.particleIcon.getInterpolatedU((double)(this.particleTextureJitterX / 4.0F * 16.0F)); + f7 = this.particleIcon.getInterpolatedU((double)((this.particleTextureJitterX + 1.0F) / 4.0F * 16.0F)); + f8 = this.particleIcon.getInterpolatedV((double)(this.particleTextureJitterY / 4.0F * 16.0F)); + f9 = this.particleIcon.getInterpolatedV((double)((this.particleTextureJitterY + 1.0F) / 4.0F * 16.0F)); + } + + float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); + float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); + float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); + float f14 = 1.0F; + par1Tessellator.setColorOpaque_F(f14 * this.particleRed, f14 * this.particleGreen, f14 * this.particleBlue); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f6, (double)f9); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f6, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f7, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f7, (double)f9); + } +} diff --git a/tconstruct/client/block/CastingBasinSpecialRender.java b/tconstruct/client/block/CastingBasinSpecialRender.java new file mode 100644 index 00000000..263fd3cd --- /dev/null +++ b/tconstruct/client/block/CastingBasinSpecialRender.java @@ -0,0 +1,69 @@ +package tconstruct.client.block; + +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.CastingBasinLogic; +import tconstruct.entity.FancyEntityItem; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/* Special renderer, only used for drawing tools */ + +@SideOnly(Side.CLIENT) +public class CastingBasinSpecialRender extends TileEntitySpecialRenderer +{ + @Override + public void renderTileEntityAt (TileEntity logic, double var2, double var4, double var6, float var8) + { + this.render((CastingBasinLogic) logic, var2, var4, var6, var8); + } + + public void render (CastingBasinLogic logic, double posX, double posY, double posZ, float var8) + { + GL11.glPushMatrix(); + float var10 = (float) (posX - 0.5F); + float var11 = (float) (posY - 0.5F); + float var12 = (float) (posZ - 0.5F); + GL11.glTranslatef(var10, var11, var12); + + ItemStack stack = logic.getStackInSlot(0); + if (stack != null) + renderItem(logic, stack); + + stack = logic.getStackInSlot(1); + if (stack != null) + renderItem(logic, stack); + + GL11.glPopMatrix(); + } + + void renderItem (CastingBasinLogic logic, ItemStack stack) + { + FancyEntityItem entityitem = new FancyEntityItem(logic.worldObj, 0.0D, 0.0D, 0.0D, stack); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(1F, 0.675F, 1.0F); + //GL11.glRotatef(90F, 1, 0F, 0F); + GL11.glScalef(1.75F, 1.75F, 1.75F); + if (stack.getItem() instanceof ItemBlock) + { + GL11.glScalef(1.6F, 1.6F, 1.6F); + GL11.glTranslatef(0F, 0.045F, 0.0f); + } + + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + + GL11.glPopMatrix(); + } +} diff --git a/tconstruct/client/block/CastingTableSpecialRenderer.java b/tconstruct/client/block/CastingTableSpecialRenderer.java new file mode 100644 index 00000000..24a83ef0 --- /dev/null +++ b/tconstruct/client/block/CastingTableSpecialRenderer.java @@ -0,0 +1,75 @@ +package tconstruct.client.block; + +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.CastingTableLogic; +import tconstruct.entity.FancyEntityItem; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/* Special renderer, only used for drawing tools */ + +@SideOnly(Side.CLIENT) +public class CastingTableSpecialRenderer extends TileEntitySpecialRenderer +{ + @Override + public void renderTileEntityAt (TileEntity logic, double var2, double var4, double var6, float var8) + { + //System.out.println("Render!!!"); + this.render((CastingTableLogic) logic, var2, var4, var6, var8); + } + + public void render (CastingTableLogic logic, double posX, double posY, double posZ, float var8) + { + GL11.glPushMatrix(); + float var10 = (float) (posX - 0.5F); + float var11 = (float) (posY - 0.5F); + float var12 = (float) (posZ - 0.5F); + GL11.glTranslatef(var10, var11, var12); + this.func_82402_b(logic); + GL11.glPopMatrix(); + } + + private void func_82402_b (CastingTableLogic logic) + { + ItemStack stack = logic.getStackInSlot(0); + + if (stack != null) + renderItem(logic, stack); + + stack = logic.getStackInSlot(1); + + if (stack != null) + renderItem(logic, stack); + } + + void renderItem (CastingTableLogic logic, ItemStack stack) + { + FancyEntityItem entityitem = new FancyEntityItem(logic.worldObj, 0.0D, 0.0D, 0.0D, stack); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(1F, 1.48F, 0.55F); + GL11.glRotatef(90F, 1, 0F, 0F); + GL11.glScalef(2F, 2F, 2F); + if (stack.getItem() instanceof ItemBlock) + { + GL11.glRotatef(90F, -1, 0F, 0F); + GL11.glTranslatef(0F, -0.1F, 0.2275F); + } + + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + + GL11.glPopMatrix(); + } +} diff --git a/tconstruct/client/block/CrystalBlockRender.java b/tconstruct/client/block/CrystalBlockRender.java new file mode 100644 index 00000000..2ca400ca --- /dev/null +++ b/tconstruct/client/block/CrystalBlockRender.java @@ -0,0 +1,126 @@ +package tconstruct.client.block; + +import tconstruct.client.TProxyClient; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class CrystalBlockRender implements ISimpleBlockRenderingHandler +{ + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + renderer.setRenderBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.125F, 0.625F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.3125F, 0.125F, 0.3125F, 0.6875F, 0.25F, 0.6875F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.3125F, 0.75F, 0.3125F, 0.6875F, 0.875F, 0.6875F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.375F, 0.875F, 0.375F, 0.625F, 1.0F, 0.625F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + int metadata = world.getBlockMetadata(x, y, z) % 5; + + if (metadata != 3) + { + renderer.setRenderBounds(0.0625F, 0.0F, 0.0625F, 0.25F, 0.0625F, 0.375F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.5F, 0.0F, 0.75F, 0.625F, 0.125F, 0.8125F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.5F, 0.0F, 0.8125F, 0.5625F, 0.0625F, 0.875F); + renderer.renderStandardBlock(block, x, y, z); + } + if (metadata == 0) + { + renderer.setRenderBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.125F, 0.625F); + renderer.renderStandardBlock(block, x, y, z); + } + else if (metadata == 1) + { + renderer.setRenderBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 0.25, 0.6875F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.375F, 0.25, 0.375F, 0.625F, 0.375, 0.625F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.1875, 0.0F, 0.5F, 0.3125F, 0.1875, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.4325F, 0.0F, 0.1875, 0.625, 0.125, 0.3125F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625F, 0.0F, 0.5F, 0.8125f, 0.125, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + } + else if (metadata == 2) + { + renderer.setRenderBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 0.5F, 0.6875F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.375F, 0.5F, 0.375F, 0.625F, 0.625F, 0.625F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.125F, 0.0F, 0.5F, 0.3125F, 0.25F, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.4325F, 0.0F, 0.125F, 0.6875F, 0.375F, 0.3125F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625F, 0.0F, 0.5F, 0.8125f, 0.375F, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + } + else if (metadata == 3) + { + renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.75F, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.3125F, 0.75F, 0.3125F, 0.6875F, 0.875F, 0.6875F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.375F, 0.875F, 0.375F, 0.625F, 0.9325F, 0.625F); + renderer.renderStandardBlock(block, x, y, z); + + renderer.setRenderBounds(0.125F, 0.0F, 0.5F, 0.375F, 0.375, 0.875F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.4325F, 0.0F, 0.0625, 0.625, 0.5, 0.3125F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625F, 0.0F, 0.5F, 0.875F, 0.625, 0.875F); + renderer.renderStandardBlock(block, x, y, z); + } + else if (metadata == 4) + { + /*renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.75F, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.3125F, 0.75F, 0.3125F, 0.6875F, 0.875F, 0.6875F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.375F, 0.875F, 0.375F, 0.625F, 0.9325F, 0.625F); + renderer.renderStandardBlock(block, x, y, z);*/ + + renderer.setRenderBounds(0.125F, 0.0F, 0.5F, 0.375F, 0.125F, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.4325F, 0.0F, 0.0625, 0.625, 0.25F, 0.3125F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625F, 0.0F, 0.5F, 0.75F, 0.1875F, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + } + } + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return model; + } +} diff --git a/tconstruct/client/block/DryingRackRender.java b/tconstruct/client/block/DryingRackRender.java new file mode 100644 index 00000000..22fa19b3 --- /dev/null +++ b/tconstruct/client/block/DryingRackRender.java @@ -0,0 +1,107 @@ +package tconstruct.client.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import tconstruct.client.TProxyClient; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class DryingRackRender implements ISimpleBlockRenderingHandler +{ + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + renderer.setRenderBounds(0.375F, 0.375F, 0.0F, 0.625F, 0.625F, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 0) + { + renderer.setRenderBounds(0.0F, 0.0, 0.375F, 1.0F, 0.25F, 0.625F); + } + if (metadata == 1) + { + renderer.setRenderBounds(0.375F, 0.0, 0.0f, 0.625F, 0.25F, 1F); + } + + if (metadata == 2) + { + renderer.setRenderBounds(0.0F, 0.75F, 0.75F, 1F, 1.0F, 1F); + } + if (metadata == 3) + { + renderer.setRenderBounds(0.0F, 0.75F, 0F, 1F, 1.0F, 0.25F); + } + if (metadata == 4) + { + renderer.setRenderBounds(0.75F, 0.75F, 0.0f, 1F, 1.0F, 1F); + } + if (metadata == 5) + { + renderer.setRenderBounds(0F, 0.75F, 0.0f, 0.25F, 1.0F, 1F); + } + renderer.renderStandardBlock(block, x, y, z); + } + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return model; + } + + public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta) + { + Tessellator tessellator = Tessellator.instance; + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1F, 0.0F); + renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } +} diff --git a/tconstruct/client/block/DryingRackSpecialRender.java b/tconstruct/client/block/DryingRackSpecialRender.java new file mode 100644 index 00000000..a971da60 --- /dev/null +++ b/tconstruct/client/block/DryingRackSpecialRender.java @@ -0,0 +1,89 @@ +package tconstruct.client.block; + +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.DryingRackLogic; +import tconstruct.entity.FancyEntityItem; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/* Special renderer, only used for drawing tools */ + +@SideOnly(Side.CLIENT) +public class DryingRackSpecialRender extends TileEntitySpecialRenderer +{ + @Override + public void renderTileEntityAt (TileEntity logic, double var2, double var4, double var6, float var8) + { + //System.out.println("Render!!!"); + this.render((DryingRackLogic) logic, var2, var4, var6, var8); + } + + public void render (DryingRackLogic logic, double posX, double posY, double posZ, float var8) + { + GL11.glPushMatrix(); + float var10 = (float) (posX - 0.5F); + float var11 = (float) (posY - 0.5F); + float var12 = (float) (posZ - 0.5F); + GL11.glTranslatef(var10, var11, var12); + this.func_82402_b(logic); + GL11.glPopMatrix(); + } + + private void func_82402_b (DryingRackLogic logic) + { + ItemStack stack = logic.getStackInSlot(0); + + if (stack != null) + renderItem(logic, stack); + } + + void renderItem (DryingRackLogic logic, ItemStack stack) + { + FancyEntityItem entityitem = new FancyEntityItem(logic.worldObj, 0.0D, 0.0D, 0.0D, stack); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glPushMatrix(); + int meta = logic.worldObj.getBlockMetadata(logic.xCoord, logic.yCoord, logic.zCoord); + if (meta <= 1) + GL11.glTranslatef(1F, -0.375F, 0.905F); + else + { + GL11.glTranslatef(1F, 0.375F, 0.905F); + + if (meta / 2 == 2) + { + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.0625F, 0F, 0F); + } + if (meta == 2) + GL11.glTranslatef(0F, 0F, 0.375F); + if (meta == 3) + GL11.glTranslatef(0F, 0F, -0.375F); + if (meta == 4) + GL11.glTranslatef(0F, 0F, 0.2875F); + if (meta == 5) + GL11.glTranslatef(0F, 0F, -0.5F); + } + GL11.glScalef(2F, 2F, 2F); + if (stack.getItem() instanceof ItemBlock) + { + //GL11.glRotatef(90F, -1, 0F, 0F); + GL11.glTranslatef(0F, 0.2125F, 0.0375F); + } + + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + + GL11.glPopMatrix(); + } +} diff --git a/tconstruct/client/block/FrypanRender.java b/tconstruct/client/block/FrypanRender.java new file mode 100644 index 00000000..b5dd49bb --- /dev/null +++ b/tconstruct/client/block/FrypanRender.java @@ -0,0 +1,48 @@ +package tconstruct.client.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class FrypanRender implements ISimpleBlockRenderingHandler +{ + public static int frypanModelID = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + //Inventory should be an item. This is not here! + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.125F, 0.0F, 0.125F, 0.25F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.125F, 0.125F, 0.875F, 0.875F, 0.25F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.875F, 0.125F, 0.0F, 1.0F, 0.25F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.25F, 0.125F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(1F, 0.0F, 0.4375F, 2F, 0.125F, 0.5625F); + renderer.renderStandardBlock(block, x, y, z); + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return frypanModelID; + } +} diff --git a/tconstruct/client/block/GolemCoreRender.java b/tconstruct/client/block/GolemCoreRender.java new file mode 100644 index 00000000..45971521 --- /dev/null +++ b/tconstruct/client/block/GolemCoreRender.java @@ -0,0 +1,60 @@ +package tconstruct.client.block; + +import tconstruct.client.TProxyClient; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class GolemCoreRender implements ISimpleBlockRenderingHandler +{ + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + renderer.setRenderBounds(0.0F, 0F, 0.0F, 1.0F, 0.1875F, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0F, 0.8125F, 0.0F, 1.0F, 1.0F, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0F, 0.1875F, 0.0F, 0.1875F, 0.8125F, 0.1875F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.8175, 0.1875F, 0.0F, 1f, 0.8125F, 0.1875F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0F, 0.1875F, 0.8175, 0.1875F, 0.8125F, 1f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.8175F, 0.1875F, 0.8175, 1f, 0.8125F, 1f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) + { + renderer.setRenderBounds(0.0F, 0F, 0.0F, 1.0F, 0.1875F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.8125F, 0.0F, 1.0F, 1.0F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.1875F, 0.0F, 0.1875F, 0.8125F, 0.1875F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.8175, 0.1875F, 0.0F, 1f, 0.8125F, 0.1875F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.1875F, 0.8175, 0.1875F, 0.8125F, 1f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.8175F, 0.1875F, 0.8175, 1f, 0.8125F, 1f); + renderer.renderStandardBlock(block, x, y, z); + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return model; + } +} diff --git a/tconstruct/client/block/GolemCoreSpecialRender.java b/tconstruct/client/block/GolemCoreSpecialRender.java new file mode 100644 index 00000000..e5c1b884 --- /dev/null +++ b/tconstruct/client/block/GolemCoreSpecialRender.java @@ -0,0 +1,65 @@ +package tconstruct.client.block; + +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.GolemCoreLogic; +import tconstruct.entity.FancyEntityItem; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/* Special renderer, only used for drawing tools */ + +@SideOnly(Side.CLIENT) +public class GolemCoreSpecialRender extends TileEntitySpecialRenderer +{ + @Override + public void renderTileEntityAt (TileEntity logic, double var2, double var4, double var6, float var8) + { + this.render((GolemCoreLogic) logic, var2, var4, var6, var8); + } + + public void render (GolemCoreLogic logic, double posX, double posY, double posZ, float var8) + { + GL11.glPushMatrix(); + float var10 = (float) (posX - 0.5F); + float var11 = (float) (posY - 0.5F); + float var12 = (float) (posZ - 0.5F); + GL11.glTranslatef(var10, var11, var12); + + ItemStack stack = logic.getStackInSlot(0); + if (stack != null) + renderItem(logic, stack); + + GL11.glPopMatrix(); + } + + void renderItem (GolemCoreLogic logic, ItemStack stack) + { + FancyEntityItem entityitem = new FancyEntityItem(logic.worldObj, 0.0D, 0.0D, 0.0D, stack); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(1F, 0.675F, 1.0F); + //GL11.glRotatef(90F, 1, 0F, 0F); + GL11.glScalef(1.4F, 1.4F, 1.4F); + if (stack.getItem() instanceof ItemBlock) + { + GL11.glScalef(1.6F, 1.6F, 1.6F); + GL11.glTranslatef(0F, 0.045F, 0.0f); + } + + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + + GL11.glPopMatrix(); + } +} diff --git a/tconstruct/client/block/MachineRender.java b/tconstruct/client/block/MachineRender.java new file mode 100644 index 00000000..171c41d2 --- /dev/null +++ b/tconstruct/client/block/MachineRender.java @@ -0,0 +1,102 @@ +package tconstruct.client.block; + +import tconstruct.client.TProxyClient; +import tconstruct.library.util.IFacingLogic; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class MachineRender implements ISimpleBlockRenderingHandler +{ + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 0) + { + renderer.renderStandardBlock(block, x, y, z); + } + else + { + renderRotatedBlock(block, x, y, z, world, renderer); + } + } + return true; + } + + public boolean renderRotatedBlock (Block block, int x, int y, int z, IBlockAccess world, RenderBlocks renderer) + { + IFacingLogic logic = (IFacingLogic) world.getBlockTileEntity(x, y, z); + byte direction = logic.getRenderDirection(); + + if (direction == 0) + { + renderer.uvRotateEast = 3; + renderer.uvRotateWest = 3; + renderer.uvRotateNorth = 3; + renderer.uvRotateSouth = 3; + } + if (direction == 2) + { + renderer.uvRotateNorth = 2; + renderer.uvRotateSouth = 1; + } + if (direction == 3) + { + renderer.uvRotateNorth = 1; + renderer.uvRotateSouth = 2; + renderer.uvRotateTop = 3; + renderer.uvRotateBottom = 3; + } + if (direction == 4) + { + renderer.uvRotateEast = 1; + renderer.uvRotateWest = 2; + renderer.uvRotateTop = 2; + renderer.uvRotateBottom = 1; + } + if (direction == 5) + { + renderer.uvRotateEast = 2; + renderer.uvRotateWest = 1; + renderer.uvRotateTop = 1; + renderer.uvRotateBottom = 2; + } + + boolean flag = renderer.renderStandardBlock(block, x, y, z); + renderer.uvRotateSouth = 0; + renderer.uvRotateEast = 0; + renderer.uvRotateWest = 0; + renderer.uvRotateNorth = 0; + renderer.uvRotateTop = 0; + renderer.uvRotateBottom = 0; + return flag; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return model; + } +} diff --git a/tconstruct/client/block/OreberryRender.java b/tconstruct/client/block/OreberryRender.java new file mode 100644 index 00000000..520185fb --- /dev/null +++ b/tconstruct/client/block/OreberryRender.java @@ -0,0 +1,61 @@ +package tconstruct.client.block; + +import tconstruct.client.TProxyClient; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class OreberryRender implements ISimpleBlockRenderingHandler +{ + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) + { + + if (modelId == model) + { + int md = world.getBlockMetadata(x, y, z); + if (md < 4) + { + renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + } + else if (md < 8) + { + renderer.setRenderBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.75F, 0.875F); + renderer.renderStandardBlock(block, x, y, z); + } + else + { + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + } + } + return true; + } + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + renderer.setRenderBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.75F, 0.875F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return model; + } +} diff --git a/tconstruct/client/block/PaneConnectedRender.java b/tconstruct/client/block/PaneConnectedRender.java new file mode 100644 index 00000000..6ea5ebb3 --- /dev/null +++ b/tconstruct/client/block/PaneConnectedRender.java @@ -0,0 +1,481 @@ +package tconstruct.client.block; + +import static net.minecraftforge.common.ForgeDirection.EAST; +import static net.minecraftforge.common.ForgeDirection.NORTH; +import static net.minecraftforge.common.ForgeDirection.SOUTH; +import static net.minecraftforge.common.ForgeDirection.WEST; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import tconstruct.blocks.GlassPaneConnected; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class PaneConnectedRender implements ISimpleBlockRenderingHandler +{ + + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) + { + GlassPaneConnected paneConnected = (GlassPaneConnected) block; + int l = world.getHeight(); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(paneConnected.getMixedBrightnessForBlock(world, x, y, z)); + float f = 1.0F; + int i1 = paneConnected.colorMultiplier(world, x, y, z); + float f1 = (float) (i1 >> 16 & 255) / 255.0F; + float f2 = (float) (i1 >> 8 & 255) / 255.0F; + float f3 = (float) (i1 & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; + float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; + float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; + f1 = f4; + f2 = f5; + f3 = f6; + } + + tessellator.setColorOpaque_F(f * f1, f * f2, f * f3); + Icon icon; + Icon icon1; + + if (renderer.hasOverrideBlockTexture()) + { + icon = renderer.overrideBlockTexture; + icon1 = renderer.overrideBlockTexture; + } + else + { + int j1 = world.getBlockMetadata(x, y, z); + icon = renderer.getBlockIconFromSideAndMetadata(paneConnected, 0, j1); + icon1 = paneConnected.getSideTextureIndex(); + } + + double d0 = (double) icon.getMinU(); + double d1 = (double) icon.getInterpolatedU(8.0D); + double d2 = (double) icon.getMaxU(); + double d3 = (double) icon.getMinV(); + double d4 = (double) icon.getMaxV(); + double d5 = (double) icon1.getInterpolatedU(7.0D); + double d6 = (double) icon1.getInterpolatedU(9.0D); + double d7 = (double) icon1.getMinV(); + double d8 = (double) icon1.getInterpolatedV(8.0D); + double d9 = (double) icon1.getMaxV(); + double d10 = (double) x; + double d11 = (double) x + 0.5D; + double d12 = (double) (x + 1); + double d13 = (double) z; + double d14 = (double) z + 0.5D; + double d15 = (double) (z + 1); + double d16 = (double) x + 0.5D - 0.0625D; + double d17 = (double) x + 0.5D + 0.0625D; + double d18 = (double) z + 0.5D - 0.0625D; + double d19 = (double) z + 0.5D + 0.0625D; + boolean flag = paneConnected.canPaneConnectTo(world, x, y, z, NORTH); + boolean flag1 = paneConnected.canPaneConnectTo(world, x, y, z, SOUTH); + boolean flag2 = paneConnected.canPaneConnectTo(world, x, y, z, WEST); + boolean flag3 = paneConnected.canPaneConnectTo(world, x, y, z, EAST); + boolean flag4 = paneConnected.shouldSideBeRendered(world, x, y + 1, z, 1); + boolean flag5 = paneConnected.shouldSideBeRendered(world, x, y - 1, z, 0); + double d20 = 0.01D; + double d21 = 0.005D; + + if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) + { + if (flag2 && !flag3) + { + tessellator.addVertexWithUV(d10, (double) (y + 1), d14, d0, d3); + tessellator.addVertexWithUV(d10, (double) (y + 0), d14, d0, d4); + tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d1, d4); + tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d1, d3); + tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d0, d3); + tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d0, d4); + tessellator.addVertexWithUV(d10, (double) (y + 0), d14, d1, d4); + tessellator.addVertexWithUV(d10, (double) (y + 1), d14, d1, d3); + + if (!flag1 && !flag) + { + tessellator.addVertexWithUV(d11, (double) (y + 1), d19, d5, d7); + tessellator.addVertexWithUV(d11, (double) (y + 0), d19, d5, d9); + tessellator.addVertexWithUV(d11, (double) (y + 0), d18, d6, d9); + tessellator.addVertexWithUV(d11, (double) (y + 1), d18, d6, d7); + tessellator.addVertexWithUV(d11, (double) (y + 1), d18, d5, d7); + tessellator.addVertexWithUV(d11, (double) (y + 0), d18, d5, d9); + tessellator.addVertexWithUV(d11, (double) (y + 0), d19, d6, d9); + tessellator.addVertexWithUV(d11, (double) (y + 1), d19, d6, d7); + } + + if (flag4 || y < l - 1 && world.isAirBlock(x - 1, y + 1, z)) + { + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d8); + } + + if (flag5 || y > 1 && world.isAirBlock(x - 1, y - 1, z)) + { + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d8); + } + } + else if (!flag2 && flag3) + { + tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d1, d3); + tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d1, d4); + tessellator.addVertexWithUV(d12, (double) (y + 0), d14, d2, d4); + tessellator.addVertexWithUV(d12, (double) (y + 1), d14, d2, d3); + tessellator.addVertexWithUV(d12, (double) (y + 1), d14, d1, d3); + tessellator.addVertexWithUV(d12, (double) (y + 0), d14, d1, d4); + tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d2, d4); + tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d2, d3); + + if (!flag1 && !flag) + { + tessellator.addVertexWithUV(d11, (double) (y + 1), d18, d5, d7); + tessellator.addVertexWithUV(d11, (double) (y + 0), d18, d5, d9); + tessellator.addVertexWithUV(d11, (double) (y + 0), d19, d6, d9); + tessellator.addVertexWithUV(d11, (double) (y + 1), d19, d6, d7); + tessellator.addVertexWithUV(d11, (double) (y + 1), d19, d5, d7); + tessellator.addVertexWithUV(d11, (double) (y + 0), d19, d5, d9); + tessellator.addVertexWithUV(d11, (double) (y + 0), d18, d6, d9); + tessellator.addVertexWithUV(d11, (double) (y + 1), d18, d6, d7); + } + + if (flag4 || y < l - 1 && world.isAirBlock(x + 1, y + 1, z)) + { + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d7); + } + + if (flag5 || y > 1 && world.isAirBlock(x + 1, y - 1, z)) + { + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d7); + } + } + } + else + { + tessellator.addVertexWithUV(d10, (double) (y + 1), d14, d0, d3); + tessellator.addVertexWithUV(d10, (double) (y + 0), d14, d0, d4); + tessellator.addVertexWithUV(d12, (double) (y + 0), d14, d2, d4); + tessellator.addVertexWithUV(d12, (double) (y + 1), d14, d2, d3); + tessellator.addVertexWithUV(d12, (double) (y + 1), d14, d0, d3); + tessellator.addVertexWithUV(d12, (double) (y + 0), d14, d0, d4); + tessellator.addVertexWithUV(d10, (double) (y + 0), d14, d2, d4); + tessellator.addVertexWithUV(d10, (double) (y + 1), d14, d2, d3); + + if (flag4) + { + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d9); + } + else + { + if (y < l - 1 && world.isAirBlock(x - 1, y + 1, z)) + { + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d8); + } + + if (y < l - 1 && world.isAirBlock(x + 1, y + 1, z)) + { + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d7); + } + } + + if (flag5) + { + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d9); + } + else + { + if (y > 1 && world.isAirBlock(x - 1, y - 1, z)) + { + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d9); + tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d9); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d8); + } + + if (y > 1 && world.isAirBlock(x + 1, y - 1, z)) + { + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d7); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d8); + tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d7); + } + } + } + + if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1)) + { + if (flag && !flag1) + { + tessellator.addVertexWithUV(d11, (double) (y + 1), d13, d0, d3); + tessellator.addVertexWithUV(d11, (double) (y + 0), d13, d0, d4); + tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d1, d4); + tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d1, d3); + tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d0, d3); + tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d0, d4); + tessellator.addVertexWithUV(d11, (double) (y + 0), d13, d1, d4); + tessellator.addVertexWithUV(d11, (double) (y + 1), d13, d1, d3); + + if (!flag3 && !flag2) + { + tessellator.addVertexWithUV(d16, (double) (y + 1), d14, d5, d7); + tessellator.addVertexWithUV(d16, (double) (y + 0), d14, d5, d9); + tessellator.addVertexWithUV(d17, (double) (y + 0), d14, d6, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1), d14, d6, d7); + tessellator.addVertexWithUV(d17, (double) (y + 1), d14, d5, d7); + tessellator.addVertexWithUV(d17, (double) (y + 0), d14, d5, d9); + tessellator.addVertexWithUV(d16, (double) (y + 0), d14, d6, d9); + tessellator.addVertexWithUV(d16, (double) (y + 1), d14, d6, d7); + } + + if (flag4 || y < l - 1 && world.isAirBlock(x, y + 1, z - 1)) + { + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d6, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d6, d8); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d6, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d6, d8); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d5, d8); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d5, d7); + } + + if (flag5 || y > 1 && world.isAirBlock(x, y - 1, z - 1)) + { + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d6, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d6, d8); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d6, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d6, d8); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d5, d8); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d5, d7); + } + } + else if (!flag && flag1) + { + tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d1, d3); + tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d1, d4); + tessellator.addVertexWithUV(d11, (double) (y + 0), d15, d2, d4); + tessellator.addVertexWithUV(d11, (double) (y + 1), d15, d2, d3); + tessellator.addVertexWithUV(d11, (double) (y + 1), d15, d1, d3); + tessellator.addVertexWithUV(d11, (double) (y + 0), d15, d1, d4); + tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d2, d4); + tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d2, d3); + + if (!flag3 && !flag2) + { + tessellator.addVertexWithUV(d17, (double) (y + 1), d14, d5, d7); + tessellator.addVertexWithUV(d17, (double) (y + 0), d14, d5, d9); + tessellator.addVertexWithUV(d16, (double) (y + 0), d14, d6, d9); + tessellator.addVertexWithUV(d16, (double) (y + 1), d14, d6, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1), d14, d5, d7); + tessellator.addVertexWithUV(d16, (double) (y + 0), d14, d5, d9); + tessellator.addVertexWithUV(d17, (double) (y + 0), d14, d6, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1), d14, d6, d7); + } + + if (flag4 || y < l - 1 && world.isAirBlock(x, y + 1, z + 1)) + { + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d6, d8); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d8); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d5, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d6, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d8); + } + + if (flag5 || y > 1 && world.isAirBlock(x, y - 1, z + 1)) + { + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d6, d8); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d8); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d5, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d6, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d8); + } + } + } + else + { + tessellator.addVertexWithUV(d11, (double) (y + 1), d15, d0, d3); + tessellator.addVertexWithUV(d11, (double) (y + 0), d15, d0, d4); + tessellator.addVertexWithUV(d11, (double) (y + 0), d13, d2, d4); + tessellator.addVertexWithUV(d11, (double) (y + 1), d13, d2, d3); + tessellator.addVertexWithUV(d11, (double) (y + 1), d13, d0, d3); + tessellator.addVertexWithUV(d11, (double) (y + 0), d13, d0, d4); + tessellator.addVertexWithUV(d11, (double) (y + 0), d15, d2, d4); + tessellator.addVertexWithUV(d11, (double) (y + 1), d15, d2, d3); + + if (flag4) + { + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d6, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d6, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d5, d9); + } + else + { + if (y < l - 1 && world.isAirBlock(x, y + 1, z - 1)) + { + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d6, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d6, d8); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d6, d7); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d6, d8); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d5, d8); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d5, d7); + } + + if (y < l - 1 && world.isAirBlock(x, y + 1, z + 1)) + { + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d6, d8); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d8); + tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d5, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d6, d9); + tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d8); + } + } + + if (flag5) + { + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d6, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d6, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d5, d9); + } + else + { + if (y > 1 && world.isAirBlock(x, y - 1, z - 1)) + { + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d6, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d6, d8); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d6, d7); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d6, d8); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d5, d8); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d5, d7); + } + + if (y > 1 && world.isAirBlock(x, y - 1, z + 1)) + { + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d6, d8); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d8); + tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d5, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d6, d9); + tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d8); + } + } + } + + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return false; + } + + @Override + public int getRenderId () + { + return model; + } + +} diff --git a/tconstruct/client/block/PaneRender.java b/tconstruct/client/block/PaneRender.java new file mode 100644 index 00000000..d84310b2 --- /dev/null +++ b/tconstruct/client/block/PaneRender.java @@ -0,0 +1,394 @@ +package tconstruct.client.block; + +import tconstruct.blocks.PaneBase; +import tconstruct.client.TProxyClient; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class PaneRender implements ISimpleBlockRenderingHandler +{ + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + renderer.setRenderBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + return renderPaneInWorld(renderer, world, x, y, z, (PaneBase) block); + } + + else + { + return false; + } + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return model; + } + + public static boolean renderPaneInWorld (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, PaneBase pane) + { + int l = iblockaccess.getHeight(); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(pane.getMixedBrightnessForBlock(iblockaccess, x, y, z)); + float f = 1.0F; + int i1 = pane.colorMultiplier(iblockaccess, x, y, z); + float f1 = (float) (i1 >> 16 & 0xff) / 255F; + float f2 = (float) (i1 >> 8 & 0xff) / 255F; + float f3 = (float) (i1 & 0xff) / 255F; + if (EntityRenderer.anaglyphEnable) + { + float f4 = (f1 * 30F + f2 * 59F + f3 * 11F) / 100F; + float f5 = (f1 * 30F + f2 * 70F) / 100F; + float f6 = (f1 * 30F + f3 * 70F) / 100F; + f1 = f4; + f2 = f5; + f3 = f6; + } + tessellator.setColorOpaque_F(f * f1, f * f2, f * f3); + boolean flag = false; + boolean flag1 = false; + Icon icon; + Icon icon1; + int meta = iblockaccess.getBlockMetadata(x, y, z); + icon = renderblocks.getBlockIconFromSideAndMetadata(pane, 0, meta); + icon1 = pane.getSideTextureIndex(meta); + + meta = icon.getOriginX(); + int k1 = icon.getOriginY(); + double d = (double) icon.getMinU(); + double d1 = (double) icon.getInterpolatedU(8.0D); + double d2 = (double) icon.getMaxU(); + double d3 = (double) icon.getMinV(); + double d4 = (double) icon.getMaxV(); + int l1 = icon1.getOriginX(); + int i2 = icon1.getOriginY(); + double d5 = (double) icon1.getInterpolatedU(7.0D); + double d6 = (double) icon1.getInterpolatedU(9.0D); + double d7 = (double) icon1.getMinV(); + double d8 = (double) icon1.getInterpolatedV(8.0D); + double d9 = (double) icon1.getMaxV(); + + /*int blockTextureIndex; + int blockSideIndex; + + int j1 = iblockaccess.getBlockMetadata(x, y, z); + blockTextureIndex = pane.getBlockTextureFromSideAndMetadata(0, j1); + blockSideIndex = pane.getSideTextureIndex(j1); + + int k1 = (blockTextureIndex & 0xf) << 4; + int j2 = blockTextureIndex & 0xf0; + double d = (float) k1 / 256F; + double d1 = ((float) k1 + 7.99F) / 256F; + double d2 = ((float) k1 + 15.99F) / 256F; + double d3 = (float) j2 / 256F; + double d4 = ((float) j2 + 15.99F) / 256F; + int k2 = (blockSideIndex & 0xf) << 4; + int l2 = blockSideIndex & 0xf0; + double d5 = (float) (k2 + 7) / 256F; + double d6 = ((float) k2 + 8.99F) / 256F; + double d7 = (float) l2 / 256F; + double d8 = (float) (l2 + 8) / 256F; + double d9 = ((float) l2 + 15.99F) / 256F;*/ + + double xBot = x; + double xMid = (double) x + 0.5D; + double xTop = x + 1; + double zBot = z; + double zMid = (double) z + 0.5D; + double zTop = z + 1; + double xMidDown = ((double) x + 0.5D) - 0.0625D; + double xMidUp = (double) x + 0.5D + 0.0625D; + double zMidDown = ((double) z + 0.5D) - 0.0625D; + double zMidUp = (double) z + 0.5D + 0.0625D; + boolean west = pane.canConnectTo(iblockaccess.getBlockId(x, y, z - 1)); + boolean east = pane.canConnectTo(iblockaccess.getBlockId(x, y, z + 1)); + boolean south = pane.canConnectTo(iblockaccess.getBlockId(x - 1, y, z)); + boolean north = pane.canConnectTo(iblockaccess.getBlockId(x + 1, y, z)); + boolean renderAbove = pane.shouldSideBeRendered(iblockaccess, x, y + 1, z, 1); + boolean renderBelow = pane.shouldSideBeRendered(iblockaccess, x, y - 1, z, 0); + if ((!south || !north) && (south || north || west || east)) + { + if (south && !north) + { + tessellator.addVertexWithUV(xBot, y + 1, zMidDown, d, d3); + tessellator.addVertexWithUV(xBot, y + 0, zMidDown, d, d4); + tessellator.addVertexWithUV(xMid, y + 0, zMidDown, d1, d4); + tessellator.addVertexWithUV(xMid, y + 1, zMidDown, d1, d3); + tessellator.addVertexWithUV(xMid, y + 1, zMidUp, d, d3); + tessellator.addVertexWithUV(xMid, y + 0, zMidUp, d, d4); + tessellator.addVertexWithUV(xBot, y + 0, zMidUp, d1, d4); + tessellator.addVertexWithUV(xBot, y + 1, zMidUp, d1, d3); + if (!east && !west) + { + tessellator.addVertexWithUV(xMid, y + 1, zMidUp, d5, d7); + tessellator.addVertexWithUV(xMid, y + 0, zMidUp, d5, d9); + tessellator.addVertexWithUV(xMid, y + 0, zMidDown, d6, d9); + tessellator.addVertexWithUV(xMid, y + 1, zMidDown, d6, d7); + } + if (renderAbove || y < l - 1 && iblockaccess.isAirBlock(x - 1, y + 1, z)) + { + tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidUp, d6, d8); + tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidUp, d6, d9); + tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidDown, d5, d9); + tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidDown, d5, d8); + } + if (renderBelow || y > 1 && iblockaccess.isAirBlock(x - 1, y - 1, z)) + { + tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidUp, d6, d8); + tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidUp, d6, d9); + tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidDown, d5, d9); + tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidDown, d5, d8); + } + } + else if (!south && north) + { + tessellator.addVertexWithUV(xMid, y + 1, zMidDown, d1, d3); + tessellator.addVertexWithUV(xMid, y + 0, zMidDown, d1, d4); + tessellator.addVertexWithUV(xTop, y + 0, zMidDown, d2, d4); + tessellator.addVertexWithUV(xTop, y + 1, zMidDown, d2, d3); + tessellator.addVertexWithUV(xTop, y + 1, zMidUp, d1, d3); + tessellator.addVertexWithUV(xTop, y + 0, zMidUp, d1, d4); + tessellator.addVertexWithUV(xMid, y + 0, zMidUp, d2, d4); + tessellator.addVertexWithUV(xMid, y + 1, zMidUp, d2, d3); + if (!east && !west) + { + tessellator.addVertexWithUV(xMid, y + 1, zMidDown, d5, d7); + tessellator.addVertexWithUV(xMid, y + 0, zMidDown, d5, d9); + tessellator.addVertexWithUV(xMid, y + 0, zMidUp, d6, d9); + tessellator.addVertexWithUV(xMid, y + 1, zMidUp, d6, d7); + } + if (renderAbove || y < l - 1 && iblockaccess.isAirBlock(x + 1, y + 1, z)) + { + tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidUp, d6, d7); + tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidUp, d6, d8); + tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidDown, d5, d8); + tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidDown, d5, d7); + } + if (renderBelow || y > 1 && iblockaccess.isAirBlock(x + 1, y - 1, z)) + { + tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidUp, d6, d7); + tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidUp, d6, d8); + tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidDown, d5, d8); + tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidDown, d5, d7); + } + } + } + else + { + tessellator.addVertexWithUV(xBot, y + 1, zMidDown, d, d3); + tessellator.addVertexWithUV(xBot, y + 0, zMidDown, d, d4); + tessellator.addVertexWithUV(xTop, y + 0, zMidDown, d2, d4); + tessellator.addVertexWithUV(xTop, y + 1, zMidDown, d2, d3); + tessellator.addVertexWithUV(xTop, y + 1, zMidUp, d, d3); + tessellator.addVertexWithUV(xTop, y + 0, zMidUp, d, d4); + tessellator.addVertexWithUV(xBot, y + 0, zMidUp, d2, d4); + tessellator.addVertexWithUV(xBot, y + 1, zMidUp, d2, d3); + if (renderAbove) + { + tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidUp, d6, d9); + tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidUp, d6, d7); + tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidDown, d5, d7); + tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidDown, d5, d9); + } + else + { + if (y < l - 1 && iblockaccess.isAirBlock(x - 1, y + 1, z)) + { + tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidUp, d6, d8); + tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidUp, d6, d9); + tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidDown, d5, d9); + tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidDown, d5, d8); + } + if (y < l - 1 && iblockaccess.isAirBlock(x + 1, y + 1, z)) + { + tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidUp, d6, d7); + tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidUp, d6, d8); + tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidDown, d5, d8); + tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidDown, d5, d7); + } + } + if (renderBelow) + { + tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidUp, d6, d9); + tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidUp, d6, d7); + tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidDown, d5, d7); + tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidDown, d5, d9); + } + else + { + if (y > 1 && iblockaccess.isAirBlock(x - 1, y - 1, z)) + { + tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidUp, d6, d8); + tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidUp, d6, d9); + tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidDown, d5, d9); + tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidDown, d5, d8); + } + if (y > 1 && iblockaccess.isAirBlock(x + 1, y - 1, z)) + { + tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidUp, d6, d7); + tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidUp, d6, d8); + tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidDown, d5, d8); + tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidDown, d5, d7); + } + } + } + if ((!west || !east) && (south || north || west || east)) + { + if (west && !east) + { + tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d, d3); + tessellator.addVertexWithUV(xMidDown, y + 0, zBot, d, d4); + tessellator.addVertexWithUV(xMidDown, y + 0, zMid, d1, d4); + tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d1, d3); + tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d, d3); + tessellator.addVertexWithUV(xMidUp, y + 0, zMid, d, d4); + tessellator.addVertexWithUV(xMidUp, y + 0, zBot, d1, d4); + tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d1, d3); + if (!north && !south) + { + tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d5, d7); + tessellator.addVertexWithUV(xMidDown, y + 0, zMid, d5, d9); + tessellator.addVertexWithUV(xMidUp, y + 0, zMid, d6, d9); + tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d6, d7); + } + if (renderAbove || y < l - 1 && iblockaccess.isAirBlock(x, y + 1, z - 1)) + { + tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d6, d7); + tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d6, d8); + tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d5, d8); + tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d5, d7); + } + if (renderBelow || y > 1 && iblockaccess.isAirBlock(x, y - 1, z - 1)) + { + tessellator.addVertexWithUV(xMidDown, y, zBot, d6, d7); + tessellator.addVertexWithUV(xMidDown, y, zMid, d6, d8); + tessellator.addVertexWithUV(xMidUp, y, zMid, d5, d8); + tessellator.addVertexWithUV(xMidUp, y, zBot, d5, d7); + } + } + else if (!west && east) + { + tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d1, d3); + tessellator.addVertexWithUV(xMidDown, y + 0, zMid, d1, d4); + tessellator.addVertexWithUV(xMidDown, y + 0, zTop, d2, d4); + tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d2, d3); + tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d1, d3); + tessellator.addVertexWithUV(xMidUp, y + 0, zTop, d1, d4); + tessellator.addVertexWithUV(xMidUp, y + 0, zMid, d2, d4); + tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d2, d3); + if (!north && !south) + { + tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d5, d7); + tessellator.addVertexWithUV(xMidUp, y + 0, zMid, d5, d9); + tessellator.addVertexWithUV(xMidDown, y + 0, zMid, d6, d9); + tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d6, d7); + } + if (renderAbove || y < l - 1 && iblockaccess.isAirBlock(x, y + 1, z + 1)) + { + tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d5, d8); + tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d5, d9); + tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d6, d9); + tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d6, d8); + } + if (renderBelow || y > 1 && iblockaccess.isAirBlock(x, y - 1, z + 1)) + { + tessellator.addVertexWithUV(xMidDown, y, zMid, d5, d8); + tessellator.addVertexWithUV(xMidDown, y, zTop, d5, d9); + tessellator.addVertexWithUV(xMidUp, y, zTop, d6, d9); + tessellator.addVertexWithUV(xMidUp, y, zMid, d6, d8); + } + } + } + else + { + tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d, d3); + tessellator.addVertexWithUV(xMidDown, y + 0, zTop, d, d4); + tessellator.addVertexWithUV(xMidDown, y + 0, zBot, d2, d4); + tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d2, d3); + tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d, d3); + tessellator.addVertexWithUV(xMidUp, y + 0, zBot, d, d4); + tessellator.addVertexWithUV(xMidUp, y + 0, zTop, d2, d4); + tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d2, d3); + if (renderAbove) + { + tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d6, d9); + tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d6, d7); + tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d5, d7); + tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d5, d9); + } + else + { + if (y < l - 1 && iblockaccess.isAirBlock(x, y + 1, z - 1)) + { + tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d6, d7); + tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d6, d8); + tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d5, d8); + tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d5, d7); + } + if (y < l - 1 && iblockaccess.isAirBlock(x, y + 1, z + 1)) + { + tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d5, d8); + tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d5, d9); + tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d6, d9); + tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d6, d8); + } + } + if (renderBelow) + { + tessellator.addVertexWithUV(xMidUp, y, zTop, d6, d9); + tessellator.addVertexWithUV(xMidUp, y, zBot, d6, d7); + tessellator.addVertexWithUV(xMidDown, y, zBot, d5, d7); + tessellator.addVertexWithUV(xMidDown, y, zTop, d5, d9); + tessellator.addVertexWithUV(xMidUp, y, zBot, d6, d9); + tessellator.addVertexWithUV(xMidUp, y, zTop, d6, d7); + tessellator.addVertexWithUV(xMidDown, y, zTop, d5, d7); + tessellator.addVertexWithUV(xMidDown, y, zBot, d5, d9); + } + else + { + if (y > 1 && iblockaccess.isAirBlock(x, y - 1, z - 1)) + { + tessellator.addVertexWithUV(xMidDown, y, zBot, d6, d7); + tessellator.addVertexWithUV(xMidDown, y, zMid, d6, d8); + tessellator.addVertexWithUV(xMidUp, y, zMid, d5, d8); + tessellator.addVertexWithUV(xMidUp, y, zBot, d5, d7); + } + if (y > 1 && iblockaccess.isAirBlock(x, y - 1, z + 1)) + { + tessellator.addVertexWithUV(xMidDown, y, zMid, d5, d8); + tessellator.addVertexWithUV(xMidDown, y, zTop, d5, d9); + tessellator.addVertexWithUV(xMidUp, y, zTop, d6, d9); + tessellator.addVertexWithUV(xMidUp, y, zMid, d6, d8); + } + } + } + return true; + } + +} diff --git a/tconstruct/client/block/SearedRender.java b/tconstruct/client/block/SearedRender.java new file mode 100644 index 00000000..94b7befd --- /dev/null +++ b/tconstruct/client/block/SearedRender.java @@ -0,0 +1,409 @@ +package tconstruct.client.block; + +import tconstruct.blocks.logic.CastingBasinLogic; +import tconstruct.blocks.logic.CastingTableLogic; +import tconstruct.blocks.logic.FaucetLogic; +import tconstruct.client.TProxyClient; +import tconstruct.common.TContent; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.item.Item; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fluids.Fluid; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class SearedRender implements ISimpleBlockRenderingHandler +{ + public static int searedModel = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == searedModel) + { + if (metadata == 0) + { + //Top + renderer.setRenderBounds(0.0F, 0.625F, 0.0F, 1.0F, 0.9375F, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + + //Lip + renderer.setRenderBounds(0.0F, 0.9375, 0.0F, 0.0625, 1.0, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0625, 0.9375, 0.9375, 0.9375, 1.0, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.9375, 0.9375, 0.0F, 1.0F, 1.0, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0625, 0.9375, 0.0F, 0.9375, 1.0, 0.0625); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + + //Legs + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.3125F, 0.625F, 0.3125F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.6875, 0.0F, 0.0F, 1.0F, 0.625F, 0.25F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0F, 0.0F, 0.6875, 0.3125F, 0.625F, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.6875, 0.0F, 0.6875, 1.0F, 0.625F, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + else if (metadata == 1) + { + renderer.setRenderBounds(0.25, 0.25, 0.625, 0.75, 0.375, 1); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.25, 0.25, 0.625, 0.375, 0.625, 1); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.625, 0.25, 0.625, 0.75, 0.625, 1); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.375, 0.375, 0.625, 0.625, 0.625, 1); + } + else if (metadata == 2) + { + renderer.setRenderBounds(0.125F, 0.125f, 0.125F, 0.875F, 0.25F, 0.875F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + + //Details + renderer.setRenderBounds(0.001f, 0.1245f, 0.001f, 0.1245f, 0.999f, 0.4375f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.001f, 0.1245f, 0.5625f, 0.1245f, 0.999f, 0.999f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.001f, 0.8755f, 0.4375f, 0.1245f, 0.999f, 0.5625f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.001f, 0.1245f, 0.4375f, 0.1245f, 0.25F, 0.5625f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + + renderer.setRenderBounds(0.8755f, 0.1245f, 0f, 0.999f, 0.999f, 0.4375f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.8755f, 0.1245f, 0.5625f, 0.999f, 0.999f, 0.999f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.8755f, 0.8755f, 0.4375f, 0.999f, 0.999f, 0.5625f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.8755f, 0.1245f, 0.4375f, 0.999f, 0.25F, 0.5625f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + + renderer.setRenderBounds(0.1245f, 0.1245f, 0.8755f, 0.4375f, 0.999f, 0.999f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.5625f, 0.1245f, 0.8755f, 0.8755f, 0.999f, 0.999f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.4375f, 0.8755f, 0.8755f, 0.5625f, 0.999f, 0.999f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.4375f, 0.1245f, 0.8755f, 0.5625f, 0.2495F, 0.999f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + + renderer.setRenderBounds(0.1245f, 0.1245f, 0.001f, 0.4375f, 0.999f, 0.1245f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.5625f, 0.1245f, 0.001f, 0.8755f, 0.999f, 0.1245f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.4375f, 0.8755f, 0.001f, 0.5625f, 0.999f, 0.1245f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.4375f, 0.1245f, 0.001f, 0.5625f, 0.25F, 0.1245f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + + //Legs + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.3125F, 0.125, 0.3125F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.6875F, 0.0F, 0.0F, 1.0F, 0.125, 0.3125F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0F, 0.0F, 0.6875F, 0.3125F, 0.125, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.6875F, 0.0F, 0.6875F, 1.0F, 0.125, 1.0F); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + + //Outside + renderer.setRenderBounds(0.0f, 0.125, 0f, 0.125, 1.0F, 1); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.875f, 0.125, 0f, 1, 1.0F, 1); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.125f, 0.125, 0f, 0.875f, 1.0F, 0.125f); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.125f, 0.125, 0.875f, 0.875f, 1.0F, 1); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + else + { + renderer.setRenderBounds(0, 0, 0, 1, 1, 1); + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + } + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == searedModel) + { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 0) + { + //Top + renderer.setRenderBounds(0.0F, 0.625F, 0.0F, 1.0F, 0.9375F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + + //Lip + renderer.setRenderBounds(0.0F, 0.9375, 0.0F, 0.0625, 1.0, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0625, 0.9375, 0.9375, 0.9375, 1.0, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.9375, 0.9375, 0.0F, 1.0F, 1.0, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0625, 0.9375, 0.0F, 0.9375, 1.0, 0.0625); + renderer.renderStandardBlock(block, x, y, z); + + //Legs + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.3125F, 0.625F, 0.3125F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.6875, 0.0F, 0.0F, 1.0F, 0.625F, 0.25F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.0F, 0.6875, 0.3125F, 0.625F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.6875, 0.0F, 0.6875, 1.0F, 0.625F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + + CastingTableLogic logic = (CastingTableLogic) world.getBlockTileEntity(x, y, z); + if (logic.liquid != null) + { + float height = logic.getLiquidAmount() / (logic.getCapacity() * 1.03F) / 16F; + renderer.setRenderBounds(0.0625F, 0.9375F, 0.0625F, 0.9375F, 0.9375F + height, 0.9375F); + + Fluid fluid = logic.liquid.getFluid(); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + /*if (logic.liquid.fluidID < 4096) //Block + { + Block liquidBlock = Block.blocksList[logic.liquid.fluidID]; + if (liquidBlock != null) + { + //ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0); + BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, 0, x, y, z, renderer, world); + } + } + else + //Item + { + Item liquidItem = Item.itemsList[logic.liquid.fluidID]; + if (liquidItem != null) + { + //ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0); + BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(0), x, y, z, renderer, world); + } + }*/ + } + } + else if (metadata == 1) + { + FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z); + float xMin = 0.375F, zMin = 0.375F, xMax = 0.625F, zMax = 0.625F; + switch (logic.getRenderDirection()) + { + case 2: + renderer.setRenderBounds(0.25, 0.25, 0.625, 0.75, 0.375, 1); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.25, 0.375, 0.625, 0.375, 0.625, 1); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625, 0.375, 0.625, 0.75, 0.625, 1); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.375, 0.375, 0.625, 0.625, 0.625, 1); + zMin = 0.5F; + //zMin = 0.625F; + break; + case 3: + renderer.setRenderBounds(0.25, 0.25, 0, 0.75, 0.375, 0.375); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.25, 0.375, 0, 0.375, 0.625, 0.375); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625, 0.375, 0, 0.75, 0.625, 0.375); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.375, 0.375, 0, 0.625, 0.625, 0.375); + zMax = 0.5F; + break; + case 4: + renderer.setRenderBounds(0.625, 0.25, 0.25, 1, 0.375, 0.75); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625, 0.375, 0.25, 1, 0.625, 0.375); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625, 0.375, 0.625, 1, 0.625, 0.75); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625, 0.375, 0.375, 1, 0.625, 0.625); + xMin = 0.5F; + break; + case 5: + renderer.setRenderBounds(0, 0.25, 0.25, 0.375, 0.375, 0.75); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0, 0.375, 0.25, 0.375, 0.625, 0.375); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0, 0.375, 0.625, 0.375, 0.625, 0.75); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0, 0.375, 0.375, 0.375, 0.625, 0.625); + xMax = 0.5F; + break; + } + + float yMin = 0F; + int uID = world.getBlockId(x, y - 1, z); + int uMeta = world.getBlockMetadata(x, y - 1, z); + if (uID == TContent.searedBlock.blockID && uMeta == 0) + { + yMin = -0.125F; + } + else if (uID == TContent.searedBlock.blockID && uMeta == 2) + { + yMin = -0.75F; + } + else if (uID == TContent.lavaTank.blockID) + { + yMin = -1F; + } + + if (logic.liquid != null) + { + Fluid fluid = logic.liquid.getFluid(); + renderer.setRenderBounds(xMin, yMin, zMin, xMax, 0.625, zMax); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + /*if (fluid.canBePlacedInWorld()) + { + Block liquidBlock = Block.blocksList[blockToRender.itemID]; + BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, 0, x, y, z, renderer, world); + renderer.setRenderBounds(xMin, yMin, zMin, xMax, 0.625, zMax); + BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, 0, x, y, z, renderer, world); + }*/ + /*ItemStack blockToRender = new ItemStack(logic.liquid.fluidID, 1, logic.liquid.itemMeta); + if (blockToRender.itemID < 4096) //Block + { + + } + else + //Item + { + Item liquidItem = Item.itemsList[blockToRender.itemID]; + //ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0); + int meta = blockToRender.getItemDamage(); + BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(meta), x, y, z, renderer, world); + renderer.setRenderBounds(xMin, yMin, zMin, xMax, 0.625, zMax); + BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(meta), x, y, z, renderer, world); + }*/ + //renderer.renderStandardBlock(block, x, y, z); + } + + } + else if (metadata == 2) + { + renderer.setRenderBounds(0.125F, 0.125f, 0.125F, 0.875F, 0.25F, 0.875F); + renderer.renderStandardBlock(block, x, y, z); + + //Outside + renderer.setRenderBounds(0.0f, 0.125, 0f, 0.125, 1.0F, 1); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.875f, 0.125, 0f, 1, 1.0F, 1); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.125f, 0.125, 0f, 0.875f, 1.0F, 0.125f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.125f, 0.125, 0.875f, 0.875f, 1.0F, 1); + renderer.renderStandardBlock(block, x, y, z); + + //Details + + renderer.setRenderBounds(0.001f, 0.1245f, 0.001f, 0.1245f, 0.999f, 0.4375f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.001f, 0.1245f, 0.5625f, 0.1245f, 0.999f, 0.999f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.001f, 0.8755f, 0.4375f, 0.1245f, 0.999f, 0.5625f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.001f, 0.1245f, 0.4375f, 0.1245f, 0.25F, 0.5625f); + renderer.renderStandardBlock(block, x, y, z); + + renderer.setRenderBounds(0.8755f, 0.1245f, 0f, 0.999f, 0.999f, 0.4375f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.8755f, 0.1245f, 0.5625f, 0.999f, 0.999f, 0.999f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.8755f, 0.8755f, 0.4375f, 0.999f, 0.999f, 0.5625f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.8755f, 0.1245f, 0.4375f, 0.999f, 0.25F, 0.5625f); + renderer.renderStandardBlock(block, x, y, z); + + renderer.setRenderBounds(0.1245f, 0.1245f, 0.8755f, 0.4375f, 0.999f, 0.999f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.5625f, 0.1245f, 0.8755f, 0.8755f, 0.999f, 0.999f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.4375f, 0.8755f, 0.8755f, 0.5625f, 0.999f, 0.999f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.4375f, 0.1245f, 0.8755f, 0.5625f, 0.2495F, 0.999f); + renderer.renderStandardBlock(block, x, y, z); + + renderer.setRenderBounds(0.1245f, 0.1245f, 0.001f, 0.4375f, 0.999f, 0.1245f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.5625f, 0.1245f, 0.001f, 0.8755f, 0.999f, 0.1245f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.4375f, 0.8755f, 0.001f, 0.5625f, 0.999f, 0.1245f); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.4375f, 0.1245f, 0.001f, 0.5625f, 0.25F, 0.1245f); + renderer.renderStandardBlock(block, x, y, z); + + //Legs + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.3125F, 0.125, 0.3125F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.6875F, 0.0F, 0.0F, 1.0F, 0.125, 0.3125F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.0F, 0.6875F, 0.3125F, 0.125, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.6875F, 0.0F, 0.6875F, 1.0F, 0.125, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + + //Liquids + CastingBasinLogic logic = (CastingBasinLogic) world.getBlockTileEntity(x, y, z); + if (logic.liquid != null) + { + float height = logic.getLiquidAmount() / (logic.getCapacity() * 1.05F) * 0.6875F; + renderer.setRenderBounds(0.0625F, 0.25f, 0.0625F, 0.9375F, 0.25f + height, 0.9375F); + + Fluid fluid = logic.liquid.getFluid(); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + /*if (logic.liquid.itemID < 4096) //Block + { + Block liquidBlock = Block.blocksList[logic.liquid.itemID]; + if (liquidBlock != null) + { + //ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0); + BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, logic.liquid.itemMeta, x, y, z, renderer, world); + } + } + else + //Item + { + Item liquidItem = Item.itemsList[logic.liquid.itemID]; + if (liquidItem != null) + { + //ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0); + BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(logic.liquid.itemMeta), x, y, z, renderer, world); + } + }*/ + } + } + else + { + renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + } + } + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return searedModel; + } +} diff --git a/tconstruct/client/block/SmallFontRenderer.java b/tconstruct/client/block/SmallFontRenderer.java new file mode 100644 index 00000000..cc9e5432 --- /dev/null +++ b/tconstruct/client/block/SmallFontRenderer.java @@ -0,0 +1,1043 @@ +package tconstruct.client.block; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.text.Bidi; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Random; + +import javax.imageio.ImageIO; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.ResourceManager; +import net.minecraft.client.resources.ResourceManagerReloadListener; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.ChatAllowedCharacters; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class SmallFontRenderer implements ResourceManagerReloadListener +{ + private static final ResourceLocation[] field_111274_c = new ResourceLocation[256]; + + /** Array of width of all the characters in default.png */ + private int[] charWidth = new int[256]; + + /** the height in pixels of default text */ + public int FONT_HEIGHT = 9; + public Random fontRandom = new Random(); + + /** + * Array of the start/end column (in upper/lower nibble) for every glyph in the /font directory. + */ + private byte[] glyphWidth = new byte[65536]; + + /** + * Array of RGB triplets defining the 16 standard chat colors followed by 16 darker version of the same colors for + * drop shadows. + */ + private int[] colorCode = new int[32]; + private final ResourceLocation field_111273_g; + + /** The RenderEngine used to load and setup glyph textures. */ + private final TextureManager renderEngine; + + /** Current X coordinate at which to draw the next character. */ + private float posX; + + /** Current Y coordinate at which to draw the next character. */ + private float posY; + + /** + * If true, strings should be rendered with Unicode fonts instead of the default.png font + */ + private boolean unicodeFlag; + + /** + * If true, the Unicode Bidirectional Algorithm should be run before rendering any string. + */ + private boolean bidiFlag; + + /** Used to specify new red value for the current color. */ + private float red; + + /** Used to specify new blue value for the current color. */ + private float blue; + + /** Used to specify new green value for the current color. */ + private float green; + + /** Used to speify new alpha value for the current color. */ + private float alpha; + + /** Text color of the currently rendering string. */ + private int textColor; + + /** Set if the "k" style (random) is active in currently rendering string */ + private boolean randomStyle; + + /** Set if the "l" style (bold) is active in currently rendering string */ + private boolean boldStyle; + + /** Set if the "o" style (italic) is active in currently rendering string */ + private boolean italicStyle; + + /** + * Set if the "n" style (underlined) is active in currently rendering string + */ + private boolean underlineStyle; + + /** + * Set if the "m" style (strikethrough) is active in currently rendering string + */ + private boolean strikethroughStyle; + + public SmallFontRenderer(GameSettings par1GameSettings, ResourceLocation par2ResourceLocation, TextureManager par3TextureManager, boolean par4) + { + this.field_111273_g = par2ResourceLocation; + this.renderEngine = par3TextureManager; + this.unicodeFlag = true; + par3TextureManager.func_110577_a(this.field_111273_g); + + for (int i = 0; i < 32; ++i) + { + int j = (i >> 3 & 1) * 85; + int k = (i >> 2 & 1) * 170 + j; + int l = (i >> 1 & 1) * 170 + j; + int i1 = (i >> 0 & 1) * 170 + j; + + if (i == 6) + { + k += 85; + } + + if (par1GameSettings.anaglyph) + { + int j1 = (k * 30 + l * 59 + i1 * 11) / 100; + int k1 = (k * 30 + l * 70) / 100; + int l1 = (k * 30 + i1 * 70) / 100; + k = j1; + l = k1; + i1 = l1; + } + + if (i >= 16) + { + k /= 4; + l /= 4; + i1 /= 4; + } + + this.colorCode[i] = (k & 255) << 16 | (l & 255) << 8 | i1 & 255; + } + + this.readGlyphSizes(); + } + + public void func_110549_a(ResourceManager par1ResourceManager) + { + this.func_111272_d(); + } + + private void func_111272_d() + { + BufferedImage bufferedimage; + + try + { + bufferedimage = ImageIO.read(Minecraft.getMinecraft().func_110442_L().func_110536_a(this.field_111273_g).func_110527_b()); + } + catch (IOException ioexception) + { + throw new RuntimeException(ioexception); + } + + int i = bufferedimage.getWidth(); + int j = bufferedimage.getHeight(); + int[] aint = new int[i * j]; + bufferedimage.getRGB(0, 0, i, j, aint, 0, i); + int k = j / 16; + int l = i / 16; + byte b0 = 1; + float f = 8.0F / (float)l; + int i1 = 0; + + while (i1 < 256) + { + int j1 = i1 % 16; + int k1 = i1 / 16; + + if (i1 == 32) + { + this.charWidth[i1] = 3 + b0; + } + + int l1 = l - 1; + + while (true) + { + if (l1 >= 0) + { + int i2 = j1 * l + l1; + boolean flag = true; + + for (int j2 = 0; j2 < k && flag; ++j2) + { + int k2 = (k1 * l + j2) * i; + + if ((aint[i2 + k2] >> 24 & 255) != 0) + { + flag = false; + } + } + + if (flag) + { + --l1; + continue; + } + } + + ++l1; + this.charWidth[i1] = (int)(0.5D + (double)((float)l1 * f)) + b0; + ++i1; + break; + } + } + } + + private void readGlyphSizes() + { + try + { + InputStream inputstream = Minecraft.getMinecraft().func_110442_L().func_110536_a(new ResourceLocation("font/glyph_sizes.bin")).func_110527_b(); + inputstream.read(this.glyphWidth); + } + catch (IOException ioexception) + { + throw new RuntimeException(ioexception); + } + } + + /** + * Pick how to render a single character and return the width used. + */ + private float renderCharAtPos(int par1, char par2, boolean par3) + { + return par2 == 32 ? 4.0F : (par1 > 0 && !this.unicodeFlag ? this.renderDefaultChar(par1 + 32, par3) : this.renderUnicodeChar(par2, par3)); + } + + /** + * Render a single character with the default.png font at current (posX,posY) location... + */ + private float renderDefaultChar(int par1, boolean par2) + { + float f = (float)(par1 % 16 * 8); + float f1 = (float)(par1 / 16 * 8); + float f2 = par2 ? 1.0F : 0.0F; + this.renderEngine.func_110577_a(this.field_111273_g); + float f3 = (float)this.charWidth[par1] - 0.01F; + GL11.glBegin(GL11.GL_TRIANGLE_STRIP); + GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F); + GL11.glVertex3f(this.posX + f2, this.posY, 0.0F); + GL11.glTexCoord2f(f / 128.0F, (f1 + 7.99F) / 128.0F); + GL11.glVertex3f(this.posX - f2, this.posY + 7.99F, 0.0F); + GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, f1 / 128.0F); + GL11.glVertex3f(this.posX + f3 - 1.0F + f2, this.posY, 0.0F); + GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F); + GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F); + GL11.glEnd(); + return (float)this.charWidth[par1]; + } + + private ResourceLocation func_111271_a(int par1) + { + if (field_111274_c[par1] == null) + { + field_111274_c[par1] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[] {Integer.valueOf(par1)})); + } + + return field_111274_c[par1]; + } + + /** + * Load one of the /font/glyph_XX.png into a new GL texture and store the texture ID in glyphTextureName array. + */ + private void loadGlyphTexture(int par1) + { + this.renderEngine.func_110577_a(this.func_111271_a(par1)); + } + + /** + * Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files... + */ + private float renderUnicodeChar(char par1, boolean par2) + { + if (this.glyphWidth[par1] == 0) + { + return 0.0F; + } + else + { + int i = par1 / 256; + this.loadGlyphTexture(i); + int j = this.glyphWidth[par1] >>> 4; + int k = this.glyphWidth[par1] & 15; + float f = (float)j; + float f1 = (float)(k + 1); + float f2 = (float)(par1 % 16 * 16) + f; + float f3 = (float)((par1 & 255) / 16 * 16); + float f4 = f1 - f - 0.02F; + float f5 = par2 ? 1.0F : 0.0F; + GL11.glBegin(GL11.GL_TRIANGLE_STRIP); + GL11.glTexCoord2f(f2 / 256.0F, f3 / 256.0F); + GL11.glVertex3f(this.posX + f5, this.posY, 0.0F); + GL11.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F); + GL11.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F); + GL11.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F); + GL11.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F); + GL11.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F); + GL11.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F); + GL11.glEnd(); + return (f1 - f) / 2.0F + 1.0F; + } + } + + /** + * Draws the specified string with a shadow. + */ + public int drawStringWithShadow(String par1Str, int par2, int par3, int par4) + { + return this.drawString(par1Str, par2, par3, par4, true); + } + + /** + * Draws the specified string. + */ + public int drawString(String par1Str, int par2, int par3, int par4) + { + return this.drawString(par1Str, par2, par3, par4, false); + } + + /** + * Draws the specified string. Args: string, x, y, color, dropShadow + */ + public int drawString(String par1Str, int par2, int par3, int par4, boolean par5) + { + this.resetStyles(); + + if (this.bidiFlag) + { + par1Str = this.bidiReorder(par1Str); + } + + int l; + + if (par5) + { + l = this.renderString(par1Str, par2 + 1, par3 + 1, par4, true); + l = Math.max(l, this.renderString(par1Str, par2, par3, par4, false)); + } + else + { + l = this.renderString(par1Str, par2, par3, par4, false); + } + + return l; + } + + /** + * Apply Unicode Bidirectional Algorithm to string and return a new possibly reordered string for visual rendering. + */ + private String bidiReorder(String par1Str) + { + if (par1Str != null && Bidi.requiresBidi(par1Str.toCharArray(), 0, par1Str.length())) + { + Bidi bidi = new Bidi(par1Str, -2); + byte[] abyte = new byte[bidi.getRunCount()]; + String[] astring = new String[abyte.length]; + int i; + + for (int j = 0; j < abyte.length; ++j) + { + int k = bidi.getRunStart(j); + i = bidi.getRunLimit(j); + int l = bidi.getRunLevel(j); + String s1 = par1Str.substring(k, i); + abyte[j] = (byte)l; + astring[j] = s1; + } + + String[] astring1 = (String[])astring.clone(); + Bidi.reorderVisually(abyte, 0, astring, 0, abyte.length); + StringBuilder stringbuilder = new StringBuilder(); + i = 0; + + while (i < astring.length) + { + byte b0 = abyte[i]; + int i1 = 0; + + while (true) + { + if (i1 < astring1.length) + { + if (!astring1[i1].equals(astring[i])) + { + ++i1; + continue; + } + + b0 = abyte[i1]; + } + + if ((b0 & 1) == 0) + { + stringbuilder.append(astring[i]); + } + else + { + for (i1 = astring[i].length() - 1; i1 >= 0; --i1) + { + char c0 = astring[i].charAt(i1); + + if (c0 == 40) + { + c0 = 41; + } + else if (c0 == 41) + { + c0 = 40; + } + + stringbuilder.append(c0); + } + } + + ++i; + break; + } + } + + return stringbuilder.toString(); + } + else + { + return par1Str; + } + } + + /** + * Reset all style flag fields in the class to false; called at the start of string rendering + */ + private void resetStyles() + { + this.randomStyle = false; + this.boldStyle = false; + this.italicStyle = false; + this.underlineStyle = false; + this.strikethroughStyle = false; + } + + /** + * Render a single line string at the current (posX,posY) and update posX + */ + private void renderStringAtPos(String par1Str, boolean par2) + { + for (int i = 0; i < par1Str.length(); ++i) + { + char c0 = par1Str.charAt(i); + int j; + int k; + + if (c0 == 167 && i + 1 < par1Str.length()) + { + j = "0123456789abcdefklmnor".indexOf(par1Str.toLowerCase().charAt(i + 1)); + + if (j < 16) + { + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + + if (j < 0 || j > 15) + { + j = 15; + } + + if (par2) + { + j += 16; + } + + k = this.colorCode[j]; + this.textColor = k; + GL11.glColor4f((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha); + } + else if (j == 16) + { + this.randomStyle = true; + } + else if (j == 17) + { + this.boldStyle = true; + } + else if (j == 18) + { + this.strikethroughStyle = true; + } + else if (j == 19) + { + this.underlineStyle = true; + } + else if (j == 20) + { + this.italicStyle = true; + } + else if (j == 21) + { + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + GL11.glColor4f(this.red, this.blue, this.green, this.alpha); + } + + ++i; + } + else + { + j = ChatAllowedCharacters.allowedCharacters.indexOf(c0); + + if (this.randomStyle && j > 0) + { + do + { + k = this.fontRandom.nextInt(ChatAllowedCharacters.allowedCharacters.length()); + } + while (this.charWidth[j + 32] != this.charWidth[k + 32]); + + j = k; + } + + float f = this.unicodeFlag ? 0.5F : 1.0F; + boolean flag1 = (j <= 0 || this.unicodeFlag) && par2; + + if (flag1) + { + this.posX -= f; + this.posY -= f; + } + + float f1 = this.renderCharAtPos(j, c0, this.italicStyle); + + if (flag1) + { + this.posX += f; + this.posY += f; + } + + if (this.boldStyle) + { + this.posX += f; + + if (flag1) + { + this.posX -= f; + this.posY -= f; + } + + this.renderCharAtPos(j, c0, this.italicStyle); + this.posX -= f; + + if (flag1) + { + this.posX += f; + this.posY += f; + } + + ++f1; + } + + Tessellator tessellator; + + if (this.strikethroughStyle) + { + tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(this.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double)(this.posX + f1), (double)(this.posY + (float)(this.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double)(this.posX + f1), (double)(this.posY + (float)(this.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(this.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + if (this.underlineStyle) + { + tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + int l = this.underlineStyle ? -1 : 0; + tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)this.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double)(this.posX + f1), (double)(this.posY + (float)this.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double)(this.posX + f1), (double)(this.posY + (float)this.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)this.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + this.posX += (float)((int)f1); + } + } + } + + /** + * Render string either left or right aligned depending on bidiFlag + */ + private int renderStringAligned(String par1Str, int par2, int par3, int par4, int par5, boolean par6) + { + if (this.bidiFlag) + { + par1Str = this.bidiReorder(par1Str); + int i1 = this.getStringWidth(par1Str); + par2 = par2 + par4 - i1; + } + + return this.renderString(par1Str, par2, par3, par5, par6); + } + + /** + * Render single line string by setting GL color, current (posX,posY), and calling renderStringAtPos() + */ + private int renderString(String par1Str, int par2, int par3, int par4, boolean par5) + { + if (par1Str == null) + { + return 0; + } + else + { + if ((par4 & -67108864) == 0) + { + par4 |= -16777216; + } + + if (par5) + { + par4 = (par4 & 16579836) >> 2 | par4 & -16777216; + } + + this.red = (float)(par4 >> 16 & 255) / 255.0F; + this.blue = (float)(par4 >> 8 & 255) / 255.0F; + this.green = (float)(par4 & 255) / 255.0F; + this.alpha = (float)(par4 >> 24 & 255) / 255.0F; + GL11.glColor4f(this.red, this.blue, this.green, this.alpha); + this.posX = (float)par2; + this.posY = (float)par3; + this.renderStringAtPos(par1Str, par5); + return (int)this.posX; + } + } + + /** + * Returns the width of this string. Equivalent of FontMetrics.stringWidth(String s). + */ + public int getStringWidth(String par1Str) + { + if (par1Str == null) + { + return 0; + } + else + { + int i = 0; + boolean flag = false; + + for (int j = 0; j < par1Str.length(); ++j) + { + char c0 = par1Str.charAt(j); + int k = this.getCharWidth(c0); + + if (k < 0 && j < par1Str.length() - 1) + { + ++j; + c0 = par1Str.charAt(j); + + if (c0 != 108 && c0 != 76) + { + if (c0 == 114 || c0 == 82) + { + flag = false; + } + } + else + { + flag = true; + } + + k = 0; + } + + i += k; + + if (flag) + { + ++i; + } + } + + return i; + } + } + + /** + * Returns the width of this character as rendered. + */ + public int getCharWidth(char par1) + { + if (par1 == 167) + { + return -1; + } + else if (par1 == 32) + { + return 4; + } + else + { + int i = ChatAllowedCharacters.allowedCharacters.indexOf(par1); + + if (i >= 0 && !this.unicodeFlag) + { + return this.charWidth[i + 32]; + } + else if (this.glyphWidth[par1] != 0) + { + int j = this.glyphWidth[par1] >>> 4; + int k = this.glyphWidth[par1] & 15; + + if (k > 7) + { + k = 15; + j = 0; + } + + ++k; + return (k - j) / 2 + 1; + } + else + { + return 0; + } + } + } + + /** + * Trims a string to fit a specified Width. + */ + public String trimStringToWidth(String par1Str, int par2) + { + return this.trimStringToWidth(par1Str, par2, false); + } + + /** + * Trims a string to a specified width, and will reverse it if par3 is set. + */ + public String trimStringToWidth(String par1Str, int par2, boolean par3) + { + StringBuilder stringbuilder = new StringBuilder(); + int j = 0; + int k = par3 ? par1Str.length() - 1 : 0; + int l = par3 ? -1 : 1; + boolean flag1 = false; + boolean flag2 = false; + + for (int i1 = k; i1 >= 0 && i1 < par1Str.length() && j < par2; i1 += l) + { + char c0 = par1Str.charAt(i1); + int j1 = this.getCharWidth(c0); + + if (flag1) + { + flag1 = false; + + if (c0 != 108 && c0 != 76) + { + if (c0 == 114 || c0 == 82) + { + flag2 = false; + } + } + else + { + flag2 = true; + } + } + else if (j1 < 0) + { + flag1 = true; + } + else + { + j += j1; + + if (flag2) + { + ++j; + } + } + + if (j > par2) + { + break; + } + + if (par3) + { + stringbuilder.insert(0, c0); + } + else + { + stringbuilder.append(c0); + } + } + + return stringbuilder.toString(); + } + + /** + * Remove all newline characters from the end of the string + */ + private String trimStringNewline(String par1Str) + { + while (par1Str != null && par1Str.endsWith("\n")) + { + par1Str = par1Str.substring(0, par1Str.length() - 1); + } + + return par1Str; + } + + /** + * Splits and draws a String with wordwrap (maximum length is parameter k) + */ + public void drawSplitString(String par1Str, int par2, int par3, int par4, int par5) + { + this.resetStyles(); + this.textColor = par5; + par1Str = this.trimStringNewline(par1Str); + this.renderSplitString(par1Str, par2, par3, par4, false); + } + + /** + * Perform actual work of rendering a multi-line string with wordwrap and with darker drop shadow color if flag is + * set + */ + private void renderSplitString(String par1Str, int par2, int par3, int par4, boolean par5) + { + List list = this.listFormattedStringToWidth(par1Str, par4); + + for (Iterator iterator = list.iterator(); iterator.hasNext(); par3 += this.FONT_HEIGHT) + { + String s1 = (String)iterator.next(); + this.renderStringAligned(s1, par2, par3, par4, this.textColor, par5); + } + } + + /** + * Returns the width of the wordwrapped String (maximum length is parameter k) + */ + public int splitStringWidth(String par1Str, int par2) + { + return this.FONT_HEIGHT * this.listFormattedStringToWidth(par1Str, par2).size(); + } + + /** + * Set unicodeFlag controlling whether strings should be rendered with Unicode fonts instead of the default.png + * font. + */ + public void setUnicodeFlag(boolean par1) + { + this.unicodeFlag = par1; + } + + /** + * Get unicodeFlag controlling whether strings should be rendered with Unicode fonts instead of the default.png + * font. + */ + public boolean getUnicodeFlag() + { + return this.unicodeFlag; + } + + /** + * Set bidiFlag to control if the Unicode Bidirectional Algorithm should be run before rendering any string. + */ + public void setBidiFlag(boolean par1) + { + this.bidiFlag = par1; + } + + /** + * Breaks a string into a list of pieces that will fit a specified width. + */ + public List listFormattedStringToWidth(String par1Str, int par2) + { + return Arrays.asList(this.wrapFormattedStringToWidth(par1Str, par2).split("\n")); + } + + /** + * Inserts newline and formatting into a string to wrap it within the specified width. + */ + String wrapFormattedStringToWidth(String par1Str, int par2) + { + int j = this.sizeStringToWidth(par1Str, par2); + + if (par1Str.length() <= j) + { + return par1Str; + } + else + { + String s1 = par1Str.substring(0, j); + char c0 = par1Str.charAt(j); + boolean flag = c0 == 32 || c0 == 10; + String s2 = getFormatFromString(s1) + par1Str.substring(j + (flag ? 1 : 0)); + return s1 + "\n" + this.wrapFormattedStringToWidth(s2, par2); + } + } + + /** + * Determines how many characters from the string will fit into the specified width. + */ + private int sizeStringToWidth(String par1Str, int par2) + { + int j = par1Str.length(); + int k = 0; + int l = 0; + int i1 = -1; + + for (boolean flag = false; l < j; ++l) + { + char c0 = par1Str.charAt(l); + + switch (c0) + { + case 10: + --l; + break; + case 167: + if (l < j - 1) + { + ++l; + char c1 = par1Str.charAt(l); + + if (c1 != 108 && c1 != 76) + { + if (c1 == 114 || c1 == 82 || isFormatColor(c1)) + { + flag = false; + } + } + else + { + flag = true; + } + } + + break; + case 32: + i1 = l; + default: + k += this.getCharWidth(c0); + + if (flag) + { + ++k; + } + } + + if (c0 == 10) + { + ++l; + i1 = l; + break; + } + + if (k > par2) + { + break; + } + } + + return l != j && i1 != -1 && i1 < l ? i1 : l; + } + + /** + * Checks if the char code is a hexadecimal character, used to set colour. + */ + private static boolean isFormatColor(char par0) + { + return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70; + } + + /** + * Checks if the char code is O-K...lLrRk-o... used to set special formatting. + */ + private static boolean isFormatSpecial(char par0) + { + return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82; + } + + /** + * Digests a string for nonprinting formatting characters then returns a string containing only that formatting. + */ + private static String getFormatFromString(String par0Str) + { + String s1 = ""; + int i = -1; + int j = par0Str.length(); + + while ((i = par0Str.indexOf(167, i + 1)) != -1) + { + if (i < j - 1) + { + char c0 = par0Str.charAt(i + 1); + + if (isFormatColor(c0)) + { + s1 = "\u00a7" + c0; + } + else if (isFormatSpecial(c0)) + { + s1 = s1 + "\u00a7" + c0; + } + } + } + + return s1; + } + + /** + * Get bidiFlag that controls if the Unicode Bidirectional Algorithm should be run before rendering any string + */ + public boolean getBidiFlag() + { + return this.bidiFlag; + } +} diff --git a/tconstruct/client/block/SmelteryRender.java b/tconstruct/client/block/SmelteryRender.java new file mode 100644 index 00000000..3e67d599 --- /dev/null +++ b/tconstruct/client/block/SmelteryRender.java @@ -0,0 +1,175 @@ +package tconstruct.client.block; + +import tconstruct.blocks.logic.SmelteryLogic; +import tconstruct.client.TProxyClient; +import tconstruct.library.crafting.Smeltery; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class SmelteryRender implements ISimpleBlockRenderingHandler +{ + public static int smelteryModel = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == smelteryModel) + { + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + } + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == smelteryModel) + { + if (world.getBlockMetadata(x, y, z) == 0) + return renderSmeltery(world, x, y, z, block, modelID, renderer); + else + renderer.renderStandardBlock(block, x, y, z); + } + return true; + } + + public boolean renderSmeltery (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + renderer.renderStandardBlock(block, x, y, z); + SmelteryLogic logic = (SmelteryLogic) world.getBlockTileEntity(x, y, z); + if (logic.validStructure) + { + int posX = logic.centerPos.x - 1, posY = logic.centerPos.y, posZ = logic.centerPos.z - 1; + //Melting + if (logic.getSizeInventory() > 0) + { + for (int i = 0; i < logic.layers; i++) + { + renderLayer(logic, i * 9, posX, posY + i, posZ, renderer, world); + } + } + + //Liquids + float base = 0F; + int yBase = 0; + int liquidBase = 0; + for (FluidStack liquid : logic.moltenMetal) + { + int liquidSize = liquid.amount; + while (liquidSize > 0) + { + int room = 20000 - liquidBase; + int countSize = liquidSize > room ? room : liquidSize; + liquidSize -= countSize; + + float height = countSize > 20000 ? 1.0F : countSize / 20000F; + //renderer.setRenderBounds(0, base, 0, 1, height + base, 1); + float renderBase = base; + float renderHeight = height + base; + base += height; + liquidBase += countSize; + + Fluid fluid = liquid.getFluid(); + for (int i = 0; i < 9; i++) + { + float minX = i % 3 == 0 ? -0.001F : 0F; + float minZ = i / 3 == 0 ? -0.001F : 0F; + float maxX = i % 3 == 2 ? 1.001F : 1F; + float maxZ = i / 3 == 2 ? 1.001F : 1F; + renderer.setRenderBounds(minX, renderBase, minZ, maxX, renderHeight, maxZ); + if (fluid.canBePlacedInWorld()) + BlockSkinRenderHelper.renderMetadataBlock(Block.blocksList[fluid.getBlockID()], 0, posX + i % 3, posY + yBase, posZ + i / 3, renderer, world); + else + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), posX + i % 3, posY + yBase, posZ + i / 3, renderer, world); + } + /*if (liquid.itemID < 4096) //Block + { + Block liquidBlock = Block.blocksList[liquid.itemID]; + for (int i = 0; i < 9; i++) + { + float minX = i % 3 == 0 ? -0.001F : 0F; + float minZ = i / 3 == 0 ? -0.001F : 0F; + float maxX = i % 3 == 2 ? 1.001F : 1F; + float maxZ = i / 3 == 2 ? 1.001F : 1F; + renderer.setRenderBounds(minX, renderBase, minZ, maxX, renderHeight, maxZ); + BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, liquid.itemMeta, posX + i % 3, posY + yBase, posZ + i / 3, renderer, world); + } + } + else + //Item + { + Item liquidItem = Item.itemsList[liquid.itemID]; + for (int i = 0; i < 9; i++) + { + float minX = i % 3 == 0 ? -0.001F : 0F; + float minZ = i / 3 == 0 ? -0.001F : 0F; + float maxX = i % 3 == 2 ? 1.001F : 1F; + float maxZ = i / 3 == 2 ? 1.001F : 1F; + renderer.setRenderBounds(minX, renderBase, minZ, maxX, renderHeight, maxZ); + BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(liquid.itemMeta), posX, posY + yBase, posZ, renderer, world); + } + }*/ + + if (countSize == room) + { + base = 0F; + yBase++; + liquidBase = 0; + } + } + } + } + return true; + } + + void renderLayer (SmelteryLogic logic, int start, int posX, int posY, int posZ, RenderBlocks renderer, IBlockAccess world) + { + renderer.setRenderBounds(-0.001F, -0.001F, -0.001F, 1.001F, 1.001F, 1.001F); + for (int i = 0; i < 9; i++) + { + ItemStack input = logic.getStackInSlot(i + start); + if (input != null && logic.getTempForSlot(i + start) > 20) + { + ItemStack blockToRender = Smeltery.getRenderIndex(input); + if (blockToRender != null) + { + float blockHeight = input.stackSize / (float) blockToRender.stackSize; + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, MathHelper.clamp_float(blockHeight, 0.01F, 1.0F), 1.0F); + + if (blockToRender.itemID < 4096) //Block + { + Block liquidBlock = Block.blocksList[blockToRender.itemID]; + BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, blockToRender.getItemDamage(), posX + i % 3, posY, posZ + i / 3, renderer, world); + } + + /*else //No items, only blocks + //Item + { + Item liquidItem = Item.itemsList[blockToRender.itemID]; + int metadata = blockToRender.getItemDamage(); + BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(metadata), posX + i % 3, posY, posZ + i / 3, renderer, world); + }*/ + } + } + } + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return smelteryModel; + } +} diff --git a/tconstruct/client/block/TableForgeRender.java b/tconstruct/client/block/TableForgeRender.java new file mode 100644 index 00000000..a9af58c3 --- /dev/null +++ b/tconstruct/client/block/TableForgeRender.java @@ -0,0 +1,96 @@ +package tconstruct.client.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class TableForgeRender implements ISimpleBlockRenderingHandler +{ + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); + renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F); + renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F); + renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F); + renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F); + renderStandardInvBlock(renderer, block, metadata); + } + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + } + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return model; + } + + public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta) + { + Tessellator tessellator = Tessellator.instance; + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1F, 0.0F); + renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } +} diff --git a/tconstruct/client/block/TableRender.java b/tconstruct/client/block/TableRender.java new file mode 100644 index 00000000..489c863b --- /dev/null +++ b/tconstruct/client/block/TableRender.java @@ -0,0 +1,113 @@ +package tconstruct.client.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class TableRender implements ISimpleBlockRenderingHandler +{ + public static int tabelModelID = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == tabelModelID) + { + if (metadata == 5) + { + renderer.setRenderBounds(0.0F, 0.0, 0.0F, 1.0F, 0.875F, 1.0F); + renderStandardInvBlock(renderer, block, metadata); + } + else + { + renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); + renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F); + renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F); + renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F); + renderStandardInvBlock(renderer, block, metadata); + renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F); + renderStandardInvBlock(renderer, block, metadata); + } + } + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == tabelModelID) + { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 5) + { + renderer.setRenderBounds(0.0F, 0.0, 0.0F, 1.0F, 0.875F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + } + else + { + renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + } + } + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return tabelModelID; + } + + public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta) + { + Tessellator tessellator = Tessellator.instance; + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1F, 0.0F); + renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } +} diff --git a/tconstruct/client/block/TankRender.java b/tconstruct/client/block/TankRender.java new file mode 100644 index 00000000..c92cbac9 --- /dev/null +++ b/tconstruct/client/block/TankRender.java @@ -0,0 +1,113 @@ +package tconstruct.client.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.Item; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.LavaTankLogic; +import tconstruct.client.TProxyClient; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class TankRender implements ISimpleBlockRenderingHandler +{ + public static int tankModelID = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == tankModelID) + { + TProxyClient.renderStandardInvBlock(renderer, block, metadata); + if (metadata == 0) + { + renderer.setRenderBounds(0.1875, 0, 0.1875, 0.8125, 0.125, 0.8125); + renderDoRe(renderer, block, metadata); + } + } + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == tankModelID) + { + //Liquid + LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z); + if (logic.containsFluid()) + { + FluidStack liquid = logic.tank.getFluid(); + renderer.setRenderBounds(0.001, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999); + Fluid fluid = liquid.getFluid(); + if (fluid.canBePlacedInWorld()) + BlockSkinRenderHelper.renderMetadataBlock(Block.blocksList[fluid.getBlockID()], 0, x, y, z, renderer, world); + else + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + + + renderer.setRenderBounds(00, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999); + } + + //Block + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0 && world.getBlockId(x, y + 1, z) == 0) + { + renderer.setRenderBounds(0.1875, 0, 0.1875, 0.8125, 0.125, 0.8125); + renderer.renderStandardBlock(block, x, y + 1, z); + } + renderer.setRenderBounds(0, 0, 0, 1, 1, 1); + renderer.renderStandardBlock(block, x, y, z); + } + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return tankModelID; + } + + private void renderDoRe (RenderBlocks renderblocks, Block block, int meta) + { + Tessellator tessellator = Tessellator.instance; + GL11.glTranslatef(-0.5F, 0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1F, 0.0F); + renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } +} diff --git a/tconstruct/client/entity/CartRender.java b/tconstruct/client/entity/CartRender.java new file mode 100644 index 00000000..1813be74 --- /dev/null +++ b/tconstruct/client/entity/CartRender.java @@ -0,0 +1,141 @@ +package tconstruct.client.entity; + +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; + +import org.lwjgl.opengl.GL11; + +import tconstruct.entity.CartEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class CartRender extends Render +{ + protected ModelBase modelCart; + RenderBlocks renderblocks; + + public CartRender() + { + this.shadowSize = 0.5F; + this.modelCart = new ModelPullcart(); + renderblocks = new RenderBlocks(); + } + + public void renderPullcart (CartEntity cart, double posX, double posY, double posZ, float par8, float par9) + { + GL11.glPushMatrix(); + long var10 = (long) cart.entityId * 493286711L; + var10 = var10 * var10 * 4392167121L + var10 * 98761L; + float var12 = (((float) (var10 >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; + float var13 = (((float) (var10 >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; + float var14 = (((float) (var10 >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; + GL11.glTranslatef(var12, var13, var14); + double var15 = cart.lastTickPosX + (cart.posX - cart.lastTickPosX) * (double) par9; + double var17 = cart.lastTickPosY + (cart.posY - cart.lastTickPosY) * (double) par9; + double var19 = cart.lastTickPosZ + (cart.posZ - cart.lastTickPosZ) * (double) par9; + double var21 = 0.30000001192092896D; + Vec3 var23 = cart.func_70489_a(var15, var17, var19); + float var24 = cart.prevRotationPitch + (cart.rotationPitch - cart.prevRotationPitch) * par9; + + if (var23 != null) + { + Vec3 var25 = cart.func_70495_a(var15, var17, var19, var21); + Vec3 var26 = cart.func_70495_a(var15, var17, var19, -var21); + + if (var25 == null) + { + var25 = var23; + } + + if (var26 == null) + { + var26 = var23; + } + + posX += var23.xCoord - var15; + posY += (var25.yCoord + var26.yCoord) / 2.0D - var17; + posZ += var23.zCoord - var19; + Vec3 var27 = var26.addVector(-var25.xCoord, -var25.yCoord, -var25.zCoord); + + if (var27.lengthVector() != 0.0D) + { + var27 = var27.normalize(); + par8 = (float) (Math.atan2(var27.zCoord, var27.xCoord) * 180.0D / Math.PI); + var24 = (float) (Math.atan(var27.yCoord) * 73.0D); + } + } + + GL11.glTranslatef((float) posX, (float) posY + 0.3125f, (float) posZ); + GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-var24, 0.0F, 0.0F, 1.0F); + float var28 = (float) cart.func_70496_j() - par9; + float var30 = (float) cart.getDamage() - par9; + + if (var30 < 0.0F) + { + var30 = 0.0F; + } + + if (var28 > 0.0F) + { + GL11.glRotatef(MathHelper.sin(var28) * var28 * var30 / 10.0F * (float) cart.func_70493_k(), 1.0F, 0.0F, 0.0F); + } + + if (cart.getCartType() != 0) + { + //this.loadTexture("/terrain.png"); + float var29 = 0.75F; + GL11.glScalef(var29, var29, var29); + + if (cart.getCartType() == 1) + { + GL11.glTranslatef(0.0F, 0.5F, 0.0F); + renderblocks.renderBlockAsItem(Block.chest, 0, cart.getBrightness(par9)); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.5F, 0.0F, -0.5F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + else if (cart.getCartType() == 2) + { + GL11.glTranslatef(0.0F, 0.3125F, 0.0F); + renderblocks.renderBlockAsItem(Block.furnaceIdle, 0, cart.getBrightness(par9)); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.3125F, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + //GL11.glScalef(1.0F / var29, 1.0F / var29, 1.0F / var29); + } + + //this.loadTexture("/tinkertextures/entity/pullcart.png"); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + this.modelCart.render(cart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render> 16 & 255) / 255.0F; + f11 = (float) (k >> 8 & 255) / 255.0F; + f6 = (float) (k & 255) / 255.0F; + GL11.glColor4f(f12, f11, f6, 1.0F); + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, j); + } + } + else + { + j = itemstack.getItem().getColorFromItemStack(itemstack, 0); + f6 = (float) (j >> 16 & 255) / 255.0F; + f12 = (float) (j >> 8 & 255) / 255.0F; + f11 = (float) (j & 255) / 255.0F; + GL11.glColor4f(f6, f12, f11, 1.0F); + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, 0); + } + + /*this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, 0); + + if (itemstack.getItem().requiresMultipleRenderPasses()) + { + for (int x = 1; x < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); x++) + { + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, x); + } + }*/ + + GL11.glPopMatrix(); + } + } + + protected void func_82422_c () + { + GL11.glTranslatef(0.0F, 0.1875F, 0.0F); + } + + @Override + protected ResourceLocation func_110775_a(Entity par1Entity) + { + return texture; + } + + static final ResourceLocation texture = new ResourceLocation("assets/tinker/textures/mob/crystalguardamber.png"); +} diff --git a/tconstruct/client/entity/CrystalModelSmall.java b/tconstruct/client/entity/CrystalModelSmall.java new file mode 100644 index 00000000..b501ef9b --- /dev/null +++ b/tconstruct/client/entity/CrystalModelSmall.java @@ -0,0 +1,52 @@ +package tconstruct.client.entity; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class CrystalModelSmall extends ModelBase +{ + /*ModelRenderer body; + ModelRendererTurbo top; + ModelRendererTurbo bottom; + + public CrystalModelSmall() + { + textureWidth = 32; + textureHeight = 32; + + body = new ModelRenderer(this, 0, 8); + body.addBox(-2F, 0F, -2F, 4, 6, 4); + body.setRotationPoint(0F, 0F, 0F); + setRotation(body, 0, 0.7853982F, 0); + top = new ModelRendererTurbo(this, 0, 0, 32, 32); + top.addCone(0, 0, 0, 2.8F, 4, 4, 0, ModelRendererTurbo.MR_BOTTOM, 4, 8); + top.setRotationPoint(0F, -4F, 0F); + setRotation(top, 0F, 0F, 0F); + bottom = new ModelRendererTurbo(this, 0, 18, 32, 32); + top.addCone(0, 10, 0, 2.8F, 4, 4, 0, ModelRendererTurbo.MR_TOP, 4, 8); + bottom.setRotationPoint(0F, 6F, 0F); + //setRotation(bottom, 0F, 0F, 0F); + } + + public void render (Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + body.render(f5); + top.render(f5); + bottom.render(f5); + } + + private void setRotation (ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles (float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + }*/ +} diff --git a/tconstruct/client/entity/CrystalRender.java b/tconstruct/client/entity/CrystalRender.java new file mode 100644 index 00000000..25a34889 --- /dev/null +++ b/tconstruct/client/entity/CrystalRender.java @@ -0,0 +1,73 @@ +package tconstruct.client.entity; + +import tconstruct.entity.Crystal; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class CrystalRender extends RenderLiving +{ + /** The creeper model. */ + private ModelBase creeperModel = new CrystalModelSmall(); + + public CrystalRender() + { + super(new CrystalModelSmall(), 0.5F); + } + + /** + * A method used to render a creeper's powered form as a pass model. + */ + protected int renderCreeperPassModel (Crystal par1EntityCreeper, int par2, float par3) + { + + return -1; + } + + protected int func_77061_b (Crystal par1EntityCreeper, int par2, float par3) + { + return -1; + } + + /** + * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args: + * entityLiving, partialTickTime + */ + /*protected void preRenderCallback(EntityLiving par1EntityLiving, float par2) + { + this.updateCreeperScale((Skyla)par1EntityLiving, par2); + }*/ + + /** + * Returns an ARGB int color back. Args: entityLiving, lightBrightness, partialTickTime + */ + protected int getColorMultiplier (EntityLiving par1EntityLiving, float par2, float par3) + { + return super.getColorMultiplier(par1EntityLiving, par2, par3); + } + + /** + * Queries whether should render the specified pass or not. + */ + protected int shouldRenderPass (EntityLiving par1EntityLiving, int par2, float par3) + { + return this.renderCreeperPassModel((Crystal) par1EntityLiving, par2, par3); + } + + protected int inheritRenderPass (EntityLiving par1EntityLiving, int par2, float par3) + { + return this.func_77061_b((Crystal) par1EntityLiving, par2, par3); + } + + protected ResourceLocation func_110775_a(Entity par1Entity) + { + return texture; + } + + static final ResourceLocation texture = new ResourceLocation("assets/tinker/textures/mob/crystalwater.png"); +} diff --git a/tconstruct/client/entity/FancyItemRender.java b/tconstruct/client/entity/FancyItemRender.java new file mode 100644 index 00000000..0bdcab06 --- /dev/null +++ b/tconstruct/client/entity/FancyItemRender.java @@ -0,0 +1,636 @@ +package tconstruct.client.entity; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class FancyItemRender extends Render +{ + private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private RenderBlocks itemRenderBlocks = new RenderBlocks(); + + /** The RNG used in RenderItem (for bobbing itemstacks on the ground) */ + private Random random = new Random(); + public boolean renderWithColor = true; + + /** Defines the zLevel of rendering of item on GUI. */ + public float zLevel; + public static boolean renderInFrame; + + public FancyItemRender() + { + this.shadowSize = 0.15F; + this.shadowOpaque = 0.75F; + } + + /** + * Renders the item + */ + public void doRenderItem (EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9) + { + this.func_110777_b(par1EntityItem); + this.random.setSeed(187L); + ItemStack itemstack = par1EntityItem.getEntityItem(); + + if (itemstack.getItem() != null) + { + GL11.glPushMatrix(); + float f2 = shouldBob() ? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F; + float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI); + byte b0 = getMiniBlockCount(itemstack); + + GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f4; + float f5; + float f6; + int i; + + Block block = null; + if (itemstack.itemID < Block.blocksList.length) + { + block = Block.blocksList[itemstack.itemID]; + } + + if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, renderBlocks)) + { + ; + } + else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType())) + { + GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); + + if (renderInFrame) + { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glTranslatef(0.0F, 0.05F, 0.0F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + + float f7 = 0.25F; + int j = block.getRenderType(); + + if (j == 1 || j == 19 || j == 12 || j == 2) + { + f7 = 0.5F; + } + + GL11.glScalef(f7, f7, f7); + + for (i = 0; i < b0; ++i) + { + GL11.glPushMatrix(); + + if (i > 0) + { + f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + GL11.glTranslatef(f5, f4, f6); + } + + f5 = 1.0F; + this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5); + GL11.glPopMatrix(); + } + } + else + { + float f8; + + if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses()) + { + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) + { + this.random.setSeed(187L); + Icon icon = itemstack.getItem().getIcon(itemstack, k); + f8 = 1.0F; + + if (this.renderWithColor) + { + i = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, k); + f5 = (float) (i >> 16 & 255) / 255.0F; + f4 = (float) (i >> 8 & 255) / 255.0F; + f6 = (float) (i & 255) / 255.0F; + GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F); + this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k); + } + else + { + this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F, k); + } + } + } + else + { + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + Icon icon1 = itemstack.getIconIndex(); + + if (this.renderWithColor) + { + int l = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, 0); + f8 = (float) (l >> 16 & 255) / 255.0F; + float f9 = (float) (l >> 8 & 255) / 255.0F; + f5 = (float) (l & 255) / 255.0F; + f4 = 1.0F; + this.renderDroppedItem(par1EntityItem, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4); + } + else + { + this.renderDroppedItem(par1EntityItem, icon1, b0, par9, 1.0F, 1.0F, 1.0F); + } + } + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation func_110796_a (EntityItem par1EntityItem) + { + return this.renderManager.renderEngine.func_130087_a(par1EntityItem.getEntityItem().getItemSpriteNumber()); + } + + /** + * Renders a dropped item + */ + private void renderDroppedItem (EntityItem par1EntityItem, Icon par2Icon, int par3, float par4, float par5, float par6, float par7) + { + renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0); + } + + private void renderDroppedItem (EntityItem par1EntityItem, Icon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass) + { + Tessellator tessellator = Tessellator.instance; + + if (par2Icon == null) + { + TextureManager texturemanager = Minecraft.getMinecraft().func_110434_K(); + ResourceLocation resourcelocation = texturemanager.func_130087_a(par1EntityItem.getEntityItem().getItemSpriteNumber()); + par2Icon = ((TextureMap) texturemanager.func_110581_b(resourcelocation)).func_110572_b("missingno"); + } + + float f4 = ((Icon) par2Icon).getMinU(); + float f5 = ((Icon) par2Icon).getMaxU(); + float f6 = ((Icon) par2Icon).getMinV(); + float f7 = ((Icon) par2Icon).getMaxV(); + float f8 = 1.0F; + float f9 = 0.5F; + float f10 = 0.25F; + float f11; + + GL11.glPushMatrix(); + + if (renderInFrame) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + else + { + GL11.glRotatef((((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); + } + + float f12 = 0.0625F; + f11 = 0.021875F; + ItemStack itemstack = par1EntityItem.getEntityItem(); + int j = itemstack.stackSize; + byte b0 = getMiniItemCount(itemstack); + + GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F)); + + for (int k = 0; k < b0; ++k) + { + // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... + if (k > 0 && shouldSpreadItems()) + { + float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + GL11.glTranslatef(x, y, f12 + f11); + } + else + { + GL11.glTranslatef(0f, 0f, f12 + f11); + } + + if (itemstack.getItemSpriteNumber() == 0) + { + this.func_110776_a(TextureMap.field_110575_b); + } + else + { + this.func_110776_a(TextureMap.field_110576_c); + } + + GL11.glColor4f(par5, par6, par7, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((Icon) par2Icon).getOriginX(), ((Icon) par2Icon).getOriginY(), f12); + + if (itemstack.hasEffect(pass)) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + this.renderManager.renderEngine.func_110577_a(field_110798_h); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f13 = 0.76F; + GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f14 = 0.125F; + GL11.glScalef(f14, f14, f14); + float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f15, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f14, f14, f14); + f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f15, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + GL11.glPopMatrix(); + + } + + /** + * Renders the item's icon or block into the UI at the specified position. + */ + public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false); + } + + public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect) + { + int k = par3ItemStack.itemID; + int l = par3ItemStack.getItemDamage(); + Object object = par3ItemStack.getIconIndex(); + float f; + int i1; + float f1; + float f2; + + Block block = (k < Block.blocksList.length ? Block.blocksList[k] : null); + if (par3ItemStack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[k].getRenderType())) + { + par2TextureManager.func_110577_a(TextureMap.field_110575_b); + GL11.glPushMatrix(); + GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel); + GL11.glScalef(10.0F, 10.0F, 10.0F); + GL11.glTranslatef(1.0F, 0.5F, 1.0F); + GL11.glScalef(1.0F, 1.0F, -1.0F); + GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); + f = (float) (i1 >> 16 & 255) / 255.0F; + f1 = (float) (i1 >> 8 & 255) / 255.0F; + f2 = (float) (i1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f, f1, f2, 1.0F); + } + + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + this.itemRenderBlocks.useInventoryTint = this.renderWithColor; + this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F); + this.itemRenderBlocks.useInventoryTint = true; + GL11.glPopMatrix(); + } + else if (Item.itemsList[k].requiresMultipleRenderPasses()) + { + GL11.glDisable(GL11.GL_LIGHTING); + + for (int j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1) + { + par2TextureManager.func_110577_a(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.field_110575_b : TextureMap.field_110576_c); + Icon icon = Item.itemsList[k].getIcon(par3ItemStack, j1); + int k1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, j1); + f1 = (float) (k1 >> 16 & 255) / 255.0F; + f2 = (float) (k1 >> 8 & 255) / 255.0F; + float f3 = (float) (k1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f1, f2, f3, 1.0F); + } + + this.renderIcon(par4, par5, icon, 16, 16); + + if (par3ItemStack.hasEffect(j1)) + { + renderEffect(par2TextureManager, par4, par5); + } + } + + GL11.glEnable(GL11.GL_LIGHTING); + } + else + { + GL11.glDisable(GL11.GL_LIGHTING); + ResourceLocation resourcelocation = par2TextureManager.func_130087_a(par3ItemStack.getItemSpriteNumber()); + par2TextureManager.func_110577_a(resourcelocation); + + if (object == null) + { + object = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(resourcelocation)).func_110572_b("missingno"); + } + + i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); + f = (float) (i1 >> 16 & 255) / 255.0F; + f1 = (float) (i1 >> 8 & 255) / 255.0F; + f2 = (float) (i1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f, f1, f2, 1.0F); + } + + this.renderIcon(par4, par5, (Icon) object, 16, 16); + GL11.glEnable(GL11.GL_LIGHTING); + + if (par3ItemStack.hasEffect(0)) + { + renderEffect(par2TextureManager, par4, par5); + } + } + + GL11.glEnable(GL11.GL_CULL_FACE); + } + + private void renderEffect (TextureManager manager, int x, int y) + { + GL11.glDepthFunc(GL11.GL_GREATER); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + manager.func_110577_a(field_110798_h); + this.zLevel -= 50.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + this.zLevel += 50.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + /** + * Render the item's icon or block into the GUI, including the glint effect. + */ + public void renderItemAndEffectIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + if (par3ItemStack != null) + { + if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5)) + { + this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true); + } + + /* Modders must handle this themselves if they use custom renderers! + if (par3ItemStack.hasEffect()) + { + GL11.glDepthFunc(GL11.GL_GREATER); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + par2TextureManager.func_110577_a(field_110798_h); + this.zLevel -= 50.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + this.zLevel += 50.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + */ + } + } + + private void renderGlint (int par1, int par2, int par3, int par4, int par5) + { + for (int j1 = 0; j1 < 2; ++j1) + { + if (j1 == 0) + { + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + } + + if (j1 == 1) + { + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + } + + float f = 0.00390625F; + float f1 = 0.00390625F; + float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F; + float f3 = 0.0F; + Tessellator tessellator = Tessellator.instance; + float f4 = 4.0F; + + if (j1 == 1) + { + f4 = -1.0F; + } + + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); + tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f), + (double) ((f3 + (float) par5) * f1)); + tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.draw(); + } + } + + /** + * Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the + * specified position. + */ + public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String) null); + } + + public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str) + { + if (par3ItemStack != null) + { + if (par3ItemStack.stackSize > 1 || par6Str != null) + { + String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + if (par3ItemStack.isItemDamaged()) + { + int k = (int) Math.round(13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage()); + int l = (int) Math.round(255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage()); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + Tessellator tessellator = Tessellator.instance; + int i1 = 255 - l << 16 | l << 8; + int j1 = (255 - l) / 4 << 16 | 16128; + this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); + this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1); + this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + } + + /** + * Adds a quad to the tesselator at the specified position with the set width and height and color. Args: + * tessellator, x, y, width, height, color + */ + private void renderQuad (Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6) + { + par1Tessellator.startDrawingQuads(); + par1Tessellator.setColorOpaque_I(par6); + par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + 0), 0.0D); + par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + par5), 0.0D); + par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D); + par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + 0), 0.0D); + par1Tessellator.draw(); + } + + public void renderIcon (int par1, int par2, Icon par3Icon, int par4, int par5) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV()); + tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV()); + tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV()); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); + tessellator.draw(); + } + + protected ResourceLocation func_110775_a (Entity par1Entity) + { + return this.func_110796_a((EntityItem) par1Entity); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render 1) + ret = 2; + if (stack.stackSize > 5) + ret = 3; + if (stack.stackSize > 20) + ret = 4; + if (stack.stackSize > 40) + ret = 5; + return ret; + } + + /** + * Allows for a subclass to override how many rendered items appear in a + * "mini item 3d stack" + * @param stack + * @return + */ + public byte getMiniItemCount (ItemStack stack) + { + byte ret = 1; + if (stack.stackSize > 1) + ret = 2; + if (stack.stackSize > 15) + ret = 3; + if (stack.stackSize > 31) + ret = 4; + return ret; + } +} diff --git a/tconstruct/client/entity/GolemBaseModel.java b/tconstruct/client/entity/GolemBaseModel.java new file mode 100644 index 00000000..1ee9694c --- /dev/null +++ b/tconstruct/client/entity/GolemBaseModel.java @@ -0,0 +1,79 @@ +package tconstruct.client.entity; + +import net.minecraft.client.model.ModelPig; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +public class GolemBaseModel extends ModelPig +{ + ModelRenderer rightArm; + ModelRenderer leftArm; + + public GolemBaseModel() + { + float f = 0.0F; + float f1 = 0.0F; + head = new ModelRenderer(this, 0, 0); + head.addBox(-4F, -8F, -4F, 8, 8, 8, f); + head.setRotationPoint(0.0F, 0.0F + f1, 0.0F); + head.showModel = false; + body = new ModelRenderer(this, 16, 16); + body.addBox(-4F, 0.0F, -2F, 8, 12, 4, f); + body.setRotationPoint(0.0F, 0.0F + f1, 0.0F); + body.showModel = false; + rightArm = new ModelRenderer(this, 40, 16); + rightArm.addBox(-3F, -2F, -2F, 4, 12, 4, f); + rightArm.setRotationPoint(-5F, 2.0F + f1, 0.0F); + leftArm = new ModelRenderer(this, 40, 16); + leftArm.mirror = true; + leftArm.addBox(-1F, -2F, -2F, 4, 12, 4, f); + leftArm.setRotationPoint(5F, 2.0F + f1, 0.0F); + leg3 = new ModelRenderer(this, 0, 16); + leg3.addBox(-2F, 0.0F, -2F, 4, 12, 4, f); + leg3.setRotationPoint(-2F, 12F + f1, 0.0F); + leg4 = new ModelRenderer(this, 0, 16); + leg4.mirror = true; + leg4.addBox(-2F, 0.0F, -2F, 4, 12, 4, f); + leg4.setRotationPoint(2.0F, 12F + f1, 0.0F); + rightArm = new ModelRenderer(this, 40, 16); + rightArm.addBox(-1F, -2F, -1F, 2, 12, 2, f); + rightArm.setRotationPoint(-5F, 2.0F, 0.0F); + rightArm.showModel = false; + leftArm = new ModelRenderer(this, 40, 16); + leftArm.mirror = true; + leftArm.addBox(-1F, -2F, -1F, 2, 12, 2, f); + leftArm.setRotationPoint(5F, 2.0F, 0.0F); + leftArm.showModel = false; + leg3 = new ModelRenderer(this, 0, 16); + leg3.addBox(-1F, 0.0F, -1F, 2, 12, 2, f); + leg3.setRotationPoint(-2F, 12F, 0.0F); + leg3.showModel = false; + leg4 = new ModelRenderer(this, 0, 16); + leg4.mirror = true; + leg4.addBox(-1F, 0.0F, -1F, 2, 12, 2, f); + leg4.setRotationPoint(2.0F, 12F, 0.0F); + leg4.showModel = false; + leg1.showModel = leg2.showModel = false; + } + + @Override + public void setRotationAngles (float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + float f6 = 0.0F; + float f7 = 0.0F; + rightArm.rotateAngleZ = 0.0F; + leftArm.rotateAngleZ = 0.0F; + rightArm.rotateAngleY = -(0.1F - f6 * 0.6F) + head.rotateAngleY; + leftArm.rotateAngleY = (0.1F - f6 * 0.6F) + head.rotateAngleY + 0.4F; + rightArm.rotateAngleX = -1.570796F + head.rotateAngleX; + leftArm.rotateAngleX = -1.570796F + head.rotateAngleX; + rightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + leftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + rightArm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F; + leftArm.rotateAngleZ -= MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F; + rightArm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F; + leftArm.rotateAngleX -= MathHelper.sin(f2 * 0.067F) * 0.05F; + } +} diff --git a/tconstruct/client/entity/MiniGardyRender.java b/tconstruct/client/entity/MiniGardyRender.java new file mode 100644 index 00000000..a0e57f05 --- /dev/null +++ b/tconstruct/client/entity/MiniGardyRender.java @@ -0,0 +1,186 @@ +package tconstruct.client.entity; + +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class MiniGardyRender extends RenderLiving +{ + public MiniGardyRender() + { + super(new ModelMiniGardy(), 0.5F); + } + + @Override + protected void renderEquippedItems (EntityLivingBase par1EntityLiving, float par2) + { + float f1 = 1.0F; + GL11.glColor3f(f1, f1, f1); + super.renderEquippedItems(par1EntityLiving, par2); + ItemStack heldItem = par1EntityLiving.getHeldItem(); + ItemStack helmetItem = par1EntityLiving.getCurrentItemOrArmor(4); + float f2; + + ModelMiniGardy model = (ModelMiniGardy) this.mainModel; + if (helmetItem != null) + { + GL11.glPushMatrix(); + model.head.postRender(0.0625F); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(helmetItem, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, helmetItem, BLOCK_3D)); + + if (helmetItem.getItem() instanceof ItemBlock) + { + if (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[helmetItem.itemID].getRenderType())) + { + f2 = 0.625F; + GL11.glTranslatef(0.0F, -0.25F, 0.0F); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f2, -f2, -f2); + } + + this.renderManager.itemRenderer.renderItem(par1EntityLiving, helmetItem, 0); + } + else if (helmetItem.getItem().itemID == Item.skull.itemID) + { + f2 = 1.0625F; + GL11.glScalef(f2, -f2, -f2); + String s = ""; + + if (helmetItem.hasTagCompound() && helmetItem.getTagCompound().hasKey("SkullOwner")) + { + s = helmetItem.getTagCompound().getString("SkullOwner"); + } + + TileEntitySkullRenderer.skullRenderer.func_82393_a(-0.5F, 0.0F, -0.5F, 1, 180.0F, helmetItem.getItemDamage(), s); + } + + GL11.glPopMatrix(); + } + + if (heldItem != null) + { + GL11.glPushMatrix(); + + //if (this.mainModel.isChild) + { + f2 = 0.5F; + GL11.glTranslatef(0.0F, 0.75F, 0.0F); + GL11.glRotatef(-10.0F, 0F, 0.0F, 1.0F); + GL11.glScalef(f2, f2, f2); + } + + model.torso.postRender(0.0625F); + model.rightArm.postRender(0.0625F); + model.rightHand.postRender(0.0625F); + GL11.glTranslatef(-0.125F, 1F, 0F); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(heldItem, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, heldItem, BLOCK_3D)); + + if (heldItem.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[heldItem.itemID].getRenderType()))) + { + f2 = 0.5F; + GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); + f2 *= 0.75F; + GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(-f2, -f2, f2); + } + else if (heldItem.itemID == Item.bow.itemID) + { + f2 = 0.625F; + GL11.glTranslatef(-0.175F, 0.125F, 0.3125F); + GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f2, -f2, f2); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else + //if (Item.itemsList[heldItem.itemID].isFull3D()) + { + f2 = 0.625F; + + if (Item.itemsList[heldItem.itemID].shouldRotateAroundWhenRendering()) + { + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, -0.125F, 0.0F); + } + + this.translateItem(); + GL11.glScalef(f2, -f2, f2); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + /*else + { + f2 = 0.375F; + GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); + GL11.glScalef(f2, f2, f2); + GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); + }*/ + + float f6; + float f11; + int j; + float f12; + + if (heldItem.getItem().requiresMultipleRenderPasses()) + { + for (j = 0; j < heldItem.getItem().getRenderPasses(heldItem.getItemDamage()); j++) + { + int k = heldItem.getItem().getColorFromItemStack(heldItem, j); + f12 = (float) (k >> 16 & 255) / 255.0F; + f11 = (float) (k >> 8 & 255) / 255.0F; + f6 = (float) (k & 255) / 255.0F; + GL11.glColor4f(f12, f11, f6, 1.0F); + this.renderManager.itemRenderer.renderItem(par1EntityLiving, heldItem, j); + } + } + else + { + j = heldItem.getItem().getColorFromItemStack(heldItem, 0); + f6 = (float) (j >> 16 & 255) / 255.0F; + f12 = (float) (j >> 8 & 255) / 255.0F; + f11 = (float) (j & 255) / 255.0F; + GL11.glColor4f(f6, f12, f11, 1.0F); + this.renderManager.itemRenderer.renderItem(par1EntityLiving, heldItem, 0); + } + + GL11.glPopMatrix(); + } + } + + protected void translateItem () + { + GL11.glTranslatef(0.0F, 0.1875F, 0.0F); + } + + @Override + protected ResourceLocation func_110775_a(Entity par1Entity) + { + return texture; + } + + static final ResourceLocation texture = new ResourceLocation("assets/tinker/textures/mob/googirl.png"); +} diff --git a/tconstruct/client/entity/ModelBoxDegrees.java b/tconstruct/client/entity/ModelBoxDegrees.java new file mode 100644 index 00000000..423756c4 --- /dev/null +++ b/tconstruct/client/entity/ModelBoxDegrees.java @@ -0,0 +1,120 @@ +package tconstruct.client.entity; + +import net.minecraft.client.model.PositionTextureVertex; +import net.minecraft.client.model.TexturedQuad; +import net.minecraft.client.renderer.Tessellator; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ModelBoxDegrees +{ + /** + * The (x,y,z) vertex positions and (u,v) texture coordinates for each of the 8 points on a cube + */ + private PositionTextureVertex[] vertexPositions; + + /** An array of 6 TexturedQuads, one for each face of a cube */ + private TexturedQuad[] quadList; + + /** X vertex coordinate of lower box corner */ + public final float posX1; + + /** Y vertex coordinate of lower box corner */ + public final float posY1; + + /** Z vertex coordinate of lower box corner */ + public final float posZ1; + + /** X vertex coordinate of upper box corner */ + public final float posX2; + + /** Y vertex coordinate of upper box corner */ + public final float posY2; + + /** Z vertex coordinate of upper box corner */ + public final float posZ2; + public String field_78247_g; + + public ModelBoxDegrees(ModelRendererDegrees par1ModelRenderer, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10) + { + this.posX1 = par4; + this.posY1 = par5; + this.posZ1 = par6; + this.posX2 = par4 + (float) par7; + this.posY2 = par5 + (float) par8; + this.posZ2 = par6 + (float) par9; + this.vertexPositions = new PositionTextureVertex[8]; + this.quadList = new TexturedQuad[6]; + float f4 = par4 + (float) par7; + float f5 = par5 + (float) par8; + float f6 = par6 + (float) par9; + par4 -= par10; + par5 -= par10; + par6 -= par10; + f4 += par10; + f5 += par10; + f6 += par10; + + if (par1ModelRenderer.mirror) + { + float f7 = f4; + f4 = par4; + par4 = f7; + } + + PositionTextureVertex positiontexturevertex = new PositionTextureVertex(par4, par5, par6, 0.0F, 0.0F); + PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f4, par5, par6, 0.0F, 8.0F); + PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(f4, f5, par6, 8.0F, 8.0F); + PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(par4, f5, par6, 8.0F, 0.0F); + PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(par4, par5, f6, 0.0F, 0.0F); + PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f4, par5, f6, 0.0F, 8.0F); + PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8.0F, 8.0F); + PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(par4, f5, f6, 8.0F, 0.0F); + this.vertexPositions[0] = positiontexturevertex; + this.vertexPositions[1] = positiontexturevertex1; + this.vertexPositions[2] = positiontexturevertex2; + this.vertexPositions[3] = positiontexturevertex3; + this.vertexPositions[4] = positiontexturevertex4; + this.vertexPositions[5] = positiontexturevertex5; + this.vertexPositions[6] = positiontexturevertex6; + this.vertexPositions[7] = positiontexturevertex7; + this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex5, positiontexturevertex1, positiontexturevertex2, positiontexturevertex6 }, par2 + par9 + par7, par3 + + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex, positiontexturevertex4, positiontexturevertex7, positiontexturevertex3 }, par2, par3 + par9, par2 + + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex5, positiontexturevertex4, positiontexturevertex, positiontexturevertex1 }, par2 + par9, par3, par2 + + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex2, positiontexturevertex3, positiontexturevertex7, positiontexturevertex6 }, par2 + par9 + par7, par3 + + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex1, positiontexturevertex, positiontexturevertex3, positiontexturevertex2 }, par2 + par9, par3 + par9, + par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex4, positiontexturevertex5, positiontexturevertex6, positiontexturevertex7 }, par2 + par9 + par7 + par9, + par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + + if (par1ModelRenderer.mirror) + { + for (int j1 = 0; j1 < this.quadList.length; ++j1) + { + this.quadList[j1].flipFace(); + } + } + } + + /** + * Draw the six sided box defined by this ModelBox + */ + @SideOnly(Side.CLIENT) + public void render (Tessellator par1Tessellator, float par2) + { + for (int i = 0; i < this.quadList.length; ++i) + { + this.quadList[i].draw(par1Tessellator, par2); + } + } + + public ModelBoxDegrees func_78244_a (String par1Str) + { + this.field_78247_g = par1Str; + return this; + } +} diff --git a/tconstruct/client/entity/ModelMiniGardy.java b/tconstruct/client/entity/ModelMiniGardy.java new file mode 100644 index 00000000..12b770b6 --- /dev/null +++ b/tconstruct/client/entity/ModelMiniGardy.java @@ -0,0 +1,208 @@ +package tconstruct.client.entity; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +public class ModelMiniGardy extends ModelBase +{ + ModelRendererDegrees body; + ModelRendererDegrees torso; + ModelRendererDegrees head; + ModelRendererDegrees rightArm; + ModelRendererDegrees rightHand; + ModelRendererDegrees leftArm; + ModelRendererDegrees leftHand; + ModelRendererDegrees hairTop; + ModelRendererDegrees hairRight; + ModelRendererDegrees lockLeft; + ModelRendererDegrees lockRight; + ModelRendererDegrees hairLeft; + ModelRendererDegrees hairBack; + ModelRendererDegrees hairFront; + ModelRendererDegrees hairTopFront; + ModelRendererDegrees hairTopBack; + ModelRendererDegrees lockInsideRight; + ModelRendererDegrees lockInsideLeft; + + public ModelMiniGardy() + { + body = new ModelRendererDegrees(this, 0, 0); + body.addBox(-3F, 0F, -3F, 6, 6, 6); + body.setRotationPoint(0F, 18F, 0F); + body.mirror = true; + setRotation(body, 0F, 0F, 0F); + + torso = new ModelRendererDegrees(this, 16, 12); + torso.addBox(-1F, -5F, -1F, 2, 5, 2); + torso.setRotationPoint(0F, 0F, 0F); + torso.mirror = true; + setRotation(torso, 0F, 0F, 0F); + body.addChild(torso); + + rightArm = new ModelRendererDegrees(this, 24, 0); + rightArm.addBox(-1F, -1F, -1F, 2, 4, 2); + rightArm.setRotationPoint(-2F, -3F, 0F); + rightArm.mirror = true; + setRotation(rightArm, 0F, 0F, 15F);//convertDegrees(30.0f));//0.2617994F); + torso.addChild(rightArm); + + rightHand = new ModelRendererDegrees(this, 24, 6); + rightHand.addBox(-1F, 0F, -2F, 2, 4, 2); + rightHand.setRotationPoint(0F, 3F, 1F); + rightHand.setTextureSize(64, 32); + rightHand.mirror = true; + setRotation(rightHand, 0F, 0F, 0F); + rightArm.addChild(rightHand); + + leftArm = new ModelRendererDegrees(this, 32, 0); + leftArm.addBox(-1F, -1F, -1F, 2, 4, 2); + leftArm.setRotationPoint(2F, -3F, 0F); + leftArm.mirror = true; + setRotation(leftArm, 0F, 0F, -15F); + torso.addChild(leftArm); + + leftHand = new ModelRendererDegrees(this, 32, 6); + leftHand.addBox(-1F, 0F, -2F, 2, 4, 2); + leftHand.setRotationPoint(0F, 3F, 1F); + leftHand.mirror = true; + setRotation(leftHand, 0F, 0F, 0F); + leftArm.addChild(leftHand); + + //Head + head = new ModelRendererDegrees(this, 0, 12); + head.addBox(-2F, -4F, -2F, 4, 4, 4); + head.setRotationPoint(0F, -5F, 0F); + head.mirror = true; + setRotation(head, 0F, 0F, 0F); + torso.addChild(head); + + hairTop = new ModelRendererDegrees(this, 40, 2); + hairTop.addBox(-3F, 0F, -2F, 6, 1, 4); + hairTop.setRotationPoint(0F, -5F, 0F); + hairTop.mirror = true; + setRotation(hairTop, 0F, 0F, 0F); + head.addChild(hairTop); + + hairRight = new ModelRendererDegrees(this, 40, 7); + hairRight.addBox(0F, 0F, 0F, 2, 5, 4); + hairRight.setRotationPoint(-3F, -4F, -1F); + hairRight.mirror = true; + setRotation(hairRight, 0F, 0F, 0F); + head.addChild(hairRight); + + lockLeft = new ModelRendererDegrees(this, 46, 19); + lockLeft.addBox(0F, 0F, 0F, 1, 2, 2); + lockLeft.setRotationPoint(2F, -1F, -3F); + lockLeft.mirror = true; + setRotation(lockLeft, 0F, 0F, 0F); + head.addChild(lockLeft); + + lockRight = new ModelRendererDegrees(this, 40, 19); + lockRight.addBox(-1F, 0F, 0F, 1, 2, 2); + lockRight.setRotationPoint(-2F, -1F, -3F); + lockRight.mirror = true; + setRotation(lockRight, 0F, 0F, 0F); + head.addChild(lockRight); + + hairLeft = new ModelRendererDegrees(this, 52, 7); + hairLeft.addBox(0F, 0F, 0F, 2, 5, 4); + hairLeft.setRotationPoint(1F, -4F, -1F); + hairLeft.mirror = true; + setRotation(hairLeft, 0F, 0F, 0F); + head.addChild(hairLeft); + + hairBack = new ModelRendererDegrees(this, 56, 16); + hairBack.addBox(-1F, 0F, 0F, 2, 4, 1); + hairBack.setRotationPoint(0F, -4F, 2F); + hairBack.mirror = true; + setRotation(hairBack, 0F, 0F, 0F); + head.addChild(hairBack); + + hairFront = new ModelRendererDegrees(this, 40, 16); + hairFront.addBox(0F, 0F, 0F, 6, 1, 2); + hairFront.setRotationPoint(-3F, -4F, -3F); + hairFront.mirror = true; + setRotation(hairFront, 0F, 0F, 0F); + head.addChild(hairFront); + + hairTopFront = new ModelRendererDegrees(this, 50, 0); + hairTopFront.addBox(0F, 0F, 0F, 4, 1, 1); + hairTopFront.setRotationPoint(-2F, -5F, -3F); + hairTopFront.mirror = true; + setRotation(hairTopFront, 0F, 0F, 0F); + head.addChild(hairTopFront); + + hairTopBack = new ModelRendererDegrees(this, 40, 0); + hairTopBack.addBox(0F, 0F, 0F, 4, 1, 1); + hairTopBack.setRotationPoint(-2F, -5F, 2F); + hairTopBack.mirror = true; + setRotation(hairTopBack, 0F, 0F, 0F); + head.addChild(hairTopBack); + + lockInsideRight = new ModelRendererDegrees(this, 40, 23); + lockInsideRight.addBox(0F, 0F, 0F, 1, 1, 2); + lockInsideRight.setRotationPoint(-2F, 0F, -3F); + lockInsideRight.mirror = true; + setRotation(lockInsideRight, 0F, 0F, 0F); + head.addChild(lockInsideRight); + + lockInsideLeft = new ModelRendererDegrees(this, 46, 23); + lockInsideLeft.addBox(-1F, 0F, 0F, 1, 1, 2); + lockInsideLeft.setRotationPoint(2F, 0F, -3F); + lockInsideLeft.mirror = true; + setRotation(lockInsideLeft, 0F, 0F, 0F); + head.addChild(lockInsideLeft); + } + + @Override + public void render (Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + body.render(f5); + } + + private void setRotation (ModelRendererDegrees model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + private float convertDegrees (float f) + { + return f * ((float) Math.PI / 180F); + } + + private float convertRadians (float f) + { + return f * (180F / (float) Math.PI); + } + + @Override + public void setRotationAngles (float limbSwing, float limbDelta, float ticksExisted, float rotation, float rotationDelta, float par6, Entity entity) + { + float bodyRotation = convertRadians(MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * limbDelta * 0.5F); + this.rightArm.rotateAngleX = bodyRotation; + this.leftArm.rotateAngleX = -bodyRotation; + this.torso.rotateAngleY = bodyRotation / 2; + this.head.rotateAngleY = rotation - bodyRotation / 2; + this.head.rotateAngleX = rotationDelta; + if (bodyRotation <= 0) + { + this.rightHand.rotateAngleX = bodyRotation; + } + if (-bodyRotation <= 0) + { + this.leftHand.rotateAngleX = -bodyRotation; + } + this.rightArm.rotateAngleZ = 15F; + this.leftArm.rotateAngleZ = -15F; + this.torso.rotationPointY = 0F; + this.rightArm.rotateAngleZ += convertRadians(MathHelper.cos(ticksExisted * 0.09F) * 0.05F + 0.05F); + this.leftArm.rotateAngleZ -= convertRadians(MathHelper.cos(ticksExisted * 0.09F) * 0.05F + 0.05F); + this.torso.rotationPointY += convertRadians(MathHelper.cos(ticksExisted * 0.09F) * 0.01F + 0.01F); + } + +} diff --git a/tconstruct/client/entity/ModelPullcart.java b/tconstruct/client/entity/ModelPullcart.java new file mode 100644 index 00000000..45769cf9 --- /dev/null +++ b/tconstruct/client/entity/ModelPullcart.java @@ -0,0 +1,281 @@ +package tconstruct.client.entity; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelPullcart extends ModelBase +{ + ModelRenderer BackPanel; + ModelRenderer FrontPanel; + ModelRenderer RightPanel; + ModelRenderer LeftPanel; + ModelRenderer BottomPanel; + ModelRenderer RightHandle; + ModelRenderer LeftHandle; + ModelRenderer RightSpokeUp; + ModelRenderer RightSpokeRight; + ModelRenderer RightSpokeDown; + ModelRenderer RightSpokeLeft; + ModelRenderer RightAxle; + ModelRenderer WheelRight1; + ModelRenderer WheelRight2; + ModelRenderer WheelRight3; + ModelRenderer WheelRight4; + ModelRenderer WheelRight5; + ModelRenderer WheelRight6; + ModelRenderer WheelRight7; + ModelRenderer WheelRight8; + ModelRenderer WheelRight9; + ModelRenderer WheelRight10; + ModelRenderer WheelRight11; + ModelRenderer WheelRight12; + ModelRenderer LeftSpokeRight; + ModelRenderer LeftSpokeLeft; + ModelRenderer LeftSpokeDown; + ModelRenderer LeftSpokeUp; + ModelRenderer LeftAxle; + ModelRenderer WheelLeft1; + ModelRenderer WheelLeft2; + ModelRenderer WheelLeft3; + ModelRenderer WheelLeft4; + ModelRenderer WheelLeft5; + ModelRenderer WheelLeft6; + ModelRenderer WheelLeft7; + ModelRenderer WheelLeft8; + ModelRenderer WheelLeft9; + ModelRenderer WheelLeft10; + ModelRenderer WheelLeft11; + ModelRenderer WheelLeft12; + + public ModelPullcart() + { + textureWidth = 128; + textureHeight = 64; + + BackPanel = new ModelRenderer(this, 0, 12); + BackPanel.addBox(-10F, 0F, 0F, 20, 10, 2); + BackPanel.setRotationPoint(0F, -8F, 8F); + setRotation(BackPanel, 0F, 0F, 0F); + FrontPanel = new ModelRenderer(this, 0, 0); + FrontPanel.addBox(-10F, 0F, 0F, 20, 10, 2); + FrontPanel.setRotationPoint(0F, -8F, -10F); + setRotation(FrontPanel, 0F, 0F, 0F); + RightPanel = new ModelRenderer(this, 0, 35); + RightPanel.addBox(0F, 0F, -10F, 2, 8, 20); + RightPanel.setRotationPoint(-12F, -6F, 0F); + setRotation(RightPanel, 0F, 0F, 0F); + LeftPanel = new ModelRenderer(this, 24, 15); + LeftPanel.addBox(0F, 0F, -10F, 2, 8, 20); + LeftPanel.setRotationPoint(10F, -6F, 0F); + setRotation(LeftPanel, 0F, 0F, 0F); + BottomPanel = new ModelRenderer(this, 40, 43); + BottomPanel.addBox(-12F, 0F, -10F, 24, 1, 20); + BottomPanel.setRotationPoint(0F, 2F, 0F); + setRotation(BottomPanel, 0F, 0F, 0F); + RightHandle = new ModelRenderer(this, 92, 33); + RightHandle.addBox(0F, 0F, 0F, 16, 2, 2); + RightHandle.setRotationPoint(-28F, 0F, -7F); + setRotation(RightHandle, 0F, 0F, 0F); + LeftHandle = new ModelRenderer(this, 92, 38); + LeftHandle.addBox(0F, 0F, 0F, 16, 2, 2); + LeftHandle.setRotationPoint(-28F, 0F, 5F); + setRotation(LeftHandle, 0F, 0F, 0F); + RightSpokeUp = new ModelRenderer(this, 99, 3); + RightSpokeUp.addBox(-2F, -8F, 0F, 4, 6, 1); + RightSpokeUp.setRotationPoint(0F, 3F, -11F); + setRotation(RightSpokeUp, 0F, 0F, 0F); + RightSpokeRight = new ModelRenderer(this, 112, 15); + RightSpokeRight.addBox(2F, -2F, 0F, 6, 4, 1); + RightSpokeRight.setRotationPoint(0F, 3F, -11F); + setRotation(RightSpokeRight, 0F, 0F, 0F); + RightSpokeDown = new ModelRenderer(this, 99, 25); + RightSpokeDown.addBox(-2F, 2F, 0F, 4, 6, 1); + RightSpokeDown.setRotationPoint(0F, 3F, -11F); + setRotation(RightSpokeDown, 0F, 0F, 0F); + RightSpokeLeft = new ModelRenderer(this, 82, 15); + RightSpokeLeft.addBox(-8F, -2F, 0F, 6, 4, 1); + RightSpokeLeft.setRotationPoint(0F, 3F, -11F); + setRotation(RightSpokeLeft, 0F, 0F, 0F); + RightAxle = new ModelRenderer(this, 98, 14); + RightAxle.addBox(-2F, -2F, 0F, 4, 4, 2); + RightAxle.setRotationPoint(0F, 3F, -12F); + setRotation(RightAxle, 0F, 0F, 0F); + WheelRight1 = new ModelRenderer(this, 110, 3); + WheelRight1.addBox(2F, -7F, 0F, 2, 2, 1); + WheelRight1.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight1, 0F, 0F, 0F); + WheelRight2 = new ModelRenderer(this, 117, 5); + WheelRight2.addBox(4F, -6F, 0F, 2, 2, 1); + WheelRight2.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight2, 0F, 0F, 0F); + WheelRight3 = new ModelRenderer(this, 122, 9); + WheelRight3.addBox(5F, -4F, 0F, 2, 2, 1); + WheelRight3.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight3, 0F, 0F, 0F); + WheelRight4 = new ModelRenderer(this, 122, 23); + WheelRight4.addBox(5F, 2F, 0F, 2, 2, 1); + WheelRight4.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight4, 0F, 0F, 0F); + WheelRight5 = new ModelRenderer(this, 117, 27); + WheelRight5.addBox(4F, 4F, 0F, 2, 2, 1); + WheelRight5.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight5, 0F, 0F, 0F); + WheelRight6 = new ModelRenderer(this, 110, 29); + WheelRight6.addBox(2F, 5F, 0F, 2, 2, 1); + WheelRight6.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight6, 0F, 0F, 0F); + WheelRight7 = new ModelRenderer(this, 92, 29); + WheelRight7.addBox(-4F, 5F, 0F, 2, 2, 1); + WheelRight7.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight7, 0F, 0F, 0F); + WheelRight8 = new ModelRenderer(this, 85, 27); + WheelRight8.addBox(-6F, 4F, 0F, 2, 2, 1); + WheelRight8.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight8, 0F, 0F, 0F); + WheelRight9 = new ModelRenderer(this, 80, 23); + WheelRight9.addBox(-7F, 2F, 0F, 2, 2, 1); + WheelRight9.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight9, 0F, 0F, 0F); + WheelRight10 = new ModelRenderer(this, 80, 9); + WheelRight10.addBox(-7F, -4F, 0F, 2, 2, 1); + WheelRight10.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight10, 0F, 0F, 0F); + WheelRight11 = new ModelRenderer(this, 85, 5); + WheelRight11.addBox(-6F, -6F, 0F, 2, 2, 1); + WheelRight11.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight11, 0F, 0F, 0F); + WheelRight12 = new ModelRenderer(this, 92, 3); + WheelRight12.addBox(-4F, -7F, 0F, 2, 2, 1); + WheelRight12.setRotationPoint(0F, 3F, -11F); + setRotation(WheelRight12, 0F, 0F, 0F); + LeftSpokeRight = new ModelRenderer(this, 82, 15); + LeftSpokeRight.addBox(-8F, -2F, 0F, 6, 4, 1); + LeftSpokeRight.setRotationPoint(0F, 3F, 10F); + setRotation(LeftSpokeRight, 0F, 0F, 0F); + LeftSpokeLeft = new ModelRenderer(this, 112, 15); + LeftSpokeLeft.addBox(2F, -2F, 0F, 6, 4, 1); + LeftSpokeLeft.setRotationPoint(0F, 3F, 10F); + setRotation(LeftSpokeLeft, 0F, 0F, 0F); + LeftSpokeDown = new ModelRenderer(this, 99, 25); + LeftSpokeDown.addBox(-2F, 2F, 0F, 4, 6, 1); + LeftSpokeDown.setRotationPoint(0F, 3F, 10F); + setRotation(LeftSpokeDown, 0F, 0F, 0F); + LeftSpokeUp = new ModelRenderer(this, 99, 3); + LeftSpokeUp.addBox(-2F, -8F, 0F, 4, 6, 1); + LeftSpokeUp.setRotationPoint(0F, 3F, 10F); + setRotation(LeftSpokeUp, 0F, 0F, 0F); + LeftAxle = new ModelRenderer(this, 98, 14); + LeftAxle.addBox(-2F, -2F, 0F, 4, 4, 2); + LeftAxle.setRotationPoint(0F, 3F, 10F); + setRotation(LeftAxle, 0F, 0F, 0F); + WheelLeft1 = new ModelRenderer(this, 92, 3); + WheelLeft1.addBox(-4F, -7F, 0F, 2, 2, 1); + WheelLeft1.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft1, 0F, 0F, 0F); + WheelLeft2 = new ModelRenderer(this, 117, 5); + WheelLeft2.addBox(-6F, -6F, 0F, 2, 2, 1); + WheelLeft2.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft2, 0F, 0F, 0F); + WheelLeft3 = new ModelRenderer(this, 80, 9); + WheelLeft3.addBox(-7F, -4F, 0F, 2, 2, 1); + WheelLeft3.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft3, 0F, 0F, 0F); + WheelLeft4 = new ModelRenderer(this, 80, 23); + WheelLeft4.addBox(-7F, 2F, 0F, 2, 2, 1); + WheelLeft4.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft4, 0F, 0F, 0F); + WheelLeft5 = new ModelRenderer(this, 117, 27); + WheelLeft5.addBox(-6F, 4F, 0F, 2, 2, 1); + WheelLeft5.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft5, 0F, 0F, 0F); + WheelLeft6 = new ModelRenderer(this, 110, 29); + WheelLeft6.addBox(-4F, 5F, 0F, 2, 2, 1); + WheelLeft6.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft6, 0F, 0F, 0F); + WheelLeft7 = new ModelRenderer(this, 92, 29); + WheelLeft7.addBox(2F, 5F, 0F, 2, 2, 1); + WheelLeft7.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft7, 0F, 0F, 0F); + WheelLeft8 = new ModelRenderer(this, 85, 27); + WheelLeft8.addBox(4F, 4F, 0F, 2, 2, 1); + WheelLeft8.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft8, 0F, 0F, 0F); + WheelLeft9 = new ModelRenderer(this, 122, 23); + WheelLeft9.addBox(5F, 2F, 0F, 2, 2, 1); + WheelLeft9.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft9, 0F, 0F, 0F); + WheelLeft10 = new ModelRenderer(this, 122, 9); + WheelLeft10.addBox(5F, -4F, 0F, 2, 2, 1); + WheelLeft10.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft10, 0F, 0F, 0F); + WheelLeft11 = new ModelRenderer(this, 85, 5); + WheelLeft11.addBox(4F, -6F, 0F, 2, 2, 1); + WheelLeft11.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft11, 0F, 0F, 0F); + WheelLeft12 = new ModelRenderer(this, 110, 3); + WheelLeft12.addBox(2F, -7F, 0F, 2, 2, 1); + WheelLeft12.setRotationPoint(0F, 3F, 10F); + setRotation(WheelLeft12, 0F, 0F, 0F); + } + + public void render (Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + BackPanel.render(f5); + FrontPanel.render(f5); + RightPanel.render(f5); + LeftPanel.render(f5); + BottomPanel.render(f5); + RightHandle.render(f5); + LeftHandle.render(f5); + RightSpokeUp.render(f5); + RightSpokeRight.render(f5); + RightSpokeDown.render(f5); + RightSpokeLeft.render(f5); + RightAxle.render(f5); + WheelRight1.render(f5); + WheelRight2.render(f5); + WheelRight3.render(f5); + WheelRight4.render(f5); + WheelRight5.render(f5); + WheelRight6.render(f5); + WheelRight7.render(f5); + WheelRight8.render(f5); + WheelRight9.render(f5); + WheelRight10.render(f5); + WheelRight11.render(f5); + WheelRight12.render(f5); + LeftSpokeRight.render(f5); + LeftSpokeLeft.render(f5); + LeftSpokeDown.render(f5); + LeftSpokeUp.render(f5); + LeftAxle.render(f5); + WheelLeft1.render(f5); + WheelLeft2.render(f5); + WheelLeft3.render(f5); + WheelLeft4.render(f5); + WheelLeft5.render(f5); + WheelLeft6.render(f5); + WheelLeft7.render(f5); + WheelLeft8.render(f5); + WheelLeft9.render(f5); + WheelLeft10.render(f5); + WheelLeft11.render(f5); + WheelLeft12.render(f5); + } + + private void setRotation (ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles (float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } + +} diff --git a/tconstruct/client/entity/ModelRendererDegrees.java b/tconstruct/client/entity/ModelRendererDegrees.java new file mode 100644 index 00000000..8175d4e3 --- /dev/null +++ b/tconstruct/client/entity/ModelRendererDegrees.java @@ -0,0 +1,321 @@ +package tconstruct.client.entity; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.TextureOffset; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.Tessellator; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ModelRendererDegrees +{ + /** The size of the texture file's width in pixels. */ + public float textureWidth; + + /** The size of the texture file's height in pixels. */ + public float textureHeight; + + /** The X offset into the texture used for displaying this model */ + private int textureOffsetX; + + /** The Y offset into the texture used for displaying this model */ + private int textureOffsetY; + public float rotationPointX; + public float rotationPointY; + public float rotationPointZ; + public float rotateAngleX; + public float rotateAngleY; + public float rotateAngleZ; + private boolean compiled; + + /** The GL display list rendered by the Tessellator for this model */ + private int displayList; + public boolean mirror; + public boolean showModel; + + /** Hides the model. */ + public boolean isHidden; + public List cubeList; + public List childModels; + public final String boxName; + private ModelBase baseModel; + public float field_82906_o; + public float field_82908_p; + public float field_82907_q; + + public ModelRendererDegrees(ModelBase par1ModelBase, String par2Str) + { + this.textureWidth = 64.0F; + this.textureHeight = 32.0F; + this.compiled = false; + this.displayList = 0; + this.mirror = false; + this.showModel = true; + this.isHidden = false; + this.cubeList = new ArrayList(); + this.baseModel = par1ModelBase; + par1ModelBase.boxList.add(this); + this.boxName = par2Str; + this.setTextureSize(par1ModelBase.textureWidth, par1ModelBase.textureHeight); + } + + public ModelRendererDegrees(ModelBase par1ModelBase) + { + this(par1ModelBase, (String) null); + } + + public ModelRendererDegrees(ModelBase par1ModelBase, int par2, int par3) + { + this(par1ModelBase); + this.setTextureOffset(par2, par3); + } + + /** + * Sets the current box's rotation points and rotation angles to another box. + */ + public void addChild (ModelRendererDegrees par1ModelRenderer) + { + if (this.childModels == null) + { + this.childModels = new ArrayList(); + } + + this.childModels.add(par1ModelRenderer); + } + + public ModelRendererDegrees setTextureOffset (int par1, int par2) + { + this.textureOffsetX = par1; + this.textureOffsetY = par2; + return this; + } + + public ModelRendererDegrees addBox (String par1Str, float par2, float par3, float par4, int par5, int par6, int par7) + { + par1Str = this.boxName + "." + par1Str; + TextureOffset textureoffset = this.baseModel.getTextureOffset(par1Str); + this.setTextureOffset(textureoffset.textureOffsetX, textureoffset.textureOffsetY); + this.cubeList.add((new ModelBoxDegrees(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5, par6, par7, 0.0F)).func_78244_a(par1Str)); + return this; + } + + public ModelRendererDegrees addBox (float par1, float par2, float par3, int par4, int par5, int par6) + { + this.cubeList.add(new ModelBoxDegrees(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F)); + return this; + } + + /** + * Creates a textured box. Args: originX, originY, originZ, width, height, depth, scaleFactor. + */ + public void addBox (float par1, float par2, float par3, int par4, int par5, int par6, float par7) + { + this.cubeList.add(new ModelBoxDegrees(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, par7)); + } + + public void setRotationPoint (float par1, float par2, float par3) + { + this.rotationPointX = par1; + this.rotationPointY = par2; + this.rotationPointZ = par3; + } + + @SideOnly(Side.CLIENT) + public void render (float par1) + { + if (!this.isHidden) + { + if (this.showModel) + { + if (!this.compiled) + { + this.compileDisplayList(par1); + } + + GL11.glTranslatef(this.field_82906_o, this.field_82908_p, this.field_82907_q); + int i; + + if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) + { + if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) + { + GL11.glCallList(this.displayList); + + if (this.childModels != null) + { + for (i = 0; i < this.childModels.size(); ++i) + { + ((ModelRendererDegrees) this.childModels.get(i)).render(par1); + } + } + } + else + { + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + GL11.glCallList(this.displayList); + + if (this.childModels != null) + { + for (i = 0; i < this.childModels.size(); ++i) + { + ((ModelRendererDegrees) this.childModels.get(i)).render(par1); + } + } + + GL11.glTranslatef(-this.rotationPointX * par1, -this.rotationPointY * par1, -this.rotationPointZ * par1); + } + } + else + { + GL11.glPushMatrix(); + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + + if (this.rotateAngleZ != 0.0F) + { + GL11.glRotatef(this.rotateAngleZ, 0.0F, 0.0F, 1.0F); + } + + if (this.rotateAngleY != 0.0F) + { + GL11.glRotatef(this.rotateAngleY, 0.0F, 1.0F, 0.0F); + } + + if (this.rotateAngleX != 0.0F) + { + GL11.glRotatef(this.rotateAngleX, 1.0F, 0.0F, 0.0F); + } + + GL11.glCallList(this.displayList); + + if (this.childModels != null) + { + for (i = 0; i < this.childModels.size(); ++i) + { + ((ModelRendererDegrees) this.childModels.get(i)).render(par1); + } + } + + GL11.glPopMatrix(); + } + + GL11.glTranslatef(-this.field_82906_o, -this.field_82908_p, -this.field_82907_q); + } + } + } + + @SideOnly(Side.CLIENT) + public void renderWithRotation (float par1) + { + if (!this.isHidden) + { + if (this.showModel) + { + if (!this.compiled) + { + this.compileDisplayList(par1); + } + + GL11.glPushMatrix(); + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + + if (this.rotateAngleY != 0.0F) + { + GL11.glRotatef(this.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); + } + + if (this.rotateAngleX != 0.0F) + { + GL11.glRotatef(this.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F); + } + + if (this.rotateAngleZ != 0.0F) + { + GL11.glRotatef(this.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F); + } + + GL11.glCallList(this.displayList); + GL11.glPopMatrix(); + } + } + } + + /** + * Allows the changing of Angles after a box has been rendered + */ + @SideOnly(Side.CLIENT) + public void postRender (float par1) + { + if (!this.isHidden) + { + if (this.showModel) + { + if (!this.compiled) + { + this.compileDisplayList(par1); + } + + if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) + { + if (this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F) + { + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + } + } + else + { + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + + if (this.rotateAngleZ != 0.0F) + { + GL11.glRotatef(this.rotateAngleZ, 0.0F, 0.0F, 1.0F); + } + + if (this.rotateAngleY != 0.0F) + { + GL11.glRotatef(this.rotateAngleY, 0.0F, 1.0F, 0.0F); + } + + if (this.rotateAngleX != 0.0F) + { + GL11.glRotatef(this.rotateAngleX, 1.0F, 0.0F, 0.0F); + } + } + } + } + } + + /** + * Compiles a GL display list for this model + */ + @SideOnly(Side.CLIENT) + private void compileDisplayList (float par1) + { + this.displayList = GLAllocation.generateDisplayLists(1); + GL11.glNewList(this.displayList, GL11.GL_COMPILE); + Tessellator tessellator = Tessellator.instance; + + for (int i = 0; i < this.cubeList.size(); ++i) + { + ((ModelBoxDegrees) this.cubeList.get(i)).render(tessellator, par1); + } + + GL11.glEndList(); + this.compiled = true; + } + + /** + * Returns the model renderer with the new texture parameters. + */ + public ModelRendererDegrees setTextureSize (int par1, int par2) + { + this.textureWidth = (float) par1; + this.textureHeight = (float) par2; + return this; + } +} diff --git a/tconstruct/client/entity/ModelWagon.java b/tconstruct/client/entity/ModelWagon.java new file mode 100644 index 00000000..be1acbf9 --- /dev/null +++ b/tconstruct/client/entity/ModelWagon.java @@ -0,0 +1,458 @@ +package tconstruct.client.entity; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelWagon extends ModelBase +{ + ModelRenderer Bottom; + ModelRenderer Left; + ModelRenderer Right; + ModelRenderer Back; + ModelRenderer Front; + ModelRenderer Leftpull; + ModelRenderer Rightpull; + ModelRenderer LeftWheelAxle; + ModelRenderer LeftWCenterHbeam; + ModelRenderer LeftWCenterVtop; + ModelRenderer LeftWCenterVbottom; + ModelRenderer LeftWnwH; + ModelRenderer LeftWnwM; + ModelRenderer LeftWnwV; + ModelRenderer LeftWnwEye; + ModelRenderer LeftWneH; + ModelRenderer LeftWneM; + ModelRenderer LeftWneV; + ModelRenderer LeftWneEye; + ModelRenderer LeftWswH; + ModelRenderer LeftWswM; + ModelRenderer LeftWswV; + ModelRenderer LeftWswEye; + ModelRenderer LeftWseH; + ModelRenderer LeftWseM; + ModelRenderer LeftWseV; + ModelRenderer LeftWseEye; + ModelRenderer RightWheelAxle; + ModelRenderer RightWCenterHbeam; + ModelRenderer RightWCenterVtop; + ModelRenderer RightWCenterVbottom; + ModelRenderer RightWnwH; + ModelRenderer RightWnwM; + ModelRenderer RightWnwV; + ModelRenderer RightWnwEye; + ModelRenderer RoghtWneH; + ModelRenderer RightWneM; + ModelRenderer RightWneV; + ModelRenderer RightWneEye; + ModelRenderer RightWswH; + ModelRenderer RightWswM; + ModelRenderer RightWswV; + ModelRenderer RightWswEye; + ModelRenderer RightWseH; + ModelRenderer RightWseM; + ModelRenderer RightWseV; + public ModelRenderer RightWseEye; + ModelRenderer HandBrakeMain; + ModelRenderer HandbrakeJamb; + ModelRenderer StandCenterBar; + ModelRenderer StandLeft; + ModelRenderer StandRight; + + public ModelWagon() + { + this.textureWidth = 128; + this.textureHeight = 64; + this.Bottom = new ModelRenderer(this, 26, 46); + this.Bottom.addBox(0.0F, 0.0F, 0.0F, 20, 2, 16); + this.Bottom.setRotationPoint(-10.0F, 4.0F, -8.0F); + this.Bottom.setTextureSize(64, 32); + this.Bottom.mirror = true; + this.setRotation(this.Bottom, 0.0F, 0.0F, 0.0F); + this.Left = new ModelRenderer(this, 0, 35); + this.Left.addBox(0.0F, 0.0F, 0.0F, 20, 8, 2); + this.Left.setRotationPoint(-10.0F, -4.0F, -8.0F); + this.Left.setTextureSize(64, 32); + this.Left.mirror = true; + this.setRotation(this.Left, 0.0F, 0.0F, 0.0F); + this.Right = new ModelRenderer(this, 83, 35); + this.Right.addBox(0.0F, 0.0F, 0.0F, 20, 8, 2); + this.Right.setRotationPoint(-10.0F, -4.0F, 6.0F); + this.Right.setTextureSize(64, 32); + this.Right.mirror = true; + this.setRotation(this.Right, 0.0F, 0.0F, 0.0F); + this.Back = new ModelRenderer(this, 99, 46); + this.Back.addBox(-2.0F, -5.0F, 0.0F, 2, 5, 12); + this.Back.setRotationPoint(10.0F, 4.0F, -6.0F); + this.Back.setTextureSize(64, 32); + this.Back.mirror = true; + this.setRotation(this.Back, 0.0F, 0.0F, 0.0F); + this.Front = new ModelRenderer(this, 50, 1); + this.Front.addBox(0.0F, 0.0F, 0.0F, 2, 8, 12); + this.Front.setRotationPoint(-10.0F, -4.0F, -6.0F); + this.Front.setTextureSize(64, 32); + this.Front.mirror = true; + this.setRotation(this.Front, 0.0F, 0.0F, 0.0F); + this.Leftpull = new ModelRenderer(this, 0, 30); + this.Leftpull.addBox(0.0F, 0.0F, 0.0F, 16, 2, 2); + this.Leftpull.setRotationPoint(-26.0F, 2.0F, -6.0F); + this.Leftpull.setTextureSize(64, 32); + this.Leftpull.mirror = true; + this.setRotation(this.Leftpull, 0.0F, 0.0F, 0.0F); + this.Rightpull = new ModelRenderer(this, 91, 30); + this.Rightpull.addBox(0.0F, 0.0F, 0.0F, 16, 2, 2); + this.Rightpull.setRotationPoint(-26.0F, 2.0F, 4.0F); + this.Rightpull.setTextureSize(64, 32); + this.Rightpull.mirror = true; + this.setRotation(this.Rightpull, 0.0F, 0.0F, 0.0F); + this.HandBrakeMain = new ModelRenderer(this, 1, 59); + this.HandBrakeMain.addBox(-6.0F, 0.0F, 0.0F, 11, 1, 1); + this.HandBrakeMain.setRotationPoint(-9.0F, -3.0F, -9.0F); + this.HandBrakeMain.setTextureSize(64, 32); + this.HandBrakeMain.mirror = true; + this.setRotation(this.HandBrakeMain, 0.0F, 0.0F, 0.0F); + this.HandbrakeJamb = new ModelRenderer(this, 10, 62); + this.HandbrakeJamb.addBox(3.0F, 1.0F, 0.0F, 2, 1, 1); + this.HandbrakeJamb.setRotationPoint(-9.0F, -3.0F, -9.0F); + this.HandbrakeJamb.setTextureSize(64, 32); + this.HandbrakeJamb.mirror = true; + this.setRotation(this.HandbrakeJamb, 0.0F, 0.0F, 0.0F); + this.LeftWheelAxle = new ModelRenderer(this, 0, 12); + this.LeftWheelAxle.addBox(-1.0F, -1.0F, -1.0F, 2, 2, 3); + this.LeftWheelAxle.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWheelAxle.setTextureSize(64, 32); + this.LeftWheelAxle.mirror = true; + this.setRotation(this.LeftWheelAxle, 0.0F, 0.0F, 0.0F); + this.LeftWCenterHbeam = new ModelRenderer(this, 12, 12); + this.LeftWCenterHbeam.addBox(-8.0F, -2.0F, 0.0F, 16, 4, 1); + this.LeftWCenterHbeam.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWCenterHbeam.setTextureSize(64, 32); + this.LeftWCenterHbeam.mirror = true; + this.setRotation(this.LeftWCenterHbeam, 0.0F, 0.0F, 0.0F); + this.LeftWCenterVtop = new ModelRenderer(this, 18, 0); + this.LeftWCenterVtop.addBox(-2.0F, -8.0F, 0.0F, 4, 6, 1); + this.LeftWCenterVtop.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWCenterVtop.setTextureSize(64, 32); + this.LeftWCenterVtop.mirror = true; + this.setRotation(this.LeftWCenterVtop, 0.0F, 0.0F, 0.0F); + this.LeftWCenterVbottom = new ModelRenderer(this, 18, 22); + this.LeftWCenterVbottom.addBox(-2.0F, 2.0F, 0.0F, 4, 6, 1); + this.LeftWCenterVbottom.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWCenterVbottom.setTextureSize(64, 32); + this.LeftWCenterVbottom.mirror = true; + this.setRotation(this.LeftWCenterVbottom, 0.0F, 0.0F, 0.0F); + this.LeftWnwH = new ModelRenderer(this, 0, 7); + this.LeftWnwH.addBox(-7.0F, -4.0F, 0.0F, 3, 2, 1); + this.LeftWnwH.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWnwH.setTextureSize(64, 32); + this.LeftWnwH.mirror = true; + this.setRotation(this.LeftWnwH, 0.0F, 0.0F, 0.0F); + this.LeftWnwM = new ModelRenderer(this, 4, 3); + this.LeftWnwM.addBox(-6.0F, -6.0F, 0.0F, 2, 2, 1); + this.LeftWnwM.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWnwM.setTextureSize(64, 32); + this.LeftWnwM.mirror = true; + this.setRotation(this.LeftWnwM, 0.0F, 0.0F, 0.0F); + this.LeftWnwV = new ModelRenderer(this, 11, 1); + this.LeftWnwV.addBox(-4.0F, -7.0F, 0.0F, 2, 3, 1); + this.LeftWnwV.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWnwV.setTextureSize(64, 32); + this.LeftWnwV.mirror = true; + this.setRotation(this.LeftWnwV, 0.0F, 0.0F, 0.0F); + this.LeftWnwEye = new ModelRenderer(this, 10, 7); + this.LeftWnwEye.addBox(-4.0F, -4.0F, 0.0F, 1, 1, 1); + this.LeftWnwEye.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWnwEye.setTextureSize(64, 32); + this.LeftWnwEye.mirror = true; + this.setRotation(this.LeftWnwEye, 0.0F, 0.0F, 0.0F); + this.LeftWneH = new ModelRenderer(this, 40, 7); + this.LeftWneH.addBox(4.0F, -4.0F, 0.0F, 3, 2, 1); + this.LeftWneH.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWneH.setTextureSize(64, 32); + this.LeftWneH.mirror = true; + this.setRotation(this.LeftWneH, 0.0F, 0.0F, 0.0F); + this.LeftWneM = new ModelRenderer(this, 37, 3); + this.LeftWneM.addBox(4.0F, -6.0F, 0.0F, 2, 2, 1); + this.LeftWneM.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWneM.setTextureSize(64, 32); + this.LeftWneM.mirror = true; + this.setRotation(this.LeftWneM, 0.0F, 0.0F, 0.0F); + this.LeftWneV = new ModelRenderer(this, 29, 1); + this.LeftWneV.addBox(2.0F, -7.0F, 0.0F, 2, 3, 1); + this.LeftWneV.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWneV.setTextureSize(64, 32); + this.LeftWneV.mirror = true; + this.setRotation(this.LeftWneV, 0.0F, 0.0F, 0.0F); + this.LeftWneEye = new ModelRenderer(this, 33, 7); + this.LeftWneEye.addBox(3.0F, -4.0F, 0.0F, 1, 1, 1); + this.LeftWneEye.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWneEye.setTextureSize(64, 32); + this.LeftWneEye.mirror = true; + this.setRotation(this.LeftWneEye, 0.0F, 0.0F, 0.0F); + this.LeftWswH = new ModelRenderer(this, 0, 19); + this.LeftWswH.addBox(-7.0F, 2.0F, 0.0F, 3, 2, 1); + this.LeftWswH.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWswH.setTextureSize(64, 32); + this.LeftWswH.mirror = true; + this.setRotation(this.LeftWswH, 0.0F, 0.0F, 0.0F); + this.LeftWswM = new ModelRenderer(this, 4, 23); + this.LeftWswM.addBox(-6.0F, 4.0F, 0.0F, 2, 2, 1); + this.LeftWswM.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWswM.setTextureSize(64, 32); + this.LeftWswM.mirror = true; + this.setRotation(this.LeftWswM, 0.0F, 0.0F, 0.0F); + this.LeftWswV = new ModelRenderer(this, 11, 24); + this.LeftWswV.addBox(-4.0F, 4.0F, 0.0F, 2, 3, 1); + this.LeftWswV.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWswV.setTextureSize(64, 32); + this.LeftWswV.mirror = true; + this.setRotation(this.LeftWswV, 0.0F, 0.0F, 0.0F); + this.LeftWswEye = new ModelRenderer(this, 10, 20); + this.LeftWswEye.addBox(-4.0F, 3.0F, 0.0F, 1, 1, 1); + this.LeftWswEye.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWswEye.setTextureSize(64, 32); + this.LeftWswEye.mirror = true; + this.setRotation(this.LeftWswEye, 0.0F, 0.0F, 0.0F); + this.LeftWseH = new ModelRenderer(this, 40, 19); + this.LeftWseH.addBox(4.0F, 2.0F, 0.0F, 3, 2, 1); + this.LeftWseH.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWseH.setTextureSize(64, 32); + this.LeftWseH.mirror = true; + this.setRotation(this.LeftWseH, 0.0F, 0.0F, 0.0F); + this.LeftWseM = new ModelRenderer(this, 37, 23); + this.LeftWseM.addBox(4.0F, 4.0F, 0.0F, 2, 2, 1); + this.LeftWseM.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWseM.setTextureSize(64, 32); + this.LeftWseM.mirror = true; + this.setRotation(this.LeftWseM, 0.0F, 0.0F, 0.0F); + this.LeftWseV = new ModelRenderer(this, 29, 24); + this.LeftWseV.addBox(2.0F, 4.0F, 0.0F, 2, 3, 1); + this.LeftWseV.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWseV.setTextureSize(64, 32); + this.LeftWseV.mirror = true; + this.setRotation(this.LeftWseV, 0.0F, 0.0F, 0.0F); + this.LeftWseEye = new ModelRenderer(this, 33, 20); + this.LeftWseEye.addBox(3.0F, 3.0F, 0.0F, 1, 1, 1); + this.LeftWseEye.setRotationPoint(0.0F, 5.0F, -10.0F); + this.LeftWseEye.setTextureSize(64, 32); + this.LeftWseEye.mirror = true; + this.setRotation(this.LeftWseEye, 0.0F, 0.0F, 0.0F); + this.RightWheelAxle = new ModelRenderer(this, 117, 12); + this.RightWheelAxle.addBox(-1.0F, -1.0F, -1.0F, 2, 2, 3); + this.RightWheelAxle.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWheelAxle.setTextureSize(64, 32); + this.RightWheelAxle.mirror = true; + this.setRotation(this.RightWheelAxle, 0.0F, 0.0F, 0.0F); + this.RightWCenterHbeam = new ModelRenderer(this, 80, 12); + this.RightWCenterHbeam.addBox(-8.0F, -2.0F, 0.0F, 16, 4, 1); + this.RightWCenterHbeam.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWCenterHbeam.setTextureSize(64, 32); + this.RightWCenterHbeam.mirror = true; + this.setRotation(this.RightWCenterHbeam, 0.0F, 0.0F, 0.0F); + this.RightWCenterVtop = new ModelRenderer(this, 98, 0); + this.RightWCenterVtop.addBox(-2.0F, -8.0F, 0.0F, 4, 6, 1); + this.RightWCenterVtop.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWCenterVtop.setTextureSize(64, 32); + this.RightWCenterVtop.mirror = true; + this.setRotation(this.RightWCenterVtop, 0.0F, 0.0F, 0.0F); + this.RightWCenterVbottom = new ModelRenderer(this, 98, 22); + this.RightWCenterVbottom.addBox(-2.0F, 2.0F, 0.0F, 4, 6, 1); + this.RightWCenterVbottom.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWCenterVbottom.setTextureSize(64, 32); + this.RightWCenterVbottom.mirror = true; + this.setRotation(this.RightWCenterVbottom, 0.0F, 0.0F, 0.0F); + this.RightWnwH = new ModelRenderer(this, 79, 7); + this.RightWnwH.addBox(4.0F, -4.0F, 0.0F, 3, 2, 1); + this.RightWnwH.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWnwH.setTextureSize(64, 32); + this.RightWnwH.mirror = true; + this.setRotation(this.RightWnwH, 0.0F, 0.0F, 0.0F); + this.RightWnwM = new ModelRenderer(this, 84, 3); + this.RightWnwM.addBox(4.0F, -6.0F, 0.0F, 2, 2, 1); + this.RightWnwM.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWnwM.setTextureSize(64, 32); + this.RightWnwM.mirror = true; + this.setRotation(this.RightWnwM, 0.0F, 0.0F, 0.0F); + this.RightWnwV = new ModelRenderer(this, 91, 1); + this.RightWnwV.addBox(2.0F, -7.0F, 0.0F, 2, 3, 1); + this.RightWnwV.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWnwV.setTextureSize(64, 32); + this.RightWnwV.mirror = true; + this.setRotation(this.RightWnwV, 0.0F, 0.0F, 0.0F); + this.RightWnwEye = new ModelRenderer(this, 90, 7); + this.RightWnwEye.addBox(3.0F, -4.0F, 0.0F, 1, 1, 1); + this.RightWnwEye.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWnwEye.setTextureSize(64, 32); + this.RightWnwEye.mirror = true; + this.setRotation(this.RightWnwEye, 0.0F, 0.0F, 0.0F); + this.RoghtWneH = new ModelRenderer(this, 119, 7); + this.RoghtWneH.addBox(-7.0F, -4.0F, 0.0F, 3, 2, 1); + this.RoghtWneH.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RoghtWneH.setTextureSize(64, 32); + this.RoghtWneH.mirror = true; + this.setRotation(this.RoghtWneH, 0.0F, 0.0F, 0.0F); + this.RightWneM = new ModelRenderer(this, 116, 3); + this.RightWneM.addBox(-6.0F, -6.0F, 0.0F, 2, 2, 1); + this.RightWneM.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWneM.setTextureSize(64, 32); + this.RightWneM.mirror = true; + this.setRotation(this.RightWneM, 0.0F, 0.0F, 0.0F); + this.RightWneV = new ModelRenderer(this, 109, 1); + this.RightWneV.addBox(-4.0F, -7.0F, 0.0F, 2, 3, 1); + this.RightWneV.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWneV.setTextureSize(64, 32); + this.RightWneV.mirror = true; + this.setRotation(this.RightWneV, 0.0F, 0.0F, 0.0F); + this.RightWneEye = new ModelRenderer(this, 113, 7); + this.RightWneEye.addBox(-4.0F, -4.0F, 0.0F, 1, 1, 1); + this.RightWneEye.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWneEye.setTextureSize(64, 32); + this.RightWneEye.mirror = true; + this.setRotation(this.RightWneEye, 0.0F, 0.0F, 0.0F); + this.RightWswH = new ModelRenderer(this, 79, 19); + this.RightWswH.addBox(4.0F, 2.0F, 0.0F, 3, 2, 1); + this.RightWswH.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWswH.setTextureSize(64, 32); + this.RightWswH.mirror = true; + this.setRotation(this.RightWswH, 0.0F, 0.0F, 0.0F); + this.RightWswM = new ModelRenderer(this, 84, 23); + this.RightWswM.addBox(4.0F, 4.0F, 0.0F, 2, 2, 1); + this.RightWswM.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWswM.setTextureSize(64, 32); + this.RightWswM.mirror = true; + this.setRotation(this.RightWswM, 0.0F, 0.0F, 0.0F); + this.RightWswV = new ModelRenderer(this, 91, 24); + this.RightWswV.addBox(2.0F, 4.0F, 0.0F, 2, 3, 1); + this.RightWswV.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWswV.setTextureSize(64, 32); + this.RightWswV.mirror = true; + this.setRotation(this.RightWswV, 0.0F, 0.0F, 0.0F); + this.RightWswEye = new ModelRenderer(this, 90, 20); + this.RightWswEye.addBox(3.0F, 3.0F, 0.0F, 1, 1, 1); + this.RightWswEye.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWswEye.setTextureSize(64, 32); + this.RightWswEye.mirror = true; + this.setRotation(this.RightWswEye, 0.0F, 0.0F, 0.0F); + this.RightWseH = new ModelRenderer(this, 119, 19); + this.RightWseH.addBox(-7.0F, 2.0F, 0.0F, 3, 2, 1); + this.RightWseH.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWseH.setTextureSize(64, 32); + this.RightWseH.mirror = true; + this.setRotation(this.RightWseH, 0.0F, 0.0F, 0.0F); + this.RightWseM = new ModelRenderer(this, 116, 23); + this.RightWseM.addBox(-6.0F, 4.0F, 0.0F, 2, 2, 1); + this.RightWseM.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWseM.setTextureSize(64, 32); + this.RightWseM.mirror = true; + this.setRotation(this.RightWseM, 0.0F, 0.0F, 0.0F); + this.RightWseV = new ModelRenderer(this, 109, 24); + this.RightWseV.addBox(-4.0F, 4.0F, 0.0F, 2, 3, 1); + this.RightWseV.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWseV.setTextureSize(64, 32); + this.RightWseV.mirror = true; + this.setRotation(this.RightWseV, 0.0F, 0.0F, 0.0F); + this.RightWseEye = new ModelRenderer(this, 113, 20); + this.RightWseEye.addBox(-4.0F, 3.0F, 0.0F, 1, 1, 1); + this.RightWseEye.setRotationPoint(0.0F, 5.0F, 9.0F); + this.RightWseEye.setTextureSize(64, 32); + this.RightWseEye.mirror = true; + this.setRotation(this.RightWseEye, 0.0F, 0.0F, 0.0F); + this.StandCenterBar = new ModelRenderer(this, 47, 27); + this.StandCenterBar.addBox(-1.0F, 0.0F, -8.0F, 1, 2, 16); + this.StandCenterBar.setRotationPoint(-9.0F, 6.0F, 0.0F); + this.StandCenterBar.setTextureSize(64, 32); + this.StandCenterBar.mirror = true; + this.setRotation(this.StandCenterBar, 0.0F, 0.0F, 0.0F); + this.StandLeft = new ModelRenderer(this, 37, 27); + this.StandLeft.addBox(-1.0F, 2.0F, -8.0F, 1, 5, 2); + this.StandLeft.setRotationPoint(-9.0F, 6.0F, 0.0F); + this.StandLeft.setTextureSize(64, 32); + this.StandLeft.mirror = true; + this.setRotation(this.StandLeft, 0.0F, 0.0F, 0.0F); + this.StandRight = new ModelRenderer(this, 84, 27); + this.StandRight.addBox(-1.0F, 2.0F, 6.0F, 1, 5, 2); + this.StandRight.setRotationPoint(-9.0F, 6.0F, 0.0F); + this.StandRight.setTextureSize(64, 32); + this.StandRight.mirror = true; + this.setRotation(this.StandRight, 0.0F, 0.0F, 0.0F); + } + + /** + * Sets the models various rotation angles then renders the model. + */ + @Override + public void render (Entity var1, float var2, float var3, float var4, float var5, float var6, float var7) + { + super.render(var1, var2, var3, var4, var5, var6, var7); + this.setRotationAngles(var2, var3, var4, var5, var6, var7, var1); + this.LeftWheelAxle.rotateAngleZ = this.LeftWCenterHbeam.rotateAngleZ = this.LeftWCenterVtop.rotateAngleZ = this.LeftWCenterVbottom.rotateAngleZ = this.LeftWnwH.rotateAngleZ = this.LeftWnwM.rotateAngleZ = this.LeftWnwV.rotateAngleZ = this.LeftWnwEye.rotateAngleZ = this.LeftWneH.rotateAngleZ = this.LeftWneM.rotateAngleZ = this.LeftWneV.rotateAngleZ = this.LeftWneEye.rotateAngleZ = this.LeftWswH.rotateAngleZ = this.LeftWswM.rotateAngleZ = this.LeftWswV.rotateAngleZ = this.LeftWswEye.rotateAngleZ = this.LeftWseH.rotateAngleZ = this.LeftWseM.rotateAngleZ = this.LeftWseV.rotateAngleZ = this.LeftWseEye.rotateAngleZ = this.RightWheelAxle.rotateAngleZ = this.RightWCenterHbeam.rotateAngleZ = this.RightWCenterVtop.rotateAngleZ = this.RightWCenterVbottom.rotateAngleZ = this.RightWnwH.rotateAngleZ = this.RightWnwM.rotateAngleZ = this.RightWnwV.rotateAngleZ = this.RightWnwEye.rotateAngleZ = this.RoghtWneH.rotateAngleZ = this.RightWneM.rotateAngleZ = this.RightWneV.rotateAngleZ = this.RightWneEye.rotateAngleZ = this.RightWswH.rotateAngleZ = this.RightWswM.rotateAngleZ = this.RightWswV.rotateAngleZ = this.RightWswEye.rotateAngleZ = this.RightWseH.rotateAngleZ = this.RightWseM.rotateAngleZ = this.RightWseV.rotateAngleZ = this.RightWseEye.rotateAngleZ; + this.Bottom.render(var7); + this.Left.render(var7); + this.Right.render(var7); + this.Back.render(var7); + this.Front.render(var7); + this.Leftpull.render(var7); + this.Rightpull.render(var7); + this.HandBrakeMain.render(var7); + this.HandbrakeJamb.render(var7); + this.LeftWheelAxle.render(var7); + this.LeftWCenterHbeam.render(var7); + this.LeftWCenterVtop.render(var7); + this.LeftWCenterVbottom.render(var7); + this.LeftWnwH.render(var7); + this.LeftWnwM.render(var7); + this.LeftWnwV.render(var7); + this.LeftWnwEye.render(var7); + this.LeftWneH.render(var7); + this.LeftWneM.render(var7); + this.LeftWneV.render(var7); + this.LeftWneEye.render(var7); + this.LeftWswH.render(var7); + this.LeftWswM.render(var7); + this.LeftWswV.render(var7); + this.LeftWswEye.render(var7); + this.LeftWseH.render(var7); + this.LeftWseM.render(var7); + this.LeftWseV.render(var7); + this.LeftWseEye.render(var7); + this.RightWheelAxle.render(var7); + this.RightWCenterHbeam.render(var7); + this.RightWCenterVtop.render(var7); + this.RightWCenterVbottom.render(var7); + this.RightWnwH.render(var7); + this.RightWnwM.render(var7); + this.RightWnwV.render(var7); + this.RightWnwEye.render(var7); + this.RoghtWneH.render(var7); + this.RightWneM.render(var7); + this.RightWneV.render(var7); + this.RightWneEye.render(var7); + this.RightWswH.render(var7); + this.RightWswM.render(var7); + this.RightWswV.render(var7); + this.RightWswEye.render(var7); + this.RightWseH.render(var7); + this.RightWseM.render(var7); + this.RightWseV.render(var7); + this.RightWseEye.render(var7); + this.StandCenterBar.render(var7); + this.StandLeft.render(var7); + this.StandRight.render(var7); + } + + private void setRotation (ModelRenderer var1, float var2, float var3, float var4) + { + var1.rotateAngleX = var2; + var1.rotateAngleY = var3; + var1.rotateAngleZ = var4; + } + + /** + * Sets the models various rotation angles. + */ + @Override + public void setRotationAngles (float var1, float var2, float var3, float var4, float var5, float var6, Entity par7Entity) + { + super.setRotationAngles(var1, var2, var3, var4, var5, var6, par7Entity); + } +} diff --git a/tconstruct/client/entity/SlimeCloneRender.java b/tconstruct/client/entity/SlimeCloneRender.java new file mode 100644 index 00000000..3ecee9d3 --- /dev/null +++ b/tconstruct/client/entity/SlimeCloneRender.java @@ -0,0 +1,101 @@ +package tconstruct.client.entity; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import tconstruct.entity.SlimeClone; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class SlimeCloneRender extends RenderLiving +{ + private ModelBase scaleAmount; + + public SlimeCloneRender(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) + { + super(par1ModelBase, par3); + this.scaleAmount = par2ModelBase; + } + + /** + * Determines whether Slime Render should pass or not. + */ + protected int shouldSlimeRenderPass (SlimeClone blueSlime, int par2, float par3) + { + if (blueSlime.isInvisible()) + { + return 0; + } + else if (par2 == 0) + { + this.setRenderPassModel(this.scaleAmount); + GL11.glEnable(GL11.GL_NORMALIZE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + return 1; + } + else + { + if (par2 == 1) + { + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + return -1; + } + } + + /** + * sets the scale for the slime based on getSlimeSize in EdibleSlime + */ + protected void scaleSlime (SlimeClone slimeClone, float par2) + { + float f1 = slimeClone.getSlimeSize(); + float f2 = (slimeClone.sizeHeight + (slimeClone.sizeFactor - slimeClone.sizeHeight) * par2) / (f1 * 0.5F + 1.0F); + float f3 = 1.0F / (f2 + 1.0F); + GL11.glScalef(f3 * f1, 1.0F / f3 * f1, f3 * f1); + } + + /** + * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args: + * entityLiving, partialTickTime + */ + protected void preRenderCallback (EntityLiving par1EntityLiving, float par2) + { + this.scaleSlime((SlimeClone) par1EntityLiving, par2); + } + + /** + * Queries whether should render the specified pass or not. + */ + protected int shouldRenderPass (EntityLiving par1EntityLiving, int par2, float par3) + { + return this.shouldSlimeRenderPass((SlimeClone) par1EntityLiving, par2, par3); + } + + /*protected ResourceLocation func_98191_a (SlimeClone slime) + { + this.loadDownloadableImageTexture(slime.skinUrl, slime.getTexture()); + } + + @Override + protected void func_98190_a (EntityLiving par1EntityLiving) + { + this.func_98191_a((SlimeClone) par1EntityLiving); + }*/ + + @Override + protected ResourceLocation func_110775_a (Entity entity) + { + //return func_98191_a((SlimeClone)entity); + return null; + } +} diff --git a/tconstruct/client/entity/SlimeModel.java b/tconstruct/client/entity/SlimeModel.java new file mode 100644 index 00000000..c6077fbb --- /dev/null +++ b/tconstruct/client/entity/SlimeModel.java @@ -0,0 +1,57 @@ +package tconstruct.client.entity; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class SlimeModel extends ModelBase +{ + /** The slime's bodies, both the inside box and the outside box */ + ModelRenderer slimeBodies; + + /** The slime's right eye */ + ModelRenderer slimeRightEye; + + /** The slime's left eye */ + ModelRenderer slimeLeftEye; + + /** The slime's mouth */ + ModelRenderer slimeMouth; + + public SlimeModel(int par1) + { + this.slimeBodies = new ModelRenderer(this, 0, par1); + this.slimeBodies.addBox(-4.0F, 16.0F, -4.0F, 8, 8, 8); + + if (par1 > 0) + { + this.slimeBodies = new ModelRenderer(this, 0, par1); + this.slimeBodies.addBox(-3.0F, 17.0F, -3.0F, 6, 6, 6); + this.slimeRightEye = new ModelRenderer(this, 32, 0); + this.slimeRightEye.addBox(-3.25F, 18.0F, -3.5F, 2, 2, 2); + this.slimeLeftEye = new ModelRenderer(this, 32, 4); + this.slimeLeftEye.addBox(1.25F, 18.0F, -3.5F, 2, 2, 2); + this.slimeMouth = new ModelRenderer(this, 32, 8); + this.slimeMouth.addBox(0.0F, 21.0F, -3.5F, 1, 1, 1); + } + } + + /** + * Sets the models various rotation angles then renders the model. + */ + public void render (Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.slimeBodies.render(par7); + + if (this.slimeRightEye != null) + { + this.slimeRightEye.render(par7); + this.slimeLeftEye.render(par7); + this.slimeMouth.render(par7); + } + } +} diff --git a/tconstruct/client/entity/SlimeRender.java b/tconstruct/client/entity/SlimeRender.java new file mode 100644 index 00000000..a1a286c7 --- /dev/null +++ b/tconstruct/client/entity/SlimeRender.java @@ -0,0 +1,104 @@ +package tconstruct.client.entity; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.boss.BossStatus; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import tconstruct.entity.BlueSlime; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class SlimeRender extends RenderLiving +{ + private ModelBase scaleAmount; + + public SlimeRender(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) + { + super(par1ModelBase, par3); + this.scaleAmount = par2ModelBase; + } + + public void doRenderLiving (EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + super.doRenderLiving(par1EntityLiving, par2, par4, par6, par8, par9); + renderBossHealth((BlueSlime) par1EntityLiving); + } + + public void renderBossHealth (BlueSlime slime) + { + if (slime.getSlimeSize() >= 8) + BossStatus.func_82824_a(slime, true); + } + + /** + * Determines whether Slime Render should pass or not. + */ + protected int shouldSlimeRenderPass (BlueSlime blueSlime, int par2, float par3) + { + if (blueSlime.isInvisible()) + { + return 0; + } + else if (par2 == 0) + { + this.setRenderPassModel(this.scaleAmount); + GL11.glEnable(GL11.GL_NORMALIZE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + return 1; + } + else + { + if (par2 == 1) + { + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + return -1; + } + } + + /** + * sets the scale for the slime based on getSlimeSize in EdibleSlime + */ + protected void scaleSlime (BlueSlime par1EdibleSlime, float par2) + { + float f1 = (float) par1EdibleSlime.getSlimeSize(); + float f2 = (par1EdibleSlime.sizeHeight + (par1EdibleSlime.sizeFactor - par1EdibleSlime.sizeHeight) * par2) / (f1 * 0.5F + 1.0F); + float f3 = 1.0F / (f2 + 1.0F); + GL11.glScalef(f3 * f1, 1.0F / f3 * f1, f3 * f1); + } + + /** + * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args: + * entityLiving, partialTickTime + */ + protected void preRenderCallback (EntityLiving par1EntityLiving, float par2) + { + this.scaleSlime((BlueSlime) par1EntityLiving, par2); + } + + /** + * Queries whether should render the specified pass or not. + */ + protected int shouldRenderPass (EntityLiving par1EntityLiving, int par2, float par3) + { + return this.shouldSlimeRenderPass((BlueSlime) par1EntityLiving, par2, par3); + } + + @Override + protected ResourceLocation func_110775_a(Entity par1Entity) + { + return texture; + } + + static final ResourceLocation texture = new ResourceLocation("tinker", "textures/mob/slimeedible.png"); +} diff --git a/tconstruct/client/entity/projectile/ArrowRender.java b/tconstruct/client/entity/projectile/ArrowRender.java new file mode 100644 index 00000000..d26f0e68 --- /dev/null +++ b/tconstruct/client/entity/projectile/ArrowRender.java @@ -0,0 +1,634 @@ +package tconstruct.client.entity.projectile; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import tconstruct.entity.projectile.ArrowEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ArrowRender extends Render +{ + private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private RenderBlocks itemRenderBlocks = new RenderBlocks(); + + /** The RNG used in RenderItem (for bobbing itemstacks on the ground) */ + private Random random = new Random(); + public boolean renderWithColor = true; + + /** Defines the zLevel of rendering of item on GUI. */ + public float zLevel; + public static boolean renderInFrame; + + public ArrowRender() + { + this.shadowSize = 0.15F; + this.shadowOpaque = 0.75F; + } + + /** + * Renders the item + */ + public void doRenderItem (ArrowEntity par1ArrowEntity, double par2, double par4, double par6, float par8, float par9) + { + this.func_110777_b(par1ArrowEntity); + this.random.setSeed(187L); + ItemStack itemstack = par1ArrowEntity.getEntityItem(); + + if (itemstack.getItem() != null) + { + GL11.glPushMatrix(); + float f2 = shouldBob() ? MathHelper.sin(((float) 0 + par9) / 10.0F + 0) * 0.1F + 0.1F : 0F; + float f3 = (((float) 0 + par9) / 20.0F + 0) * (180F / (float) Math.PI); + byte b0 = getMiniBlockCount(itemstack); + + GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f4; + float f5; + float f6; + int i; + + Block block = null; + if (itemstack.itemID < Block.blocksList.length) + { + block = Block.blocksList[itemstack.itemID]; + } + + if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType())) + { + GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); + + if (renderInFrame) + { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glTranslatef(0.0F, 0.05F, 0.0F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + + float f7 = 0.25F; + int j = block.getRenderType(); + + if (j == 1 || j == 19 || j == 12 || j == 2) + { + f7 = 0.5F; + } + + GL11.glScalef(f7, f7, f7); + + for (i = 0; i < b0; ++i) + { + GL11.glPushMatrix(); + + if (i > 0) + { + f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + GL11.glTranslatef(f5, f4, f6); + } + + f5 = 1.0F; + this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5); + GL11.glPopMatrix(); + } + } + else + { + float f8; + + if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses()) + { + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) + { + this.random.setSeed(187L); + Icon icon = itemstack.getItem().getIcon(itemstack, k); + f8 = 1.0F; + + if (this.renderWithColor) + { + i = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, k); + f5 = (float) (i >> 16 & 255) / 255.0F; + f4 = (float) (i >> 8 & 255) / 255.0F; + f6 = (float) (i & 255) / 255.0F; + GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F); + this.renderDroppedItem(par1ArrowEntity, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k); + } + else + { + this.renderDroppedItem(par1ArrowEntity, icon, b0, par9, 1.0F, 1.0F, 1.0F, k); + } + } + } + else + { + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + Icon icon1 = itemstack.getIconIndex(); + + if (this.renderWithColor) + { + int l = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, 0); + f8 = (float) (l >> 16 & 255) / 255.0F; + float f9 = (float) (l >> 8 & 255) / 255.0F; + f5 = (float) (l & 255) / 255.0F; + f4 = 1.0F; + this.renderDroppedItem(par1ArrowEntity, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4); + } + else + { + this.renderDroppedItem(par1ArrowEntity, icon1, b0, par9, 1.0F, 1.0F, 1.0F); + } + } + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation func_110796_a (ArrowEntity par1ArrowEntity) + { + return this.renderManager.renderEngine.func_130087_a(par1ArrowEntity.getEntityItem().getItemSpriteNumber()); + } + + /** + * Renders a dropped item + */ + private void renderDroppedItem (ArrowEntity par1ArrowEntity, Icon par2Icon, int par3, float par4, float par5, float par6, float par7) + { + renderDroppedItem(par1ArrowEntity, par2Icon, par3, par4, par5, par6, par7, 0); + } + + private void renderDroppedItem (ArrowEntity arrow, Icon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass) + { + Tessellator tessellator = Tessellator.instance; + + if (par2Icon == null) + { + TextureManager texturemanager = Minecraft.getMinecraft().func_110434_K(); + ResourceLocation resourcelocation = texturemanager.func_130087_a(arrow.getEntityItem().getItemSpriteNumber()); + par2Icon = ((TextureMap) texturemanager.func_110581_b(resourcelocation)).func_110572_b("missingno"); + } + + float f4 = ((Icon) par2Icon).getMinU(); + float f5 = ((Icon) par2Icon).getMaxU(); + float f6 = ((Icon) par2Icon).getMinV(); + float f7 = ((Icon) par2Icon).getMaxV(); + float f8 = 1.0F; + float f9 = 0.5F; + float f10 = 0.25F; + float f11; + GL11.glRotatef(arrow.prevRotationYaw + (arrow.rotationYaw - arrow.prevRotationYaw) * par4 - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(arrow.prevRotationPitch + (arrow.rotationPitch - arrow.prevRotationPitch) * par4 - 45.0F, 0.0F, 0.0F, 1.0F); + + GL11.glPushMatrix(); + + if (renderInFrame) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + else + { + GL11.glRotatef((((float) 0 + par4) / 20.0F + 0) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); + } + + float f12 = 0.0625F; + f11 = 0.021875F; + ItemStack itemstack = arrow.getEntityItem(); + int j = itemstack.stackSize; + byte b0 = getMiniItemCount(itemstack); + + GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F)); + + for (int k = 0; k < b0; ++k) + { + // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... + if (k > 0 && shouldSpreadItems()) + { + float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + GL11.glTranslatef(x, y, f12 + f11); + } + else + { + GL11.glTranslatef(0f, 0f, f12 + f11); + } + + if (itemstack.getItemSpriteNumber() == 0) + { + this.func_110776_a(TextureMap.field_110575_b); + } + else + { + this.func_110776_a(TextureMap.field_110576_c); + } + + GL11.glColor4f(par5, par6, par7, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((Icon) par2Icon).getOriginX(), ((Icon) par2Icon).getOriginY(), f12); + + if (itemstack.hasEffect(pass)) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + this.renderManager.renderEngine.func_110577_a(field_110798_h); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f13 = 0.76F; + GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f14 = 0.125F; + GL11.glScalef(f14, f14, f14); + float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f15, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f14, f14, f14); + f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f15, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + GL11.glPopMatrix(); + } + + /** + * Renders the item's icon or block into the UI at the specified position. + */ + public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false); + } + + public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect) + { + int k = par3ItemStack.itemID; + int l = par3ItemStack.getItemDamage(); + Object object = par3ItemStack.getIconIndex(); + float f; + int i1; + float f1; + float f2; + + Block block = (k < Block.blocksList.length ? Block.blocksList[k] : null); + if (par3ItemStack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[k].getRenderType())) + { + par2TextureManager.func_110577_a(TextureMap.field_110575_b); + GL11.glPushMatrix(); + GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel); + GL11.glScalef(10.0F, 10.0F, 10.0F); + GL11.glTranslatef(1.0F, 0.5F, 1.0F); + GL11.glScalef(1.0F, 1.0F, -1.0F); + GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); + f = (float) (i1 >> 16 & 255) / 255.0F; + f1 = (float) (i1 >> 8 & 255) / 255.0F; + f2 = (float) (i1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f, f1, f2, 1.0F); + } + + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + this.itemRenderBlocks.useInventoryTint = this.renderWithColor; + this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F); + this.itemRenderBlocks.useInventoryTint = true; + GL11.glPopMatrix(); + } + else if (Item.itemsList[k].requiresMultipleRenderPasses()) + { + GL11.glDisable(GL11.GL_LIGHTING); + + for (int j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1) + { + par2TextureManager.func_110577_a(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.field_110575_b : TextureMap.field_110576_c); + Icon icon = Item.itemsList[k].getIcon(par3ItemStack, j1); + int k1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, j1); + f1 = (float) (k1 >> 16 & 255) / 255.0F; + f2 = (float) (k1 >> 8 & 255) / 255.0F; + float f3 = (float) (k1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f1, f2, f3, 1.0F); + } + + this.renderIcon(par4, par5, icon, 16, 16); + + if (par3ItemStack.hasEffect(j1)) + { + renderEffect(par2TextureManager, par4, par5); + } + } + + GL11.glEnable(GL11.GL_LIGHTING); + } + else + { + GL11.glDisable(GL11.GL_LIGHTING); + ResourceLocation resourcelocation = par2TextureManager.func_130087_a(par3ItemStack.getItemSpriteNumber()); + par2TextureManager.func_110577_a(resourcelocation); + + if (object == null) + { + object = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(resourcelocation)).func_110572_b("missingno"); + } + + i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); + f = (float) (i1 >> 16 & 255) / 255.0F; + f1 = (float) (i1 >> 8 & 255) / 255.0F; + f2 = (float) (i1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f, f1, f2, 1.0F); + } + + this.renderIcon(par4, par5, (Icon) object, 16, 16); + GL11.glEnable(GL11.GL_LIGHTING); + + if (par3ItemStack.hasEffect(0)) + { + renderEffect(par2TextureManager, par4, par5); + } + } + + GL11.glEnable(GL11.GL_CULL_FACE); + } + + private void renderEffect (TextureManager manager, int x, int y) + { + GL11.glDepthFunc(GL11.GL_GREATER); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + manager.func_110577_a(field_110798_h); + this.zLevel -= 50.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + this.zLevel += 50.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + /** + * Render the item's icon or block into the GUI, including the glint effect. + */ + public void renderItemAndEffectIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + if (par3ItemStack != null) + { + if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5)) + { + this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true); + } + + /* Modders must handle this themselves if they use custom renderers! + if (par3ItemStack.hasEffect()) + { + GL11.glDepthFunc(GL11.GL_GREATER); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + par2TextureManager.func_110577_a(field_110798_h); + this.zLevel -= 50.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + this.zLevel += 50.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + */ + } + } + + private void renderGlint (int par1, int par2, int par3, int par4, int par5) + { + for (int j1 = 0; j1 < 2; ++j1) + { + if (j1 == 0) + { + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + } + + if (j1 == 1) + { + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + } + + float f = 0.00390625F; + float f1 = 0.00390625F; + float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F; + float f3 = 0.0F; + Tessellator tessellator = Tessellator.instance; + float f4 = 4.0F; + + if (j1 == 1) + { + f4 = -1.0F; + } + + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); + tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f), + (double) ((f3 + (float) par5) * f1)); + tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.draw(); + } + } + + /** + * Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the + * specified position. + */ + public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String) null); + } + + public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str) + { + if (par3ItemStack != null) + { + if (par3ItemStack.stackSize > 1 || par6Str != null) + { + String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + if (par3ItemStack.isItemDamaged()) + { + int k = (int) Math.round(13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage()); + int l = (int) Math.round(255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage()); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + Tessellator tessellator = Tessellator.instance; + int i1 = 255 - l << 16 | l << 8; + int j1 = (255 - l) / 4 << 16 | 16128; + this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); + this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1); + this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + } + + /** + * Adds a quad to the tesselator at the specified position with the set width and height and color. Args: + * tessellator, x, y, width, height, color + */ + private void renderQuad (Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6) + { + par1Tessellator.startDrawingQuads(); + par1Tessellator.setColorOpaque_I(par6); + par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + 0), 0.0D); + par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + par5), 0.0D); + par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D); + par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + 0), 0.0D); + par1Tessellator.draw(); + } + + public void renderIcon (int par1, int par2, Icon par3Icon, int par4, int par5) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV()); + tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV()); + tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV()); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); + tessellator.draw(); + } + + protected ResourceLocation func_110775_a (Entity par1Entity) + { + return this.func_110796_a((ArrowEntity) par1Entity); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render 1) + ret = 2; + if (stack.stackSize > 5) + ret = 3; + if (stack.stackSize > 20) + ret = 4; + if (stack.stackSize > 40) + ret = 5; + return ret; + } + + /** + * Allows for a subclass to override how many rendered items appear in a + * "mini item 3d stack" + * @param stack + * @return + */ + public byte getMiniItemCount (ItemStack stack) + { + byte ret = 1; + if (stack.stackSize > 1) + ret = 2; + if (stack.stackSize > 15) + ret = 3; + if (stack.stackSize > 31) + ret = 4; + return ret; + } +} diff --git a/tconstruct/client/entity/projectile/DaggerRender.java b/tconstruct/client/entity/projectile/DaggerRender.java new file mode 100644 index 00000000..6a12bd21 --- /dev/null +++ b/tconstruct/client/entity/projectile/DaggerRender.java @@ -0,0 +1,633 @@ +package tconstruct.client.entity.projectile; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import tconstruct.entity.projectile.DaggerEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class DaggerRender extends Render +{ + private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private RenderBlocks itemRenderBlocks = new RenderBlocks(); + + /** The RNG used in RenderItem (for bobbing itemstacks on the ground) */ + private Random random = new Random(); + public boolean renderWithColor = true; + + /** Defines the zLevel of rendering of item on GUI. */ + public float zLevel; + public static boolean renderInFrame; + + public DaggerRender() + { + this.shadowSize = 0.15F; + this.shadowOpaque = 0.75F; + } + + /** + * Renders the item + */ + public void doRenderItem (DaggerEntity par1ArrowEntity, double par2, double par4, double par6, float par8, float par9) + { + this.func_110777_b(par1ArrowEntity); + this.random.setSeed(187L); + ItemStack itemstack = par1ArrowEntity.getEntityItem(); + + if (itemstack.getItem() != null) + { + GL11.glPushMatrix(); + float f2 = shouldBob() ? MathHelper.sin(((float) 0 + par9) / 10.0F + 0) * 0.1F + 0.1F : 0F; + float f3 = (((float) 0 + par9) / 20.0F + 0) * (180F / (float) Math.PI); + byte b0 = getMiniBlockCount(itemstack); + + GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f4; + float f5; + float f6; + int i; + + Block block = null; + if (itemstack.itemID < Block.blocksList.length) + { + block = Block.blocksList[itemstack.itemID]; + } + + if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType())) + { + GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); + + if (renderInFrame) + { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glTranslatef(0.0F, 0.05F, 0.0F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + + float f7 = 0.25F; + int j = block.getRenderType(); + + if (j == 1 || j == 19 || j == 12 || j == 2) + { + f7 = 0.5F; + } + + GL11.glScalef(f7, f7, f7); + + for (i = 0; i < b0; ++i) + { + GL11.glPushMatrix(); + + if (i > 0) + { + f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; + GL11.glTranslatef(f5, f4, f6); + } + + f5 = 1.0F; + this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5); + GL11.glPopMatrix(); + } + } + else + { + float f8; + + if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses()) + { + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) + { + this.random.setSeed(187L); + Icon icon = itemstack.getItem().getIcon(itemstack, k); + f8 = 1.0F; + + if (this.renderWithColor) + { + i = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, k); + f5 = (float) (i >> 16 & 255) / 255.0F; + f4 = (float) (i >> 8 & 255) / 255.0F; + f6 = (float) (i & 255) / 255.0F; + GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F); + this.renderDroppedItem(par1ArrowEntity, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k); + } + else + { + this.renderDroppedItem(par1ArrowEntity, icon, b0, par9, 1.0F, 1.0F, 1.0F, k); + } + } + } + else + { + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + Icon icon1 = itemstack.getIconIndex(); + + if (this.renderWithColor) + { + int l = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, 0); + f8 = (float) (l >> 16 & 255) / 255.0F; + float f9 = (float) (l >> 8 & 255) / 255.0F; + f5 = (float) (l & 255) / 255.0F; + f4 = 1.0F; + this.renderDroppedItem(par1ArrowEntity, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4); + } + else + { + this.renderDroppedItem(par1ArrowEntity, icon1, b0, par9, 1.0F, 1.0F, 1.0F); + } + } + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation func_110796_a (DaggerEntity par1ArrowEntity) + { + return this.renderManager.renderEngine.func_130087_a(par1ArrowEntity.getEntityItem().getItemSpriteNumber()); + } + + /** + * Renders a dropped item + */ + private void renderDroppedItem (DaggerEntity par1ArrowEntity, Icon par2Icon, int par3, float par4, float par5, float par6, float par7) + { + renderDroppedItem(par1ArrowEntity, par2Icon, par3, par4, par5, par6, par7, 0); + } + + private void renderDroppedItem (DaggerEntity dagger, Icon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass) + { + Tessellator tessellator = Tessellator.instance; + + if (par2Icon == null) + { + TextureManager texturemanager = Minecraft.getMinecraft().func_110434_K(); + ResourceLocation resourcelocation = texturemanager.func_130087_a(dagger.getEntityItem().getItemSpriteNumber()); + par2Icon = ((TextureMap) texturemanager.func_110581_b(resourcelocation)).func_110572_b("missingno"); + } + + float f4 = ((Icon) par2Icon).getMinU(); + float f5 = ((Icon) par2Icon).getMaxU(); + float f6 = ((Icon) par2Icon).getMinV(); + float f7 = ((Icon) par2Icon).getMaxV(); + float f8 = 1.0F; + float f9 = 0.5F; + float f10 = 0.25F; + float f11; + float rotation = dagger.prevRotationPitch + (dagger.rotationPitch - dagger.prevRotationPitch) * par7; + + GL11.glPushMatrix(); + + if (renderInFrame) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + else + { + GL11.glRotatef((((float) 0 + par4) / 20.0F + 0) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); + } + + float f12 = 0.0625F; + f11 = 0.021875F; + ItemStack itemstack = dagger.getEntityItem(); + int j = itemstack.stackSize; + byte b0 = getMiniItemCount(itemstack); + + GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F)); + + for (int k = 0; k < b0; ++k) + { + // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... + if (k > 0 && shouldSpreadItems()) + { + float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + GL11.glTranslatef(x, y, f12 + f11); + } + else + { + GL11.glTranslatef(0f, 0f, f12 + f11); + } + + if (itemstack.getItemSpriteNumber() == 0) + { + this.func_110776_a(TextureMap.field_110575_b); + } + else + { + this.func_110776_a(TextureMap.field_110576_c); + } + + GL11.glColor4f(par5, par6, par7, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((Icon) par2Icon).getOriginX(), ((Icon) par2Icon).getOriginY(), f12); + + if (itemstack.hasEffect(pass)) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + this.renderManager.renderEngine.func_110577_a(field_110798_h); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f13 = 0.76F; + GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f14 = 0.125F; + GL11.glScalef(f14, f14, f14); + float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f15, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f14, f14, f14); + f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f15, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + GL11.glPopMatrix(); + } + + /** + * Renders the item's icon or block into the UI at the specified position. + */ + public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false); + } + + public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect) + { + int k = par3ItemStack.itemID; + int l = par3ItemStack.getItemDamage(); + Object object = par3ItemStack.getIconIndex(); + float f; + int i1; + float f1; + float f2; + + Block block = (k < Block.blocksList.length ? Block.blocksList[k] : null); + if (par3ItemStack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[k].getRenderType())) + { + par2TextureManager.func_110577_a(TextureMap.field_110575_b); + GL11.glPushMatrix(); + GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel); + GL11.glScalef(10.0F, 10.0F, 10.0F); + GL11.glTranslatef(1.0F, 0.5F, 1.0F); + GL11.glScalef(1.0F, 1.0F, -1.0F); + GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); + f = (float) (i1 >> 16 & 255) / 255.0F; + f1 = (float) (i1 >> 8 & 255) / 255.0F; + f2 = (float) (i1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f, f1, f2, 1.0F); + } + + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + this.itemRenderBlocks.useInventoryTint = this.renderWithColor; + this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F); + this.itemRenderBlocks.useInventoryTint = true; + GL11.glPopMatrix(); + } + else if (Item.itemsList[k].requiresMultipleRenderPasses()) + { + GL11.glDisable(GL11.GL_LIGHTING); + + for (int j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1) + { + par2TextureManager.func_110577_a(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.field_110575_b : TextureMap.field_110576_c); + Icon icon = Item.itemsList[k].getIcon(par3ItemStack, j1); + int k1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, j1); + f1 = (float) (k1 >> 16 & 255) / 255.0F; + f2 = (float) (k1 >> 8 & 255) / 255.0F; + float f3 = (float) (k1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f1, f2, f3, 1.0F); + } + + this.renderIcon(par4, par5, icon, 16, 16); + + if (par3ItemStack.hasEffect(j1)) + { + renderEffect(par2TextureManager, par4, par5); + } + } + + GL11.glEnable(GL11.GL_LIGHTING); + } + else + { + GL11.glDisable(GL11.GL_LIGHTING); + ResourceLocation resourcelocation = par2TextureManager.func_130087_a(par3ItemStack.getItemSpriteNumber()); + par2TextureManager.func_110577_a(resourcelocation); + + if (object == null) + { + object = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(resourcelocation)).func_110572_b("missingno"); + } + + i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); + f = (float) (i1 >> 16 & 255) / 255.0F; + f1 = (float) (i1 >> 8 & 255) / 255.0F; + f2 = (float) (i1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f, f1, f2, 1.0F); + } + + this.renderIcon(par4, par5, (Icon) object, 16, 16); + GL11.glEnable(GL11.GL_LIGHTING); + + if (par3ItemStack.hasEffect(0)) + { + renderEffect(par2TextureManager, par4, par5); + } + } + + GL11.glEnable(GL11.GL_CULL_FACE); + } + + private void renderEffect (TextureManager manager, int x, int y) + { + GL11.glDepthFunc(GL11.GL_GREATER); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + manager.func_110577_a(field_110798_h); + this.zLevel -= 50.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + this.zLevel += 50.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + /** + * Render the item's icon or block into the GUI, including the glint effect. + */ + public void renderItemAndEffectIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + if (par3ItemStack != null) + { + if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5)) + { + this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true); + } + + /* Modders must handle this themselves if they use custom renderers! + if (par3ItemStack.hasEffect()) + { + GL11.glDepthFunc(GL11.GL_GREATER); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + par2TextureManager.func_110577_a(field_110798_h); + this.zLevel -= 50.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + this.zLevel += 50.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + */ + } + } + + private void renderGlint (int par1, int par2, int par3, int par4, int par5) + { + for (int j1 = 0; j1 < 2; ++j1) + { + if (j1 == 0) + { + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + } + + if (j1 == 1) + { + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + } + + float f = 0.00390625F; + float f1 = 0.00390625F; + float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F; + float f3 = 0.0F; + Tessellator tessellator = Tessellator.instance; + float f4 = 4.0F; + + if (j1 == 1) + { + f4 = -1.0F; + } + + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); + tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f), + (double) ((f3 + (float) par5) * f1)); + tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.draw(); + } + } + + /** + * Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the + * specified position. + */ + public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String) null); + } + + public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str) + { + if (par3ItemStack != null) + { + if (par3ItemStack.stackSize > 1 || par6Str != null) + { + String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + if (par3ItemStack.isItemDamaged()) + { + int k = (int) Math.round(13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage()); + int l = (int) Math.round(255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage()); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + Tessellator tessellator = Tessellator.instance; + int i1 = 255 - l << 16 | l << 8; + int j1 = (255 - l) / 4 << 16 | 16128; + this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); + this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1); + this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + } + + /** + * Adds a quad to the tesselator at the specified position with the set width and height and color. Args: + * tessellator, x, y, width, height, color + */ + private void renderQuad (Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6) + { + par1Tessellator.startDrawingQuads(); + par1Tessellator.setColorOpaque_I(par6); + par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + 0), 0.0D); + par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + par5), 0.0D); + par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D); + par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + 0), 0.0D); + par1Tessellator.draw(); + } + + public void renderIcon (int par1, int par2, Icon par3Icon, int par4, int par5) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV()); + tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV()); + tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV()); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); + tessellator.draw(); + } + + protected ResourceLocation func_110775_a (Entity par1Entity) + { + return this.func_110796_a((DaggerEntity) par1Entity); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render 1) + ret = 2; + if (stack.stackSize > 5) + ret = 3; + if (stack.stackSize > 20) + ret = 4; + if (stack.stackSize > 40) + ret = 5; + return ret; + } + + /** + * Allows for a subclass to override how many rendered items appear in a + * "mini item 3d stack" + * @param stack + * @return + */ + public byte getMiniItemCount (ItemStack stack) + { + byte ret = 1; + if (stack.stackSize > 1) + ret = 2; + if (stack.stackSize > 15) + ret = 3; + if (stack.stackSize > 31) + ret = 4; + return ret; + } +} diff --git a/tconstruct/client/entity/projectile/DaggerRenderOld.java b/tconstruct/client/entity/projectile/DaggerRenderOld.java new file mode 100644 index 00000000..50e69692 --- /dev/null +++ b/tconstruct/client/entity/projectile/DaggerRenderOld.java @@ -0,0 +1,68 @@ +package tconstruct.client.entity.projectile; + +import java.util.Random; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import tconstruct.entity.projectile.DaggerEntity; + +public class DaggerRenderOld extends RangedRenderBase +{ + public DaggerRenderOld(double d) + { + System.out.println("new renderer"); + shadowSize = 0.15F; + shadowOpaque = 0.75F; + daggerRotation = (float) d; + } + + public void doRender (DaggerEntity dagger, double d, double d1, double d2, float f, float f1) + { + if ((new Random()).nextFloat() > 0.8) + System.out.println("rendering dagger " + dagger.texID + " " + dagger.tex2ID); + GL11.glPushMatrix(); + GL11.glTranslatef((float) d, (float) d1, (float) d2); + GL11.glRotatef(f, 0.0F, 1.0F, 0.0F); + float f2 = dagger.prevRotationPitch + (dagger.rotationPitch - dagger.prevRotationPitch) * f1; + GL11.glRotatef(-f2, 1.0F, 0.0F, 0.0F); + if (!dagger.onGround) + { + float f3 = dagger.prevBoomerangRotation + (dagger.boomerangRotation - dagger.prevBoomerangRotation) * f1 * 1.1F; + GL11.glRotatef(f3, 1.0F, 0.0F, 0.0F); + } + GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F); + //loadTexture("/infi2x2/daggers.png"); + Tessellator tessellator = Tessellator.instance; + int i = 0;//dagger.getTexID(); + float f4 = ((float) ((i % 16) * 16) + 0.0F) / 256F; + float f5 = ((float) ((i % 16) * 16) + 15.99F) / 256F; + float f6 = ((float) ((i / 16) * 16) + 0.0F) / 256F; + float f7 = ((float) ((i / 16) * 16) + 15.99F) / 256F; + float f8 = 1.0F; + GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); + float f9 = 0.0625F; + GL11.glTranslatef(-0.5F, 0.0F, -0.5F); + renderItem(tessellator, f4, f5, f6, f7, f8, f9); + GL11.glPopMatrix(); + + } + + @Override + public void doRender (Entity entity, double d, double d1, double d2, float f, float f1) + { + doRender((DaggerEntity) entity, d, d1, d2, f, f1); + } + + public float daggerRotation; + + @Override + protected ResourceLocation func_110775_a (Entity entity) + { + // TODO Auto-generated method stub + return null; + } +} diff --git a/tconstruct/client/entity/projectile/LaunchedItemRender.java b/tconstruct/client/entity/projectile/LaunchedItemRender.java new file mode 100644 index 00000000..f03a1d9f --- /dev/null +++ b/tconstruct/client/entity/projectile/LaunchedItemRender.java @@ -0,0 +1,100 @@ +package tconstruct.client.entity.projectile; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemPotion; +import net.minecraft.potion.PotionHelper; +import net.minecraft.util.Icon; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import tconstruct.entity.projectile.LaunchedPotion; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class LaunchedItemRender extends Render +{ + private Item field_94151_a; + private int field_94150_f; + + public LaunchedItemRender(Item par1Item, int par2) + { + this.field_94151_a = par1Item; + this.field_94150_f = par2; + } + + public LaunchedItemRender(Item par1Item) + { + this(par1Item, 0); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render> 16 & 255) / 255.0F; + float f3 = (float)(i >> 8 & 255) / 255.0F; + float f4 = (float)(i & 255) / 255.0F; + GL11.glColor3f(f2, f3, f4); + GL11.glPushMatrix(); + this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay")); + GL11.glPopMatrix(); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + } + + this.func_77026_a(tessellator, icon); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation func_110775_a(Entity par1Entity) + { + return TextureMap.field_110576_c; + } + + private void func_77026_a(Tessellator par1Tessellator, Icon par2Icon) + { + float f = par2Icon.getMinU(); + float f1 = par2Icon.getMaxU(); + float f2 = par2Icon.getMinV(); + float f3 = par2Icon.getMaxV(); + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + par1Tessellator.startDrawingQuads(); + par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); + par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3); + par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3); + par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2); + par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2); + par1Tessellator.draw(); + } +} diff --git a/tconstruct/client/entity/projectile/RangedRenderBase.java b/tconstruct/client/entity/projectile/RangedRenderBase.java new file mode 100644 index 00000000..793ca4e8 --- /dev/null +++ b/tconstruct/client/entity/projectile/RangedRenderBase.java @@ -0,0 +1,90 @@ +package tconstruct.client.entity.projectile; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; + +public abstract class RangedRenderBase extends Render +{ + public RangedRenderBase() + { + } + + public void doRender (Entity entity, double d, double d1, double d2, float f, float f1) + { + } + + public void renderItem (Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) + { + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + tessellator.addVertexWithUV(0.0D, 0.0D - (double) f5, 0.0D, f1, f3); + tessellator.addVertexWithUV(f4, 0.0D - (double) f5, 0.0D, f, f3); + tessellator.addVertexWithUV(f4, 0.0D - (double) f5, 1.0D, f, f2); + tessellator.addVertexWithUV(0.0D, 0.0D - (double) f5, 1.0D, f1, f2); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1F); + tessellator.addVertexWithUV(0.0D, 0.0D, 1.0D, f1, f2); + tessellator.addVertexWithUV(f4, 0.0D, 1.0D, f, f2); + tessellator.addVertexWithUV(f4, 0.0D, 0.0D, f, f3); + tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, f1, f3); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1F, 0.0F, 0.0F); + for (int i = 0; i < 16; i++) + { + float f6 = (float) i / 16F; + float f10 = (f1 + (f - f1) * f6) - 0.001953125F; + float f14 = f4 * f6 + 0.0625F; + tessellator.addVertexWithUV(f14, 0.0F - f5, 0.0D, f10, f3); + tessellator.addVertexWithUV(f14, 0.0D, 0.0D, f10, f3); + tessellator.addVertexWithUV(f14, 0.0D, 1.0D, f10, f2); + tessellator.addVertexWithUV(f14, 0.0F - f5, 1.0D, f10, f2); + } + + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + for (int j = 0; j < 16; j++) + { + float f7 = (float) j / 16F; + float f11 = (f1 + (f - f1) * f7) - 0.001953125F; + float f15 = f4 * f7; + tessellator.addVertexWithUV(f15, 0.0F - f5, 1.0D, f11, f2); + tessellator.addVertexWithUV(f15, 0.0D, 1.0D, f11, f2); + tessellator.addVertexWithUV(f15, 0.0D, 0.0D, f11, f3); + tessellator.addVertexWithUV(f15, 0.0F - f5, 0.0D, f11, f3); + } + + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + for (int k = 0; k < 16; k++) + { + float f8 = (float) k / 16F; + float f12 = (f3 + (f2 - f3) * f8) - 0.001953125F; + float f16 = f4 * f8; + tessellator.addVertexWithUV(0.0D, 0.0D, f16, f1, f12); + tessellator.addVertexWithUV(f4, 0.0D, f16, f, f12); + tessellator.addVertexWithUV(f4, 0.0F - f5, f16, f, f12); + tessellator.addVertexWithUV(0.0D, 0.0F - f5, f16, f1, f12); + } + + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1F, 0.0F); + for (int l = 0; l < 16; l++) + { + float f9 = (float) l / 16F; + float f13 = (f3 + (f2 - f3) * f9) - 0.001953125F; + float f17 = f4 * f9 + 0.0625F; + tessellator.addVertexWithUV(f4, 0.0D, f17, f, f13); + tessellator.addVertexWithUV(0.0D, 0.0D, f17, f1, f13); + tessellator.addVertexWithUV(0.0D, 0.0F - f5, f17, f1, f13); + tessellator.addVertexWithUV(f4, 0.0F - f5, f17, f, f13); + } + + tessellator.draw(); + } +} diff --git a/tconstruct/client/gui/ArmorExtendedGui.java b/tconstruct/client/gui/ArmorExtendedGui.java new file mode 100644 index 00000000..234a9a0d --- /dev/null +++ b/tconstruct/client/gui/ArmorExtendedGui.java @@ -0,0 +1,154 @@ +package tconstruct.client.gui; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.InventoryEffectRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import tconstruct.common.TContent; +import tconstruct.inventory.ArmorExtendedContainer; +import tconstruct.util.player.ArmorExtended; + +public class ArmorExtendedGui extends InventoryEffectRenderer +{ + public InventoryPlayer inv; + public ArmorExtended stats; + + private float xSize_lo; + private float ySize_lo; + + public ArmorExtendedGui(InventoryPlayer inventoryplayer, ArmorExtended holder) + { + super(new ArmorExtendedContainer(inventoryplayer, holder)); + inv = inventoryplayer; + stats = holder; + } + + public void initGui () + { + super.initGui(); + + int cornerX = guiLeft; + int cornerY = (this.height - this.ySize) / 2; + this.buttonList.clear(); + + InventoryTab tab = new InventoryTab(2, cornerX, cornerY - 28, new ItemStack(Block.workbench), 0); + this.buttonList.add(tab); + tab = new InventoryTab(3, cornerX + 28, cornerY - 28, new ItemStack(Item.plateDiamond), 1); + tab.enabled = false; + this.buttonList.add(tab); + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + //fontRenderer.drawString(StatCollector.translateToLocal("inventory.armorextended"), 60, 6, 0x404040); + //fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040); + } + + public void drawScreen (int par1, int par2, float par3) + { + super.drawScreen(par1, par2, par3); + this.xSize_lo = (float) par1; + this.ySize_lo = (float) par2; + if (stats.inventory[2] != null && stats.inventory[2].getItem() == TContent.knapsack) + { + if (this.buttonList.size() < 3) + { + int cornerX = guiLeft; + int cornerY = (this.height - this.ySize) / 2; + InventoryTab tab = new InventoryTab(4, cornerX + 56, cornerY - 28, new ItemStack(TContent.knapsack), 1); + this.buttonList.add(tab); + } + } + else + { + if (this.buttonList.size() >= 3) + { + buttonList.remove(2); + } + } + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/armorextended.png"); + + protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + //mc.renderEngine.bindTexture("/mods/tinker/textures/gui/armorextended.png"); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = guiLeft; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); + + if (!stats.isStackInSlot(0)) + drawTexturedModalRect(cornerX + 79, cornerY + 16, 176, 9, 18, 18); + if (!stats.isStackInSlot(1)) + drawTexturedModalRect(cornerX + 79, cornerY + 34, 176, 27, 18, 18); + if (!stats.isStackInSlot(2)) + drawTexturedModalRect(cornerX + 115, cornerY + 16, 212, 9, 18, 18); + if (!stats.isStackInSlot(3)) + drawTexturedModalRect(cornerX + 115, cornerY + 34, 212, 27, 18, 18); + if (!stats.isStackInSlot(4)) + drawTexturedModalRect(cornerX + 151, cornerY + 16, 230, 0, 18, 18); + if (!stats.isStackInSlot(5)) + drawTexturedModalRect(cornerX + 151, cornerY + 34, 230, 18, 18, 18); + if (!stats.isStackInSlot(6)) + drawTexturedModalRect(cornerX + 151, cornerY + 52, 230, 36, 18, 18); + + cornerX = this.guiLeft; + cornerY = this.guiTop; + drawPlayerOnGui(this.mc, cornerX + 33, cornerY + 75, 30, (float) (cornerX + 51) - this.xSize_lo, (float) (cornerY + 75 - 50) - this.ySize_lo); + } + + public static void drawPlayerOnGui (Minecraft par0Minecraft, int par1, int par2, int par3, float par4, float par5) + { + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef((float) par1, (float) par2, 50.0F); + GL11.glScalef((float) (-par3), (float) par3, (float) par3); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + float f2 = par0Minecraft.thePlayer.renderYawOffset; + float f3 = par0Minecraft.thePlayer.rotationYaw; + float f4 = par0Minecraft.thePlayer.rotationPitch; + par4 -= 19; + GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-((float) Math.atan((double) (par5 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); + par0Minecraft.thePlayer.renderYawOffset = (float) Math.atan((double) (par4 / 40.0F)) * 20.0F; + par0Minecraft.thePlayer.rotationYaw = (float) Math.atan((double) (par4 / 40.0F)) * 40.0F; + par0Minecraft.thePlayer.rotationPitch = -((float) Math.atan((double) (par5 / 40.0F))) * 20.0F; + par0Minecraft.thePlayer.rotationYawHead = par0Minecraft.thePlayer.rotationYaw; + GL11.glTranslatef(0.0F, par0Minecraft.thePlayer.yOffset, 0.0F); + RenderManager.instance.playerViewY = 180.0F; + RenderManager.instance.renderEntityWithPosYaw(par0Minecraft.thePlayer, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); + par0Minecraft.thePlayer.renderYawOffset = f2; + par0Minecraft.thePlayer.rotationYaw = f3; + par0Minecraft.thePlayer.rotationPitch = f4; + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + /*protected void keyTyped(char par1, int par2) + { + if (par2 == TControls.armorKey.keyCode) + { + this.mc.thePlayer.closeScreen(); + } + + super.keyTyped(par1, par2); + }*/ +} diff --git a/tconstruct/client/gui/DrawbridgeGui.java b/tconstruct/client/gui/DrawbridgeGui.java new file mode 100644 index 00000000..dee49a6b --- /dev/null +++ b/tconstruct/client/gui/DrawbridgeGui.java @@ -0,0 +1,40 @@ +package tconstruct.client.gui; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.DrawbridgeLogic; + +public class DrawbridgeGui extends GuiContainer +{ + public DrawbridgeLogic logic; + + public DrawbridgeGui(InventoryPlayer inventoryplayer, DrawbridgeLogic frypan, World world, int x, int y, int z) + { + super(frypan.getGuiContainer(inventoryplayer, world, x, y, z)); + logic = frypan; + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + //fontRenderer.drawString(StatCollector.translateToLocal("aggregator.glowstone"), 60, 6, 0x404040); + fontRenderer.drawString("Drawbridge", 8, 6, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/drawbridge.png"); + + protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); + } +} diff --git a/tconstruct/client/gui/FrypanGui.java b/tconstruct/client/gui/FrypanGui.java new file mode 100644 index 00000000..d8108c01 --- /dev/null +++ b/tconstruct/client/gui/FrypanGui.java @@ -0,0 +1,46 @@ +package tconstruct.client.gui; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.FrypanLogic; + +public class FrypanGui extends GuiContainer +{ + public FrypanLogic logic; + + public FrypanGui(InventoryPlayer inventoryplayer, FrypanLogic frypan, World world, int x, int y, int z) + { + super(frypan.getGuiContainer(inventoryplayer, world, x, y, z)); + logic = frypan; + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + fontRenderer.drawString(StatCollector.translateToLocal("crafters.Frypan"), 60, 6, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/frypan.png"); + + protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); + if (logic.fuel > 0) + { + int fuel = logic.gaugeFuelScaled(12); + drawTexturedModalRect(cornerX + 27, (cornerY + 40) - fuel, 176, 12 - fuel, 14, fuel + 2); + } + int fuelgague = logic.gaugeProgressScaled(24); + drawTexturedModalRect(cornerX + 140, cornerY + 8, 176, 14, fuelgague, 16); + } +} diff --git a/tconstruct/client/gui/GlowstoneAggregatorGui.java b/tconstruct/client/gui/GlowstoneAggregatorGui.java new file mode 100644 index 00000000..e6dd131b --- /dev/null +++ b/tconstruct/client/gui/GlowstoneAggregatorGui.java @@ -0,0 +1,47 @@ +package tconstruct.client.gui; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.GlowstoneAggregator; + +public class GlowstoneAggregatorGui extends GuiContainer +{ + public GlowstoneAggregator logic; + + public GlowstoneAggregatorGui(InventoryPlayer inventoryplayer, GlowstoneAggregator frypan, World world, int x, int y, int z) + { + super(frypan.getGuiContainer(inventoryplayer, world, x, y, z)); + logic = frypan; + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + //fontRenderer.drawString(StatCollector.translateToLocal("aggregator.glowstone"), 60, 6, 0x404040); + fontRenderer.drawString("Glowstone Aggregator", 8, 6, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/aggregator.png"); + + protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); + /*if (logic.fuel > 0) + { + int fuel = logic.gaugeFuelScaled(12); + drawTexturedModalRect(cornerX + 27, (cornerY + 40) - fuel, 176, 12 - fuel, 14, fuel + 2); + } + int fuelgague = logic.gaugeProgressScaled(24); + drawTexturedModalRect(cornerX + 140, cornerY + 8, 176, 14, fuelgague, 16);*/ + } +} diff --git a/tconstruct/client/gui/GuiButtonTool.java b/tconstruct/client/gui/GuiButtonTool.java new file mode 100644 index 00000000..745cd4c2 --- /dev/null +++ b/tconstruct/client/gui/GuiButtonTool.java @@ -0,0 +1,55 @@ +package tconstruct.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import tconstruct.library.client.ToolGuiElement; + + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiButtonTool extends GuiButton +{ + /** + * True for pointing right (next page), false for pointing left (previous page). + */ + int textureX; + int textureY; + public String texture; + public ToolGuiElement element; + private static ResourceLocation background;// = new ResourceLocation("tinker", "textures/gui/armorextended.png"); + + public GuiButtonTool(int id, int posX, int posY, int texX, int texY, String domain, String tex, ToolGuiElement e) + { + super(id, posX, posY, 18, 18, ""); + textureX = texX; + textureY = texY; + texture = tex; + element = e; + background = new ResourceLocation(domain, tex); + } + + /** + * Draws this button to the screen. + */ + public void drawButton (Minecraft mc, int mouseX, int mouseY) + { + if (this.drawButton) + { + boolean var4 = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.func_110434_K().func_110577_a(background); + + this.field_82253_i = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + int var5 = this.getHoverState(this.field_82253_i); + int index = 18 * getHoverState(field_82253_i); + this.drawTexturedModalRect(this.xPosition, this.yPosition, 144 + index * 2, 216, 18, 18); + this.drawTexturedModalRect(this.xPosition, this.yPosition, textureX * 18, textureY * 18, 18, 18); + } + } +} diff --git a/tconstruct/client/gui/GuiManual.java b/tconstruct/client/gui/GuiManual.java new file mode 100644 index 00000000..6d131804 --- /dev/null +++ b/tconstruct/client/gui/GuiManual.java @@ -0,0 +1,193 @@ +package tconstruct.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import tconstruct.client.RenderItemCopy; +import tconstruct.client.TProxyClient; +import tconstruct.client.block.SmallFontRenderer; +import tconstruct.client.pages.BookPage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiManual extends GuiScreen +{ + ItemStack itemstackBook; + Document manual; + public RenderItemCopy renderitem = new RenderItemCopy(); + int bookImageWidth = 206; + int bookImageHeight = 200; + int bookTotalPages = 1; + int currentPage; + int maxPages; + + private TurnPageButton buttonNextPage; + private TurnPageButton buttonPreviousPage; + + BookPage pageLeft; + BookPage pageRight; + + public SmallFontRenderer fonts = TProxyClient.smallFontRenderer; + + public GuiManual(ItemStack stack, Document doc) + { + this.mc = Minecraft.getMinecraft(); + this.itemstackBook = stack; + currentPage = 0; //Stack page + manual = doc; + //renderitem.renderInFrame = true; + } + + /*@Override + public void setWorldAndResolution (Minecraft minecraft, int w, int h) + { + this.guiParticles = new GuiParticle(minecraft); + this.mc = minecraft; + this.width = w; + this.height = h; + this.buttonList.clear(); + this.initGui(); + }*/ + + public void initGui () + { + maxPages = manual.getElementsByTagName("page").getLength(); + updateText(); + int xPos = (this.width) / 2; + this.buttonList.add(this.buttonNextPage = new TurnPageButton(1, xPos + bookImageWidth - 50, 180, true)); + this.buttonList.add(this.buttonPreviousPage = new TurnPageButton(2, xPos - bookImageWidth + 24, 180, false)); + } + + protected void actionPerformed (GuiButton button) + { + if (button.enabled) + { + if (button.id == 1) + currentPage += 2; + if (button.id == 2) + currentPage -= 2; + + updateText(); + } + } + + void updateText () + { + if (maxPages % 2 == 1) + { + if (currentPage > maxPages) + currentPage = maxPages; + } + else + { + if (currentPage >= maxPages) + currentPage = maxPages - 2; + } + if (currentPage % 2 == 1) + currentPage--; + if (currentPage < 0) + currentPage = 0; + + NodeList nList = manual.getElementsByTagName("page"); + + Node node = nList.item(currentPage); + if (node.getNodeType() == Node.ELEMENT_NODE) + { + Element element = (Element) node; + Class clazz = TProxyClient.getPageClass(element.getAttribute("type")); + if (clazz != null) + { + try + { + pageLeft = (BookPage) clazz.newInstance(); + pageLeft.init(this, 0); + pageLeft.readPageFromXML(element); + } + catch (Exception e) + { + } + } + else + { + pageLeft = null; + } + } + + node = nList.item(currentPage + 1); + if (node != null && node.getNodeType() == Node.ELEMENT_NODE) + { + Element element = (Element) node; + Class clazz = TProxyClient.getPageClass(element.getAttribute("type")); + if (clazz != null) + { + try + { + pageRight = (BookPage) clazz.newInstance(); + pageRight.init(this, 1); + pageRight.readPageFromXML(element); + } + catch (Exception e) + { + } + } + else + { + pageLeft = null; + } + } + else + { + pageRight = null; + } + } + + private static final ResourceLocation bookRight = new ResourceLocation("tinker", "textures/gui/bookright.png"); + private static final ResourceLocation bookLeft = new ResourceLocation("tinker", "textures/gui/bookleft.png"); + + public void drawScreen (int par1, int par2, float par3) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(bookRight); + int localWidth = (this.width) / 2; + byte localHeight = 8; + this.drawTexturedModalRect(localWidth, localHeight, 0, 0, this.bookImageWidth, this.bookImageHeight); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(bookLeft); + localWidth = localWidth - this.bookImageWidth; + this.drawTexturedModalRect(localWidth, localHeight, 256 - this.bookImageWidth, 0, this.bookImageWidth, this.bookImageHeight); + + super.drawScreen(par1, par2, par3); //16, 12, 220, 12 + + if (pageLeft != null) + pageLeft.renderBackgroundLayer(localWidth + 16, localHeight + 12); + if (pageRight != null) + pageRight.renderBackgroundLayer(localWidth + 220, localHeight + 12); + + if (pageLeft != null) + pageLeft.renderContentLayer(localWidth + 16, localHeight + 12); + if (pageRight != null) + pageRight.renderContentLayer(localWidth + 220, localHeight + 12); + } + + public Minecraft getMC () + { + return mc; + } + + public boolean doesGuiPauseGame () + { + return false; + } +} diff --git a/tconstruct/client/gui/InventoryTab.java b/tconstruct/client/gui/InventoryTab.java new file mode 100644 index 00000000..5cdf1604 --- /dev/null +++ b/tconstruct/client/gui/InventoryTab.java @@ -0,0 +1,77 @@ +package tconstruct.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import tconstruct.client.TControls; +import tconstruct.client.TProxyClient; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class InventoryTab extends GuiButton +{ + int textureX; + //String texture = "/gui/allitems.png"; + ItemStack renderStack; + private static final ResourceLocation background = new ResourceLocation("gui/allitems.png"); + + public InventoryTab(int id, int posX, int posY, ItemStack stack, int texX) + { + super(id, posX, posY, 28, 32, ""); + textureX = texX; + renderStack = stack; + } + + /** + * Draws this button to the screen. + */ + public void drawButton (Minecraft mc, int mouseX, int mouseY) + { + if (this.drawButton) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.func_110434_K().func_110577_a(background); + //mc.renderEngine.bindTexture(texture); + + int yTexPos = this.enabled ? 0 : 32; + int ySize = this.enabled ? 28 : 32; + + this.drawTexturedModalRect(this.xPosition, this.yPosition, textureX * 28, yTexPos, 28, ySize); + + RenderHelper.enableGUIStandardItemLighting(); + this.zLevel = 100.0F; + TProxyClient.itemRenderer.zLevel = 100.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + TProxyClient.itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, renderStack, xPosition + 6, yPosition + 8); + TProxyClient.itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, renderStack, xPosition + 6, yPosition + 8); + GL11.glDisable(GL11.GL_LIGHTING); + TProxyClient.itemRenderer.zLevel = 0.0F; + this.zLevel = 0.0F; + RenderHelper.disableStandardItemLighting(); + } + } + + public boolean mousePressed (Minecraft mc, int mouseX, int mouseY) + { + boolean inWindow = this.enabled && this.drawButton && mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + if (inWindow) + { + if (this.id == 2) + TProxyClient.openInventoryGui(); + if (this.id == 3) + TControls.openArmorGui(); + if (this.id == 4) + TControls.openKnapsackGui(); + } + return inWindow; + } +} diff --git a/tconstruct/client/gui/KnapsackGui.java b/tconstruct/client/gui/KnapsackGui.java new file mode 100644 index 00000000..0ba14a53 --- /dev/null +++ b/tconstruct/client/gui/KnapsackGui.java @@ -0,0 +1,72 @@ +package tconstruct.client.gui; + +import net.minecraft.block.Block; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; + +import tconstruct.common.TContent; +import tconstruct.inventory.KnapsackContainer; +import tconstruct.util.player.KnapsackInventory; + +public class KnapsackGui extends GuiContainer +{ + public InventoryPlayer inv; + public KnapsackInventory stats; + + public KnapsackGui(InventoryPlayer inventoryplayer, KnapsackInventory holder) + { + super(new KnapsackContainer(inventoryplayer, holder)); + inv = inventoryplayer; + stats = holder; + } + + public void initGui () + { + super.initGui(); + + int cornerX = guiLeft; + int cornerY = (this.height - this.ySize) / 2; + this.buttonList.clear(); + + InventoryTab tab = new InventoryTab(2, cornerX, cornerY - 28, new ItemStack(Block.workbench), 0); + this.buttonList.add(tab); + tab = new InventoryTab(3, cornerX + 28, cornerY - 28, new ItemStack(Item.plateDiamond), 1); + this.buttonList.add(tab); + tab = new InventoryTab(4, cornerX + 56, cornerY - 28, new ItemStack(TContent.knapsack), 1); + tab.enabled = false; + this.buttonList.add(tab); + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + fontRenderer.drawString(StatCollector.translateToLocal("inventory.knapsack"), 8, 6, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 4, 0x404040); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/knapsack.png"); + + protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = guiLeft; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); + } + + /*protected void keyTyped(char par1, int par2) + { + if (par2 == TControls.armorKey.keyCode) + { + this.mc.thePlayer.closeScreen(); + } + + super.keyTyped(par1, par2); + }*/ +} diff --git a/tconstruct/client/gui/MiniGardyGui.java b/tconstruct/client/gui/MiniGardyGui.java new file mode 100644 index 00000000..a912b96f --- /dev/null +++ b/tconstruct/client/gui/MiniGardyGui.java @@ -0,0 +1,39 @@ +package tconstruct.client.gui; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; + +import tconstruct.entity.MiniGardy; +import tconstruct.inventory.MiniGardyContainer; + +public class MiniGardyGui extends GuiContainer +{ + public MiniGardy gardy; + + public MiniGardyGui(InventoryPlayer inventoryplayer, MiniGardy gardy) + { + super(new MiniGardyContainer(inventoryplayer, gardy)); + this.gardy = gardy; + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + fontRenderer.drawString(gardy.getEntityName(), 8, 6, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 4, 0x404040); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/googirl.png"); + + protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); + } +} diff --git a/tconstruct/client/gui/NewContainerGui.java b/tconstruct/client/gui/NewContainerGui.java new file mode 100644 index 00000000..bcd556b2 --- /dev/null +++ b/tconstruct/client/gui/NewContainerGui.java @@ -0,0 +1,904 @@ +package tconstruct.client.gui; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import tconstruct.inventory.ActiveContainer; +import tconstruct.inventory.ActiveSlot; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public abstract class NewContainerGui extends GuiScreen +{ + /** Stacks renderer. Icons, stack size, health, etc... */ + protected static RenderItem itemRenderer = new RenderItem(); + + /** The X/Y size of the inventory window in stretched pixels. */ + protected int xSize = 176; + protected int ySize = 166; + + /** A list of the players inventory slots. */ + public ActiveContainer container; + + /** + * Starting X/Y position for the Gui. Inconsistent use for Gui backgrounds. + */ + protected int guiLeft; + protected int guiTop; + + protected Slot mainSlot; + + /** Used when touchscreen is enabled */ + protected Slot clickedSlot = null; + protected boolean isRightMouseClick = false; + protected ItemStack draggedStack = null; + + protected int field_85049_r = 0; + protected int field_85048_s = 0; + protected Slot returningStackDestSlot = null; + protected long returningStackTime = 0L; + + /** Used when touchscreen is enabled */ + protected ItemStack returningStack = null; + protected Slot field_92033_y = null; + protected long field_92032_z = 0L; + protected final Set field_94077_p = new HashSet(); + protected boolean field_94076_q; + protected int field_94071_C = 0; + protected int field_94067_D = 0; + protected boolean field_94068_E = false; + protected int field_94069_F; + protected long field_94070_G = 0L; + protected Slot field_94072_H = null; + protected int field_94073_I = 0; + protected boolean field_94074_J; + protected ItemStack field_94075_K = null; + + public NewContainerGui(ActiveContainer container) + { + this.container = container; + this.field_94068_E = true; + } + + /** + * Adds the buttons (and other controls) to the screen in question. + */ + public void initGui () + { + super.initGui(); + this.mc.thePlayer.openContainer = this.container; + this.guiLeft = (this.width - this.xSize) / 2; + this.guiTop = (this.height - this.ySize) / 2; + } + + /** + * Draws the screen and all the components in it. + */ + public void drawScreen (int mouseX, int mouseY, float par3) + { + this.drawDefaultBackground(); + int gLeft = this.guiLeft; + int gTop = this.guiTop; + this.drawGuiContainerBackgroundLayer(par3, mouseX, mouseY); + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + super.drawScreen(mouseX, mouseY, par3); + + RenderHelper.enableGUIStandardItemLighting(); + GL11.glPushMatrix(); + GL11.glTranslatef((float) gLeft, (float) gTop, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + this.mainSlot = null; + short short1 = 240; + short short2 = 240; + + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) short1 / 1.0F, (float) short2 / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int slotXPos; + int slotYPos; + + for (int slotIter = 0; slotIter < this.container.inventorySlots.size(); ++slotIter) + { + Slot slot = (Slot) this.container.inventorySlots.get(slotIter); + if (!(slot instanceof ActiveSlot) || ((ActiveSlot) slot).getActive()) + { + this.drawSlotInventory(slot); + + if (this.isMouseOverSlot(slot, mouseX, mouseY)) + { + this.mainSlot = slot; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + slotXPos = slot.xDisplayPosition; + slotYPos = slot.yDisplayPosition; + this.drawGradientRect(slotXPos, slotYPos, slotXPos + 16, slotYPos + 16, -2130706433, -2130706433); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + } + } + + /*for (int slotIter = 0; slotIter < this.container.otherInventorySlots.size(); ++slotIter) + { + ActiveSlot slot = (ActiveSlot) this.container.otherInventorySlots.get(slotIter); + if (slot.getActive()) + { + this.drawSlotInventory(slot); + + if (this.isMouseOverSlot(slot, mouseX, mouseY)) + { + this.mainSlot = slot; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + slotXPos = slot.xDisplayPosition; + slotYPos = slot.yDisplayPosition; + this.drawGradientRect(slotXPos, slotYPos, slotXPos + 16, slotYPos + 16, -2130706433, -2130706433); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + } + }*/ + + this.drawGuiContainerForegroundLayer(mouseX, mouseY); + InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory; + ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack; + + if (itemstack != null) + { + byte b0 = 8; + slotYPos = this.draggedStack == null ? 8 : 16; + String s = null; + + if (this.draggedStack != null && this.isRightMouseClick) + { + itemstack = itemstack.copy(); + itemstack.stackSize = MathHelper.ceiling_float_int((float) itemstack.stackSize / 2.0F); + } + else if (this.field_94076_q && this.field_94077_p.size() > 1) + { + itemstack = itemstack.copy(); + itemstack.stackSize = this.field_94069_F; + + if (itemstack.stackSize == 0) + { + s = "" + EnumChatFormatting.YELLOW + "0"; + } + } + + this.drawItemStack(itemstack, mouseX - gLeft - b0, mouseY - gTop - slotYPos, s); + } + + if (this.returningStack != null) + { + float f1 = (float) (Minecraft.getSystemTime() - this.returningStackTime) / 100.0F; + + if (f1 >= 1.0F) + { + f1 = 1.0F; + this.returningStack = null; + } + + slotXPos = this.returningStackDestSlot.xDisplayPosition - this.field_85049_r; + slotYPos = this.returningStackDestSlot.yDisplayPosition - this.field_85048_s; + int xPos = this.field_85049_r + (int) ((float) slotXPos * f1); + int yPos = this.field_85048_s + (int) ((float) slotYPos * f1); + this.drawItemStack(this.returningStack, xPos, yPos, (String) null); + } + + GL11.glPopMatrix(); + + if (inventoryplayer.getItemStack() == null && this.mainSlot != null && this.mainSlot.getHasStack()) + { + ItemStack itemstack1 = this.mainSlot.getStack(); + this.drawItemStackTooltip(itemstack1, mouseX, mouseY); + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + } + + protected void drawItemStack (ItemStack par1ItemStack, int par2, int par3, String par4Str) + { + GL11.glTranslatef(0.0F, 0.0F, 32.0F); + this.zLevel = 200.0F; + itemRenderer.zLevel = 200.0F; + itemRenderer.renderItemAndEffectIntoGUI(this.fontRenderer, this.mc.renderEngine, par1ItemStack, par2, par3); + itemRenderer.renderItemOverlayIntoGUI(this.fontRenderer, this.mc.renderEngine, par1ItemStack, par2, par3 - (this.draggedStack == null ? 0 : 8), par4Str); + this.zLevel = 0.0F; + itemRenderer.zLevel = 0.0F; + } + + protected void drawItemStackTooltip (ItemStack par1ItemStack, int par2, int par3) + { + List list = par1ItemStack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); + + for (int k = 0; k < list.size(); ++k) + { + if (k == 0) + { + list.set(k, "\u00a7" + Integer.toHexString(par1ItemStack.getRarity().rarityColor) + (String) list.get(k)); + } + else + { + list.set(k, EnumChatFormatting.GRAY + (String) list.get(k)); + } + } + + this.func_102021_a(list, par2, par3); + } + + /** + * Draws the text when mouse is over creative inventory tab. Params: current creative tab to be checked, current + * mouse x position, current mouse y position. + */ + protected void drawCreativeTabHoveringText (String par1Str, int par2, int par3) + { + this.func_102021_a(Arrays.asList(new String[] { par1Str }), par2, par3); + } + + protected void func_102021_a (List par1List, int par2, int par3) + { + if (!par1List.isEmpty()) + { + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + int k = 0; + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + String s = (String) iterator.next(); + int l = this.fontRenderer.getStringWidth(s); + + if (l > k) + { + k = l; + } + } + + int i1 = par2 + 12; + int j1 = par3 - 12; + int k1 = 8; + + if (par1List.size() > 1) + { + k1 += 2 + (par1List.size() - 1) * 10; + } + + if (i1 + k > this.width) + { + i1 -= 28 + k; + } + + if (j1 + k1 + 6 > this.height) + { + j1 = this.height - k1 - 6; + } + + this.zLevel = 300.0F; + itemRenderer.zLevel = 300.0F; + int l1 = -267386864; + this.drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1); + this.drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1); + this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1); + this.drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1); + this.drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1); + int i2 = 1347420415; + int j2 = (i2 & 16711422) >> 1 | i2 & -16777216; + this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2); + this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2); + this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2); + this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2); + + for (int k2 = 0; k2 < par1List.size(); ++k2) + { + String s1 = (String) par1List.get(k2); + this.fontRenderer.drawStringWithShadow(s1, i1, j1, -1); + + if (k2 == 0) + { + j1 += 2; + } + + j1 += 10; + } + + this.zLevel = 0.0F; + itemRenderer.zLevel = 0.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected abstract void drawGuiContainerBackgroundLayer (float f, int i, int j); + + /** + * Draws an inventory slot + */ + protected void drawSlotInventory (Slot par1Slot) + { + int i = par1Slot.xDisplayPosition; + int j = par1Slot.yDisplayPosition; + ItemStack itemstack = par1Slot.getStack(); + boolean flag = false; + boolean flag1 = par1Slot == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick; + ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack(); + String s = null; + + if (par1Slot == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null) + { + itemstack = itemstack.copy(); + itemstack.stackSize /= 2; + } + else if (this.field_94076_q && this.field_94077_p.contains(par1Slot) && itemstack1 != null) + { + if (this.field_94077_p.size() == 1) + { + return; + } + + if (Container.func_94527_a(par1Slot, itemstack1, true) && this.container.canDragIntoSlot(par1Slot)) + { + itemstack = itemstack1.copy(); + flag = true; + Container.func_94525_a(this.field_94077_p, this.field_94071_C, itemstack, par1Slot.getStack() == null ? 0 : par1Slot.getStack().stackSize); + + if (itemstack.stackSize > itemstack.getMaxStackSize()) + { + s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize(); + itemstack.stackSize = itemstack.getMaxStackSize(); + } + + if (itemstack.stackSize > par1Slot.getSlotStackLimit()) + { + s = EnumChatFormatting.YELLOW + "" + par1Slot.getSlotStackLimit(); + itemstack.stackSize = par1Slot.getSlotStackLimit(); + } + } + else + { + this.field_94077_p.remove(par1Slot); + this.func_94066_g(); + } + } + + this.zLevel = 100.0F; + itemRenderer.zLevel = 100.0F; + + if (itemstack == null) + { + Icon icon = par1Slot.getBackgroundIconIndex(); + + if (icon != null) + { + GL11.glDisable(GL11.GL_LIGHTING); + this.mc.func_110434_K().func_110577_a(TextureMap.field_110576_c); + this.drawTexturedModelRectFromIcon(i, j, icon, 16, 16); + GL11.glEnable(GL11.GL_LIGHTING); + flag1 = true; + } + } + + if (!flag1) + { + if (flag) + { + drawRect(i, j, i + 16, j + 16, -2130706433); + } + + GL11.glEnable(GL11.GL_DEPTH_TEST); + itemRenderer.renderItemAndEffectIntoGUI(this.fontRenderer, this.mc.renderEngine, itemstack, i, j); + itemRenderer.renderItemOverlayIntoGUI(this.fontRenderer, this.mc.renderEngine, itemstack, i, j, s); + } + + itemRenderer.zLevel = 0.0F; + this.zLevel = 0.0F; + } + + protected void func_94066_g () + { + ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); + + if (itemstack != null && this.field_94076_q) + { + this.field_94069_F = itemstack.stackSize; + ItemStack itemstack1; + int i; + + for (Iterator iterator = this.field_94077_p.iterator(); iterator.hasNext(); this.field_94069_F -= itemstack1.stackSize - i) + { + Slot slot = (Slot) iterator.next(); + itemstack1 = itemstack.copy(); + i = slot.getStack() == null ? 0 : slot.getStack().stackSize; + Container.func_94525_a(this.field_94077_p, this.field_94071_C, itemstack1, i); + + if (itemstack1.stackSize > itemstack1.getMaxStackSize()) + { + itemstack1.stackSize = itemstack1.getMaxStackSize(); + } + + if (itemstack1.stackSize > slot.getSlotStackLimit()) + { + itemstack1.stackSize = slot.getSlotStackLimit(); + } + } + } + } + + /** + * Returns the slot at the given coordinates or null if there is none. + */ + protected Slot getSlotAtPosition (int mouseX, int mouseY) + { + for (int k = 0; k < this.container.inventorySlots.size(); ++k) + { + Slot slot = (Slot) this.container.inventorySlots.get(k); + + if (this.isMouseOverSlot(slot, mouseX, mouseY)) + { + return slot; + } + } + + return null; + } + + /** + * Called when the mouse is clicked. + */ + protected void mouseClicked (int mouseX, int mouseY, int mouseButton) + { + super.mouseClicked(mouseX, mouseY, mouseButton); + boolean flag = mouseButton == this.mc.gameSettings.keyBindPickBlock.keyCode + 100; + Slot slot = this.getSlotAtPosition(mouseX, mouseY); + long l = Minecraft.getSystemTime(); + this.field_94074_J = this.field_94072_H == slot && l - this.field_94070_G < 250L && this.field_94073_I == mouseButton; + this.field_94068_E = false; + + if (mouseButton == 0 || mouseButton == 1 || flag) + { + int gLeft = this.guiLeft; + int gTop = this.guiTop; + boolean flag1 = mouseX < gLeft || mouseY < gTop || mouseX >= gLeft + this.xSize || mouseY >= gTop + this.ySize; + int k1 = -1; + + if (slot != null) + { + k1 = slot.slotNumber; + } + + if (flag1) + { + k1 = -999; + } + + if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null) + { + this.mc.displayGuiScreen((GuiScreen) null); + return; + } + + if (k1 != -1) + { + if (this.mc.gameSettings.touchscreen) + { + if (slot != null && slot.getHasStack()) + { + this.clickedSlot = slot; + this.draggedStack = null; + this.isRightMouseClick = mouseButton == 1; + } + else + { + this.clickedSlot = null; + } + } + else if (!this.field_94076_q) + { + if (this.mc.thePlayer.inventory.getItemStack() == null) + { + if (mouseButton == this.mc.gameSettings.keyBindPickBlock.keyCode + 100) + { + this.handleMouseClick(slot, k1, mouseButton, 3); + } + else + { + boolean flag2 = k1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)); + byte b0 = 0; + + if (flag2) + { + this.field_94075_K = slot != null && slot.getHasStack() ? slot.getStack() : null; + b0 = 1; + } + else if (k1 == -999) + { + b0 = 4; + } + + this.handleMouseClick(slot, k1, mouseButton, b0); + } + + this.field_94068_E = true; + } + else + { + this.field_94076_q = true; + this.field_94067_D = mouseButton; + this.field_94077_p.clear(); + + if (mouseButton == 0) + { + this.field_94071_C = 0; + } + else if (mouseButton == 1) + { + this.field_94071_C = 1; + } + } + } + } + } + + this.field_94072_H = slot; + this.field_94070_G = l; + this.field_94073_I = mouseButton; + } + + protected void func_85041_a (int par1, int par2, int par3, long par4) + { + Slot slot = this.getSlotAtPosition(par1, par2); + ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); + + if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) + { + if (par3 == 0 || par3 == 1) + { + if (this.draggedStack == null) + { + if (slot != this.clickedSlot) + { + this.draggedStack = this.clickedSlot.getStack().copy(); + } + } + else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false)) + { + long i1 = Minecraft.getSystemTime(); + + if (this.field_92033_y == slot) + { + if (i1 - this.field_92032_z > 500L) + { + this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0); + this.handleMouseClick(slot, slot.slotNumber, 1, 0); + this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0); + this.field_92032_z = i1 + 750L; + --this.draggedStack.stackSize; + } + } + else + { + this.field_92033_y = slot; + this.field_92032_z = i1; + } + } + } + } + else if (this.field_94076_q && slot != null && itemstack != null && itemstack.stackSize > this.field_94077_p.size() && Container.func_94527_a(slot, itemstack, true) + && slot.isItemValid(itemstack) && this.container.canDragIntoSlot(slot)) + { + this.field_94077_p.add(slot); + this.func_94066_g(); + } + } + + /** + * Called when the mouse is moved or a mouse button is released. Signature: (mouseX, mouseY, which) which==-1 is + * mouseMove, which==0 or which==1 is mouseUp + */ + protected void mouseMovedOrUp (int par1, int par2, int par3) + { + Slot slot = this.getSlotAtPosition(par1, par2); + int l = this.guiLeft; + int i1 = this.guiTop; + boolean flag = par1 < l || par2 < i1 || par1 >= l + this.xSize || par2 >= i1 + this.ySize; + int j1 = -1; + + if (slot != null) + { + j1 = slot.slotNumber; + } + + if (flag) + { + j1 = -999; + } + + Slot slot1; + Iterator iterator; + + if (this.field_94074_J && slot != null && par3 == 0 && this.container.func_94530_a((ItemStack) null, slot)) + { + if (isShiftKeyDown()) + { + if (slot != null && slot.inventory != null && this.field_94075_K != null) + { + iterator = this.container.inventorySlots.iterator(); + + while (iterator.hasNext()) + { + slot1 = (Slot) iterator.next(); + + if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory + && Container.func_94527_a(slot1, this.field_94075_K, true)) + { + this.handleMouseClick(slot1, slot1.slotNumber, par3, 1); + } + } + } + } + else + { + this.handleMouseClick(slot, j1, par3, 6); + } + + this.field_94074_J = false; + this.field_94070_G = 0L; + } + else + { + if (this.field_94076_q && this.field_94067_D != par3) + { + this.field_94076_q = false; + this.field_94077_p.clear(); + this.field_94068_E = true; + return; + } + + if (this.field_94068_E) + { + this.field_94068_E = false; + return; + } + + boolean flag1; + + if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) + { + if (par3 == 0 || par3 == 1) + { + if (this.draggedStack == null && slot != this.clickedSlot) + { + this.draggedStack = this.clickedSlot.getStack(); + } + + flag1 = Container.func_94527_a(slot, this.draggedStack, false); + + if (j1 != -1 && this.draggedStack != null && flag1) + { + this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, par3, 0); + this.handleMouseClick(slot, j1, 0, 0); + + if (this.mc.thePlayer.inventory.getItemStack() != null) + { + this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, par3, 0); + this.field_85049_r = par1 - l; + this.field_85048_s = par2 - i1; + this.returningStackDestSlot = this.clickedSlot; + this.returningStack = this.draggedStack; + this.returningStackTime = Minecraft.getSystemTime(); + } + else + { + this.returningStack = null; + } + } + else if (this.draggedStack != null) + { + this.field_85049_r = par1 - l; + this.field_85048_s = par2 - i1; + this.returningStackDestSlot = this.clickedSlot; + this.returningStack = this.draggedStack; + this.returningStackTime = Minecraft.getSystemTime(); + } + + this.draggedStack = null; + this.clickedSlot = null; + } + } + else if (this.field_94076_q && !this.field_94077_p.isEmpty()) + { + this.handleMouseClick((Slot) null, -999, Container.func_94534_d(0, this.field_94071_C), 5); + iterator = this.field_94077_p.iterator(); + + while (iterator.hasNext()) + { + slot1 = (Slot) iterator.next(); + this.handleMouseClick(slot1, slot1.slotNumber, Container.func_94534_d(1, this.field_94071_C), 5); + } + + this.handleMouseClick((Slot) null, -999, Container.func_94534_d(2, this.field_94071_C), 5); + } + else if (this.mc.thePlayer.inventory.getItemStack() != null) + { + if (par3 == this.mc.gameSettings.keyBindPickBlock.keyCode + 100) + { + this.handleMouseClick(slot, j1, par3, 3); + } + else + { + flag1 = j1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)); + + if (flag1) + { + this.field_94075_K = slot != null && slot.getHasStack() ? slot.getStack() : null; + } + + this.handleMouseClick(slot, j1, par3, flag1 ? 1 : 0); + } + } + } + + if (this.mc.thePlayer.inventory.getItemStack() == null) + { + this.field_94070_G = 0L; + } + + this.field_94076_q = false; + } + + /** + * Returns if the passed mouse position is over the specified slot. + */ + protected boolean isMouseOverSlot (Slot slot, int mouseX, int mouseY) + { + if (!(slot instanceof ActiveSlot) || ((ActiveSlot) slot).getActive()) + { + return this.isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY); + } + return false; + } + + /** + * Args: left, top, width, height, pointX, pointY. Note: left, top are local to Gui, pointX, pointY are local to + * screen + */ + protected boolean isPointInRegion (int par1, int par2, int par3, int par4, int par5, int par6) + { + int k1 = this.guiLeft; + int l1 = this.guiTop; + par5 -= k1; + par6 -= l1; + return par5 >= par1 - 1 && par5 < par1 + par3 + 1 && par6 >= par2 - 1 && par6 < par2 + par4 + 1; + } + + protected void handleMouseClick (Slot par1Slot, int par2, int par3, int par4) + { + if (par1Slot != null) + { + par2 = par1Slot.slotNumber; + } + + this.mc.playerController.windowClick(this.container.windowId, par2, par3, par4, this.mc.thePlayer); + } + + /** + * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). + */ + protected void keyTyped (char par1, int par2) + { + if (par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.keyCode) + { + this.mc.thePlayer.closeScreen(); + } + + this.checkHotbarKeys(par2); + + if (this.mainSlot != null && this.mainSlot.getHasStack()) + { + if (par2 == this.mc.gameSettings.keyBindPickBlock.keyCode) + { + this.handleMouseClick(this.mainSlot, this.mainSlot.slotNumber, 0, 3); + } + else if (par2 == this.mc.gameSettings.keyBindDrop.keyCode) + { + this.handleMouseClick(this.mainSlot, this.mainSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, 4); + } + } + } + + /** + * This function is what controls the hotbar shortcut check when you press a number key when hovering a stack. + */ + protected boolean checkHotbarKeys (int par1) + { + if (this.mc.thePlayer.inventory.getItemStack() == null && this.mainSlot != null) + { + for (int j = 0; j < 9; ++j) + { + if (par1 == 2 + j) + { + this.handleMouseClick(this.mainSlot, this.mainSlot.slotNumber, j, 2); + return true; + } + } + } + + return false; + } + + /** + * Called when the screen is unloaded. Used to disable keyboard repeat events + */ + public void onGuiClosed () + { + if (this.mc.thePlayer != null) + { + this.container.onContainerClosed(this.mc.thePlayer); + } + } + + /** + * Returns true if this GUI should pause the game when it is displayed in single-player + */ + public boolean doesGuiPauseGame () + { + return false; + } + + /** + * Called from the main game loop to update the screen. + */ + public void updateScreen () + { + super.updateScreen(); + + if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead) + { + this.mc.thePlayer.closeScreen(); + } + } +} diff --git a/tconstruct/client/gui/PartCrafterGui.java b/tconstruct/client/gui/PartCrafterGui.java new file mode 100644 index 00000000..a6cb0e81 --- /dev/null +++ b/tconstruct/client/gui/PartCrafterGui.java @@ -0,0 +1,297 @@ +package tconstruct.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.PartCrafterLogic; +import tconstruct.inventory.ActiveContainer; +import tconstruct.inventory.PartCrafterChestContainer; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.PatternBuilder; +import tconstruct.library.tools.ToolMaterial; + +public class PartCrafterGui extends NewContainerGui +{ + PartCrafterLogic logic; + String title, otherTitle = ""; + boolean drawChestPart; + boolean hasTop, hasBottom; + ItemStack topMaterial, bottomMaterial; + ToolMaterial topEnum, bottomEnum; + + public PartCrafterGui(InventoryPlayer inventoryplayer, PartCrafterLogic partlogic, World world, int x, int y, int z) + { + super((ActiveContainer) partlogic.getGuiContainer(inventoryplayer, world, x, y, z)); + logic = partlogic; + drawChestPart = container instanceof PartCrafterChestContainer; + + title = "\u00A7nTool Part Crafting"; + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + this.fontRenderer.drawString(StatCollector.translateToLocal("crafters.PartBuilder"), 6, 6, 4210752); + this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + if (drawChestPart) + this.fontRenderer.drawString(StatCollector.translateToLocal("inventory.PatternChest"), -108, this.ySize - 148, 4210752); + + drawMaterialInformation(); + } + + void drawDefaultInformation () + { + title = "\u00A7nTool Part Building"; + this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 16777215); + fontRenderer.drawSplitString("Place a pattern and a material on the left to get started.", xSize + 8, 24, 115, 16777215); + } + + void drawMaterialInformation () + { + ItemStack top = logic.getStackInSlot(2); + ItemStack bottom = logic.getStackInSlot(3); + if (topMaterial != top) + { + topMaterial = top; + int topID = PatternBuilder.instance.getPartID(top); + + if (topID != Short.MAX_VALUE) + { + topEnum = TConstructRegistry.getMaterial(topID); + hasTop = true; + title = "\u00A7n" + topEnum.name(); + } + else + hasTop = false; + } + + if (bottomMaterial != bottom) + { + bottomMaterial = bottom; + int bottomID = PatternBuilder.instance.getPartID(bottom); + + if (bottomID != Short.MAX_VALUE) + { + bottomEnum = TConstructRegistry.getMaterial(bottomID); + hasBottom = true; + otherTitle = "\u00A7n" + bottomEnum.name(); + } + else + hasBottom = false; + } + + int offset = 8; + if (hasTop) + { + this.drawCenteredString(fontRenderer, title, xSize + 63, offset, 16777215); + this.fontRenderer.drawString("Base Durability: " + topEnum.durability(), xSize + 8, offset + 16, 16777215); + this.fontRenderer.drawString("Handle Modifier: " + topEnum.handleDurability() + "x", xSize + 8, offset + 27, 16777215); + this.fontRenderer.drawString("Mining Speed: " + topEnum.toolSpeed() / 100f, xSize + 8, offset + 38, 16777215); + this.fontRenderer.drawString("Mining Level: " + getHarvestLevelName(topEnum.harvestLevel()), xSize + 8, offset + 49, 16777215); + + int attack = topEnum.attack(); + String heart = attack == 2 ? " Heart" : " Hearts"; + if (attack % 2 == 0) + this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, offset + 60, 0xffffff); + else + this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, offset + 60, 0xffffff); + } + + offset = 90; + if (hasBottom) + { + this.drawCenteredString(fontRenderer, otherTitle, xSize + 63, offset, 16777215); + this.fontRenderer.drawString("Base Durability: " + bottomEnum.durability(), xSize + 8, offset + 16, 16777215); + this.fontRenderer.drawString("Handle Modifier: " + bottomEnum.handleDurability() + "x", xSize + 8, offset + 27, 16777215); + this.fontRenderer.drawString("Mining Speed: " + bottomEnum.toolSpeed() / 100f, xSize + 8, offset + 38, 16777215); + this.fontRenderer.drawString("Mining Level: " + getHarvestLevelName(bottomEnum.harvestLevel()), xSize + 8, offset + 49, 16777215); + int attack = bottomEnum.attack(); + String heart = attack == 2 ? " Heart" : " Hearts"; + if (attack % 2 == 0) + this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, offset + 60, 0xffffff); + else + this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, offset + 60, 0xffffff); + } + + if (!hasTop && !hasBottom) + drawDefaultInformation(); + } + + public static String getHarvestLevelName (int num) + { + switch (num) + { + case 0: + return "Stone"; + case 1: + return "Iron"; + case 2: + return "Redstone"; + case 3: + return "Obsidian"; + case 4: + return "Cobalt"; + case 5: + return "Manyullyn"; + default: + return String.valueOf(num); + } + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/toolparts.png"); + private static final ResourceLocation minichest = new ResourceLocation("tinker", "textures/gui/patternchestmini.png"); + private static final ResourceLocation description = new ResourceLocation("tinker", "textures/gui/description.png"); + + protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3) + { + // Draw the background + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = (this.width - this.xSize) / 2; + int cornerY = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize); + + // Draw Slots + this.drawTexturedModalRect(cornerX + 39, cornerY + 26, 0, 166, 98, 36); + if (!logic.isStackInSlot(0)) + { + this.drawTexturedModalRect(cornerX + 39, cornerY + 26, 176, 0, 18, 18); + } + if (!logic.isStackInSlot(2)) + { + this.drawTexturedModalRect(cornerX + 57, cornerY + 26, 176, 18, 18, 18); + } + if (!logic.isStackInSlot(1)) + { + this.drawTexturedModalRect(cornerX + 39, cornerY + 44, 176, 0, 18, 18); + } + if (!logic.isStackInSlot(3)) + { + this.drawTexturedModalRect(cornerX + 57, cornerY + 44, 176, 36, 18, 18); + } + + // Draw chest + if (drawChestPart) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(minichest); + this.drawTexturedModalRect(cornerX - 116, cornerY + 11, 0, 0, this.xSize, this.ySize); + } + + // Draw description + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(description); + cornerX = (this.width + this.xSize) / 2; + cornerY = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(cornerX, cornerY, 126, 0, 126, this.ySize); + } + + @Override + protected void mouseClicked (int mouseX, int mouseY, int clickNum) + { + boolean flag = clickNum == this.mc.gameSettings.keyBindPickBlock.keyCode + 100; + Slot slot = this.getSlotAtPosition(mouseX, mouseY); + long l = Minecraft.getSystemTime(); + this.field_94074_J = this.field_94072_H == slot && l - this.field_94070_G < 250L && this.field_94073_I == clickNum; + this.field_94068_E = false; + + int offsetLeft = drawChestPart ? 108 : 0; + + if (clickNum == 0 || clickNum == 1 || flag) + { + int i1 = this.guiLeft; + int j1 = this.guiTop; + boolean flag1 = mouseX < i1 - offsetLeft || mouseY < j1 || mouseX >= i1 + this.xSize || mouseY >= j1 + this.ySize; + int k1 = -1; + + if (slot != null) + { + k1 = slot.slotNumber; + } + + if (flag1) + { + k1 = -999; + } + + if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null) + { + this.mc.displayGuiScreen((GuiScreen) null); + return; + } + + if (k1 != -1) + { + if (this.mc.gameSettings.touchscreen) + { + if (slot != null && slot.getHasStack()) + { + this.clickedSlot = slot; + this.draggedStack = null; + this.isRightMouseClick = clickNum == 1; + } + else + { + this.clickedSlot = null; + } + } + else if (!this.field_94076_q) + { + if (this.mc.thePlayer.inventory.getItemStack() == null) + { + if (clickNum == this.mc.gameSettings.keyBindPickBlock.keyCode + 100) + { + this.handleMouseClick(slot, k1, clickNum, 3); + } + else + { + boolean flag2 = k1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)); + byte b0 = 0; + + if (flag2) + { + this.field_94075_K = slot != null && slot.getHasStack() ? slot.getStack() : null; + b0 = 1; + } + else if (k1 == -999) + { + b0 = 4; + } + + this.handleMouseClick(slot, k1, clickNum, b0); + } + + this.field_94068_E = true; + } + else + { + this.field_94076_q = true; + this.field_94067_D = clickNum; + this.field_94077_p.clear(); + + if (clickNum == 0) + { + this.field_94071_C = 0; + } + else if (clickNum == 1) + { + this.field_94071_C = 1; + } + } + } + } + } + + this.field_94072_H = slot; + this.field_94070_G = l; + this.field_94073_I = clickNum; + } +} diff --git a/tconstruct/client/gui/PatternChestGui.java b/tconstruct/client/gui/PatternChestGui.java new file mode 100644 index 00000000..66bf6380 --- /dev/null +++ b/tconstruct/client/gui/PatternChestGui.java @@ -0,0 +1,41 @@ +package tconstruct.client.gui; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.PatternChestLogic; + +public class PatternChestGui extends GuiContainer +{ + public PatternChestLogic logic; + + public PatternChestGui(InventoryPlayer inventoryplayer, PatternChestLogic holder, World world, int x, int y, int z) + { + super(holder.getGuiContainer(inventoryplayer, world, x, y, z)); + logic = holder; + xSize = 194; + ySize = 168; + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + fontRenderer.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 60, 6, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternchest.png"); + + protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); + } +} diff --git a/tconstruct/client/gui/SmelteryGui.java b/tconstruct/client/gui/SmelteryGui.java new file mode 100644 index 00000000..2be01dcf --- /dev/null +++ b/tconstruct/client/gui/SmelteryGui.java @@ -0,0 +1,384 @@ +package tconstruct.client.gui; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.Icon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import tconstruct.blocks.logic.SmelteryLogic; +import tconstruct.inventory.ActiveContainer; +import tconstruct.inventory.SmelteryContainer; + +public class SmelteryGui extends NewContainerGui +{ + public SmelteryLogic logic; + String username; + boolean isScrolling = false; + boolean wasClicking; + float currentScroll = 0.0F; + int slotPos = 0; + int prevSlotPos = 0; + + public SmelteryGui(InventoryPlayer inventoryplayer, SmelteryLogic smeltery, World world, int x, int y, int z) + { + super((ActiveContainer) smeltery.getGuiContainer(inventoryplayer, world, x, y, z)); + logic = smeltery; + username = inventoryplayer.player.username; + xSize = 248; + smeltery.updateFuelDisplay(); + } + + public void drawScreen (int mouseX, int mouseY, float par3) + { + super.drawScreen(mouseX, mouseY, par3); + updateScrollbar(mouseX, mouseY, par3); + } + + protected void updateScrollbar (int mouseX, int mouseY, float par3) + { + if (logic.layers > 2) + { + boolean mouseDown = Mouse.isButtonDown(0); + int lefto = this.guiLeft; + int topo = this.guiTop; + int xScroll = lefto + 67; + int yScroll = topo + 8; + int scrollWidth = xScroll + 14; + int scrollHeight = yScroll + 144; + + if (!this.wasClicking && mouseDown && mouseX >= xScroll && mouseY >= yScroll && mouseX < scrollWidth && mouseY < scrollHeight) + { + this.isScrolling = true; + } + + if (!mouseDown) + { + this.isScrolling = false; + } + + if (wasClicking && !isScrolling && slotPos != prevSlotPos) + { + prevSlotPos = slotPos; + } + + this.wasClicking = mouseDown; + + if (this.isScrolling) + { + this.currentScroll = ((float) (mouseY - yScroll) - 7.5F) / ((float) (scrollHeight - yScroll) - 15.0F); + + if (this.currentScroll < 0.0F) + { + this.currentScroll = 0.0F; + } + + if (this.currentScroll > 1.0F) + { + this.currentScroll = 1.0F; + } + + int s = ((SmelteryContainer) this.container).scrollTo(this.currentScroll); + if (s != -1) + slotPos = s; + } + } + } + + protected void drawGuiContainerForegroundLayer (int mouseX, int mouseY) + { + fontRenderer.drawString(StatCollector.translateToLocal("crafters.Smeltery"), 86, 5, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 90, (ySize - 96) + 2, 0x404040); + + int base = 0; + int cornerX = (width - xSize) / 2 + 36; + int cornerY = (height - ySize) / 2; + for (FluidStack liquid : logic.moltenMetal) + { + int basePos = 54; + int initialLiquidSize = 0; + int liquidSize = 0;//liquid.amount * 52 / liquidLayers; + if (logic.getCapacity() > 0) + { + int total = logic.getTotalLiquid(); + int liquidLayers = (total / 20000 + 1) * 20000; + liquidSize = liquid.amount * 52 / liquidLayers; + if (liquidSize == 0) + liquidSize = 1; + base += liquidSize; + } + + int leftX = cornerX + basePos; + int topY = (cornerY + 68) - base; + int sizeX = 52; + int sizeY = liquidSize; + if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY) + { + drawFluidStackTooltip(liquid, mouseX - cornerX + 36, mouseY - cornerY); + } + } + + if (logic.fuelGague > 0) + { + int leftX = cornerX + 117; + int topY = (cornerY + 68) - logic.getScaledFuelGague(52); + int sizeX = 12; + int sizeY = logic.getScaledFuelGague(52); + if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY) + { + drawFluidStackTooltip(new FluidStack(Block.lavaStill.blockID, logic.fuelAmount), mouseX - cornerX + 36, mouseY - cornerY); + } + } + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/smeltery.png"); + private static final ResourceLocation backgroundSide = new ResourceLocation("tinker", "textures/gui/smelteryside.png"); + private static final ResourceLocation terrain = new ResourceLocation("terrain.png"); + + protected void drawGuiContainerBackgroundLayer (float f, int mouseX, int mouseY) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = (width - xSize) / 2 + 36; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX + 46, cornerY, 0, 0, 176, ySize); + + //Fuel - Lava + this.mc.func_110434_K().func_110577_a(TextureMap.field_110575_b); + if (logic.fuelGague > 0) + { + Icon lavaIcon = Block.lavaStill.getIcon(0, 0); + int fuel = logic.getScaledFuelGague(52); + int count = 0; + while (fuel > 0) + { + int size = fuel >= 16 ? 16 : fuel; + fuel -= size; + drawLiquidRect(cornerX + 117, (cornerY + 68) - size - 16 * count, lavaIcon, 12, size); + count++; + } + } + + //Liquids - molten metal + int base = 0; + for (FluidStack liquid : logic.moltenMetal) + { + Icon renderIndex = liquid.getFluid().getStillIcon(); + int basePos = 54; + if (logic.getCapacity() > 0) + { + int total = logic.getTotalLiquid(); + int liquidLayers = (total / 20000 + 1) * 20000; + int liquidSize = liquid.amount * 52 / liquidLayers; + if (liquidSize == 0) + liquidSize = 1; + while (liquidSize > 0) + { + int size = liquidSize >= 16 ? 16 : liquidSize; + drawLiquidRect(cornerX + basePos, (cornerY + 68) - size - base, renderIndex, 16, size); + drawLiquidRect(cornerX + basePos + 16, (cornerY + 68) - size - base, renderIndex, 16, size); + drawLiquidRect(cornerX + basePos + 32, (cornerY + 68) - size - base, renderIndex, 16, size); + drawLiquidRect(cornerX + basePos + 48, (cornerY + 68) - size - base, renderIndex, 4, size); + liquidSize -= size; + base += size; + } + } + } + + //Liquid gague + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.func_110434_K().func_110577_a(background); + drawTexturedModalRect(cornerX + 54, cornerY + 16, 176, 76, 52, 52); + + //Side inventory + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(backgroundSide); + if (logic.layers > 0) + { + if (logic.layers == 1) + { + drawTexturedModalRect(cornerX - 46, cornerY, 0, 0, 98, 43); + drawTexturedModalRect(cornerX - 46, cornerY + 43, 0, 133, 98, 25); + } + else if (logic.layers == 2) + { + drawTexturedModalRect(cornerX - 46, cornerY, 0, 0, 98, 61); + drawTexturedModalRect(cornerX - 46, cornerY + 61, 0, 97, 98, 61); + } + else + { + drawTexturedModalRect(cornerX - 46, cornerY, 0, 0, 98, ySize - 8); + } + drawTexturedModalRect(cornerX + 32, (int) (cornerY + 8 + 127 * currentScroll), 98, 0, 12, 15); + } + + //Temperature + int slotSize = logic.layers * 9; + if (slotSize > 24) + slotSize = 24; + for (int iter = 0; iter < slotSize; iter++) + { + int slotTemp = logic.getTempForSlot(iter + slotPos * 3) - 20; + int maxTemp = logic.getMeltingPointForSlot(iter + slotPos * 3) - 20; + if (slotTemp > 0 && maxTemp > 0) + { + int size = 16 * slotTemp / maxTemp + 1; + drawTexturedModalRect(cornerX - 38 + (iter % 3 * 22), cornerY + 8 + (iter / 3 * 18) + 16 - size, 98, 15 + 16 - size, 5, size); + } + } + } + + protected void drawFluidStackTooltip (FluidStack par1ItemStack, int par2, int par3) + { + this.zLevel = 100; + List list = getLiquidTooltip(par1ItemStack, this.mc.gameSettings.advancedItemTooltips); + + for (int k = 0; k < list.size(); ++k) + { + list.set(k, EnumChatFormatting.GRAY + (String) list.get(k)); + } + + this.drawToolTip(list, par2, par3); + this.zLevel = 0; + } + + public List getLiquidTooltip (FluidStack liquid, boolean par2) + { + ArrayList list = new ArrayList(); + if (liquid.getFluid().getBlockID() == Block.lavaStill.blockID) + { + list.add("\u00A7fFuel"); + int mB = liquid.amount; + if (mB > 0) + list.add("mB: " + mB); + } + else + { + String name = FluidRegistry.getFluidName(liquid); + list.add("\u00A7f" + name); + if (name.equals("Liquified Emerald")) + { + float emeralds = liquid.amount / 320f; + list.add("Emeralds: " + emeralds); + } + else + { + int ingots = liquid.amount / 144; + if (ingots > 0) + list.add("Ingots: " + ingots); + int mB = liquid.amount % 144; + if (mB > 0) + { + if (mB % 72 == 0) + list.add("Chunks: " + liquid.amount % 144 / 72); + else if (mB % 16 == 0) + list.add("Nuggets: " + liquid.amount % 144 / 16); + else + list.add("mB: " + mB); + } + } + } + return list; + } + + protected void drawToolTip (List par1List, int par2, int par3) + { + if (!par1List.isEmpty()) + { + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + int k = 0; + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + String s = (String) iterator.next(); + int l = this.fontRenderer.getStringWidth(s); + + if (l > k) + { + k = l; + } + } + + int i1 = par2 + 12; + int j1 = par3 - 12; + int k1 = 8; + + if (par1List.size() > 1) + { + k1 += 2 + (par1List.size() - 1) * 10; + } + + if (i1 + k > this.width) + { + i1 -= 28 + k; + } + + if (j1 + k1 + 6 > this.height) + { + j1 = this.height - k1 - 6; + } + + this.zLevel = 300.0F; + itemRenderer.zLevel = 300.0F; + int l1 = -267386864; + this.drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1); + this.drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1); + this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1); + this.drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1); + this.drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1); + int i2 = 1347420415; + int j2 = (i2 & 16711422) >> 1 | i2 & -16777216; + this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2); + this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2); + this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2); + this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2); + + for (int k2 = 0; k2 < par1List.size(); ++k2) + { + String s1 = (String) par1List.get(k2); + this.fontRenderer.drawStringWithShadow(s1, i1, j1, -1); + + if (k2 == 0) + { + j1 += 2; + } + + j1 += 10; + } + + this.zLevel = 0.0F; + itemRenderer.zLevel = 0.0F; + } + } + + public void drawLiquidRect (int startU, int startV, Icon par3Icon, int endU, int endV) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (startU + 0), (double) (startV + endV), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV());//Bottom left + tessellator.addVertexWithUV((double) (startU + endU), (double) (startV + endV), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV());//Bottom right + tessellator.addVertexWithUV((double) (startU + endU), (double) (startV + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV());//Top right + tessellator.addVertexWithUV((double) (startU + 0), (double) (startV + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); //Top left + tessellator.draw(); + } +} diff --git a/tconstruct/client/gui/StencilTableGui.java b/tconstruct/client/gui/StencilTableGui.java new file mode 100644 index 00000000..4ac9996c --- /dev/null +++ b/tconstruct/client/gui/StencilTableGui.java @@ -0,0 +1,148 @@ +package tconstruct.client.gui; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.StencilTableLogic; +import tconstruct.common.TContent; +import tconstruct.inventory.PatternShaperContainer; + +import cpw.mods.fml.common.network.PacketDispatcher; + +public class StencilTableGui extends GuiContainer +{ + StencilTableLogic logic; + int patternIndex; + + public StencilTableGui(InventoryPlayer inventoryplayer, StencilTableLogic shaper, World world, int x, int y, int z) + { + super(new PatternShaperContainer(inventoryplayer, shaper)); + logic = shaper; + patternIndex = 0; + } + + public void onGuiClosed () + { + super.onGuiClosed(); + } + + @Override + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + fontRenderer.drawString(StatCollector.translateToLocal("crafters.PatternShaper"), 50, 6, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternshaper.png"); + + protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = (this.width - this.xSize) / 2; + int cornerY = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize); + if (!logic.isStackInSlot(0)) + { + this.drawTexturedModalRect(cornerX + 47, cornerY + 34, 176, 0, 18, 18); + } + } + + public void initGui () + { + super.initGui(); + int cornerX = (this.width - this.xSize) / 2; + int cornerY = (this.height - this.ySize) / 2; + + this.buttonList.clear(); + /*ToolGuiElement repair = TConstruct.toolButtons.get(0); + GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.texture); // Repair + repairButton.enabled = false; + this.buttonList.add(repairButton);*/ + this.buttonList.add(new GuiButton(0, cornerX - 120, cornerY, 120, 20, "Next Pattern")); + this.buttonList.add(new GuiButton(1, cornerX - 120, cornerY + 20, 120, 20, "Previous Pattern")); + + //for (int iter = 0; iter < TConstructContent.patternOutputs.length; iter++) + //{ + + /*ToolGuiElement element = TConstruct.toolButtons.get(iter); + GuiButtonTool button = new GuiButtonTool(iter, cornerX - 110 + 22 * (iter % 5), cornerY + 22 * (iter / 5), element.buttonIconX, element.buttonIconY, element.texture); // Repair + this.buttonList.add(button);*/ + //} + } + + protected void actionPerformed (GuiButton button) + { + ItemStack pattern = logic.getStackInSlot(0); + if (pattern != null && pattern.getItem() == TContent.blankPattern) + { + int meta = pattern.getItemDamage(); + if (meta == 0) + { + if (button.id == 0) + { + patternIndex++; + if (patternIndex == 21) + patternIndex++; + if (patternIndex >= TContent.patternOutputs.length) + patternIndex = 0; + } + else if (button.id == 1) + { + patternIndex--; + if (patternIndex == 21) + patternIndex--; + if (patternIndex < 0) + patternIndex = TContent.patternOutputs.length - 1; + } + ItemStack stack = new ItemStack(TContent.woodPattern, 1, patternIndex + 1); + logic.setInventorySlotContents(1, stack); + updateServer(stack); + } + else if (meta == 1 || meta == 2) + { + ItemStack stack = new ItemStack(TContent.metalPattern, 1, 0); + logic.setInventorySlotContents(1, stack); + updateServer(stack); + } + } + } + + void updateServer (ItemStack stack) + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(2); + outputStream.writeInt(logic.worldObj.provider.dimensionId); + outputStream.writeInt(logic.xCoord); + outputStream.writeInt(logic.yCoord); + outputStream.writeInt(logic.zCoord); + outputStream.writeShort(stack.itemID); + outputStream.writeShort(stack.getItemDamage()); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "TConstruct"; + packet.data = bos.toByteArray(); + packet.length = bos.size(); + + PacketDispatcher.sendPacketToServer(packet); + } +} diff --git a/tconstruct/client/gui/ToolForgeGui.java b/tconstruct/client/gui/ToolForgeGui.java new file mode 100644 index 00000000..c14e8578 --- /dev/null +++ b/tconstruct/client/gui/ToolForgeGui.java @@ -0,0 +1,130 @@ +package tconstruct.client.gui; + +import tconstruct.blocks.logic.ToolForgeLogic; +import tconstruct.library.client.TConstructClientRegistry; +import tconstruct.library.client.ToolGuiElement; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ToolForgeGui extends ToolStationGui +{ + int selectedButton; + + public ToolForgeGui(InventoryPlayer inventoryplayer, ToolForgeLogic stationlogic, World world, int x, int y, int z) + { + super(inventoryplayer, stationlogic, world, x, y, z); + } + + protected void mouseClicked (int mouseX, int mouseY, int mouseButton) + { + super.mouseClicked(mouseX, mouseY, mouseButton); + if (mouseButton == 0) + { + int gLeft = this.guiLeft + 68; + int gTop = this.guiTop + 6; + int gWidth = 102; + int gHeight = 12; + active = mouseX > gLeft && mouseX < gLeft + gWidth && mouseY > gTop && mouseY < gTop + gHeight; + } + } + + public void initGui () + { + super.initGui(); + int cornerX = (this.width - this.xSize) / 2; + int cornerY = (this.height - this.ySize) / 2; + + this.buttonList.clear(); + ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0); + GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair + repairButton.enabled = false; + this.buttonList.add(repairButton); + int offset = TConstructClientRegistry.tierTwoButtons.size(); + + for (int iter = 0; iter < TConstructClientRegistry.tierTwoButtons.size(); iter++) + { + ToolGuiElement element = TConstructClientRegistry.tierTwoButtons.get(iter); + GuiButtonTool button = new GuiButtonTool(iter + 1, cornerX - 110 + 22 * ((iter + 1) % 5), cornerY + 22 * ((iter + 1) / 5), element.buttonIconX, element.buttonIconY, repair.domain, + element.texture, element); + this.buttonList.add(button); + } + + for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++) + { + ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter); + GuiButtonTool button = new GuiButtonTool(iter + offset, cornerX - 110 + 22 * ((iter + offset) % 5), cornerY + 22 * ((iter + offset) / 5), element.buttonIconX, element.buttonIconY, + repair.domain, element.texture, element); + this.buttonList.add(button); + } + } + + protected void actionPerformed (GuiButton button) + { + GuiButtonTool b = (GuiButtonTool) button; + ((GuiButton) this.buttonList.get(selectedButton)).enabled = true; + selectedButton = button.id; + button.enabled = false; + + setSlotType(b.element.slotType); + iconX = b.element.iconsX; + iconY = b.element.iconsY; + title = "\u00A7n" + b.element.title; + body = b.element.body; + } + + @Override + void resetGui () + { + this.text.setText(""); + selectedButton = 0; + setSlotType(0); + iconX = new int[] { 0, 1, 2, 13 }; + iconY = new int[] { 13, 13, 13, 13 }; + title = "\u00A7nRepair and Modification"; + body = "The main way to repair or change your tools. Place a tool and a material on the left to get started."; + } + + void setSlotType (int type) + { + switch (type) + { + case 0: + slotX = new int[] { 56, 38, 38, 14 }; // Repair + slotY = new int[] { 37, 28, 46, 37 }; + break; + case 1: + slotX = new int[] { 56, 56, 56, 14 }; // Three parts + slotY = new int[] { 19, 55, 37, 37 }; + break; + case 2: + slotX = new int[] { 56, 56, 14, 14 }; // Two parts + slotY = new int[] { 28, 46, 28, 46 }; + break; + case 3: + slotX = new int[] { 38, 47, 56, 14 }; // Double head + slotY = new int[] { 28, 46, 28, 37 }; + break; + case 4: + slotX = new int[] { 47, 38, 56, 47 }; // Four parts + slotY = new int[] { 19, 37, 37, 55 }; + break; + case 5: + slotX = new int[] { 38, 47, 56, 47 }; // Four parts, double head + slotY = new int[] { 19, 55, 19, 37 }; + break; + case 6: + slotX = new int[] { 38, 38, 20, 56 }; // Double head + slotY = new int[] { 28, 46, 28, 28 }; + break; + case 7: + slotX = new int[] { 56, 56, 56, 14 }; // Three parts reverse + slotY = new int[] { 19, 37, 55, 37 }; + break; + } + toolSlots.resetSlots(slotX, slotY); + } +} diff --git a/tconstruct/client/gui/ToolStationGui.java b/tconstruct/client/gui/ToolStationGui.java new file mode 100644 index 00000000..40840687 --- /dev/null +++ b/tconstruct/client/gui/ToolStationGui.java @@ -0,0 +1,514 @@ +package tconstruct.client.gui; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.ToolStationLogic; +import tconstruct.inventory.ActiveContainer; +import tconstruct.inventory.ToolStationContainer; +import tconstruct.library.client.TConstructClientRegistry; +import tconstruct.library.client.ToolGuiElement; +import tconstruct.library.tools.ToolCore; + +import cpw.mods.fml.common.network.PacketDispatcher; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ToolStationGui extends NewContainerGui +{ + public ToolStationLogic logic; + public ToolStationContainer toolSlots; + public GuiTextField text; + public String toolName; + public int guiType; + public int[] slotX, slotY, iconX, iconY; + public boolean active; + public String title, body = ""; + + public ToolStationGui(InventoryPlayer inventoryplayer, ToolStationLogic stationlogic, World world, int x, int y, int z) + { + super((ActiveContainer) stationlogic.getGuiContainer(inventoryplayer, world, x, y, z)); + this.logic = stationlogic; + toolSlots = (ToolStationContainer) container; + text = new GuiTextField(this.fontRenderer, this.xSize / 2 - 5, 8, 30, 12); + this.text.setMaxStringLength(40); + this.text.setEnableBackgroundDrawing(false); + this.text.setVisible(true); + this.text.setCanLoseFocus(false); + this.text.setFocused(true); + this.text.setTextColor(0xffffff); + toolName = ""; + resetGui(); + Keyboard.enableRepeatEvents(true); + } + + protected void mouseClicked (int mouseX, int mouseY, int mouseButton) + { + super.mouseClicked(mouseX, mouseY, mouseButton); + if (mouseButton == 0) + { + int gLeft = this.guiLeft + 68; + int gTop = this.guiTop + 6; + int gWidth = 102; + int gHeight = 12; + active = mouseX > gLeft && mouseX < gLeft + gWidth && mouseY > gTop && mouseY < gTop + gHeight; + } + } + + void resetGui () + { + this.text.setText(""); + guiType = 0; + setSlotType(0); + iconX = new int[] { 0, 1, 2 }; + iconY = new int[] { 13, 13, 13 }; + title = "\u00A7nRepair and Modification"; + body = "The main way to repair or change your tools. Place a tool and a material on the left to get started."; + } + + public void initGui () + { + super.initGui(); + int cornerX = (this.width - this.xSize) / 2; + int cornerY = (this.height - this.ySize) / 2; + + this.buttonList.clear(); + ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0); + GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair + repairButton.enabled = false; + this.buttonList.add(repairButton); + + for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++) + { + ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter); + GuiButtonTool button = new GuiButtonTool(iter, cornerX - 110 + 22 * (iter % 5), cornerY + 22 * (iter / 5), element.buttonIconX, element.buttonIconY, repair.domain, element.texture, element); + this.buttonList.add(button); + } + } + + protected void actionPerformed (GuiButton button) + { + ((GuiButton) this.buttonList.get(guiType)).enabled = true; + guiType = button.id; + button.enabled = false; + + ToolGuiElement element = TConstructClientRegistry.toolButtons.get(guiType); + setSlotType(element.slotType); + iconX = element.iconsX; + iconY = element.iconsY; + title = "\u00A7n" + element.title; + body = element.body; + } + + void setSlotType (int type) + { + switch (type) + { + case 0: + slotX = new int[] { 56, 38, 38 }; // Repair + slotY = new int[] { 37, 28, 46 }; + break; + case 1: + slotX = new int[] { 56, 56, 56 }; // Three parts + slotY = new int[] { 19, 55, 37 }; + break; + case 2: + slotX = new int[] { 56, 56, 14 }; // Two parts + slotY = new int[] { 28, 46, 37 }; + break; + case 3: + slotX = new int[] { 38, 47, 56 }; // Double head + slotY = new int[] { 28, 46, 28 }; + break; + case 7: + slotX = new int[] { 56, 56, 56 }; // Three parts reverse + slotY = new int[] { 19, 37, 55 }; + break; + } + toolSlots.resetSlots(slotX, slotY); + } + + public void updateScreen () + { + super.updateScreen(); + this.text.updateCursorCounter(); + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + this.fontRenderer.drawString(StatCollector.translateToLocal("crafters.ToolStation"), 6, 8, 0x000000); + this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 0x000000); + this.fontRenderer.drawString(toolName + "_", this.xSize / 2 - 18, 8, 0xffffff); + + if (logic.isStackInSlot(0)) + drawToolStats(); + else + drawToolInformation(); + + //this.fontRenderer.drawString("Namebox active: "+active, this.xSize / 2 - 18, -10, 0xffffff); + } + + void drawToolStats () + { + ItemStack stack = logic.getStackInSlot(0); + if (stack.getItem() instanceof ToolCore) + { + ToolCore tool = (ToolCore) stack.getItem(); + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + this.drawCenteredString(fontRenderer, "\u00A7n" + tool.getToolName(), xSize + 63, 8, 0xffffff); + + drawModularToolStats(stack, tool, tags); + } + } + + void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags) + { + List categories = Arrays.asList(tool.toolCategories()); + final int durability = tags.getInteger("Damage"); + final int maxDur = tags.getInteger("TotalDurability"); + int availableDurability = maxDur - durability; + + //Durability + int base = 24; + int offset = 0; + if (maxDur > 0) + { + if (maxDur >= 10000) + { + fontRenderer.drawString("Durability:", xSize + 8, base + offset * 11, 0xffffff); + offset++; + fontRenderer.drawString("- " + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff); + offset++; + } + else + { + fontRenderer.drawString("Durability: " + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff); + offset++; + } + } + + final float stonebound = tags.getFloat("Shoddy"); + //Attack + if (categories.contains("weapon")) + { + int attack = (int) (tags.getInteger("Attack")); + float stoneboundDamage = (float) Math.log(durability / 72f + 1) * -2 * stonebound; + attack += stoneboundDamage; + if (attack < 1) + attack = 1; + + String heart = attack == 2 ? " Heart" : " Hearts"; + if (attack % 2 == 0) + this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, base + offset * 10, 0xffffff); + else + this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, base + offset * 10, 0xffffff); + offset++; + + if (stoneboundDamage != 0) + { + heart = stoneboundDamage == 2 ? " Heart" : " Hearts"; + String bloss = stoneboundDamage > 0 ? "Bonus: " : "Loss: "; + this.fontRenderer.drawString(bloss + (int) stoneboundDamage / 2 + heart, xSize + 8, base + offset * 10, 0xffffff); + offset++; + } + offset++; + } + + if (categories.contains("bow")) + { + DecimalFormat df = new DecimalFormat("##.##"); + df.setRoundingMode(RoundingMode.DOWN); + int drawSpeed = tags.getInteger("DrawSpeed"); + float flightSpeed = tags.getFloat("FlightSpeed"); + float trueDraw = drawSpeed / 20f * flightSpeed; + this.fontRenderer.drawString("Draw Speed: " + df.format(trueDraw) + "s", xSize + 8, base + offset * 10, 0xffffff); + offset++; + this.fontRenderer.drawString("Arrow Speed: " + df.format(flightSpeed) + "x", xSize + 8, base + offset * 10, 0xffffff); + offset++; + offset++; + } + + if (categories.contains("ammo")) + { + DecimalFormat df = new DecimalFormat("##.##"); + df.setRoundingMode(RoundingMode.DOWN); + int attack = (int) (tags.getInteger("Attack")); + float mass = tags.getFloat("Mass"); + float shatter = tags.getFloat("BreakChance"); + float accuracy = tags.getFloat("Accuracy"); + + this.fontRenderer.drawString("Base Attack:", xSize + 8, base + offset * 10, 0xffffff); + offset++; + String heart = attack == 2 ? " Heart" : " Hearts"; + if (attack % 2 == 0) + this.fontRenderer.drawString("- " + attack / 2 + heart, xSize + 8, base + offset * 10, 0xffffff); + else + this.fontRenderer.drawString("- " + attack / 2f + heart, xSize + 8, base + offset * 10, 0xffffff); + offset++; + int minAttack = attack; + int maxAttack = attack * 2; + heart = " Hearts"; + this.fontRenderer.drawString("Shortbow Attack:", xSize + 8, base + offset * 10, 0xffffff); + offset++; + this.fontRenderer.drawString(df.format(minAttack / 2f) + "-" + df.format(maxAttack / 2f) + heart, xSize + 8, base + offset * 10, 0xffffff); + offset++; + offset++; + + this.fontRenderer.drawString("Weight: " + df.format(mass), xSize + 8, base + offset * 10, 0xffffff); + offset++; + this.fontRenderer.drawString("Accuracy: " + df.format(accuracy - 4) + "%", xSize + 8, base + offset * 10, 0xffffff); + offset++; + /*this.fontRenderer.drawString("Chance to break: " + df.format(shatter)+"%", xSize + 8, base + offset * 10, 0xffffff); + offset++;*/ + offset++; + } + + //Mining + if (categories.contains("dualharvest")) + { + float mineSpeed = tags.getInteger("MiningSpeed") / 100f; + float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f; + float stoneboundSpeed = (float) Math.log(durability / 90f + 1) * 2 * stonebound; + DecimalFormat df = new DecimalFormat("##.##"); + df.setRoundingMode(RoundingMode.DOWN); + float trueSpeed = mineSpeed + stoneboundSpeed; + float trueSpeed2 = mineSpeed + stoneboundSpeed; + + fontRenderer.drawString("Mining Speeds: ", xSize + 8, base + offset * 10, 0xffffff); + offset++; + fontRenderer.drawString("- " + df.format(trueSpeed) + ", " + df.format(trueSpeed2), xSize + 8, base + offset * 10, 0xffffff); + offset++; + if (stoneboundSpeed != 0) + { + String bloss = stoneboundSpeed > 0 ? "Bonus: " : "Loss: "; + fontRenderer.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff); + offset++; + } + offset++; + fontRenderer.drawString("Harvest Levels:", xSize + 8, base + offset * 10, 0xffffff); + offset++; + fontRenderer + .drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel")) + ", " + getHarvestLevelName(tags.getInteger("HarvestLevel2")), xSize + 8, base + offset * 10, 0xffffff); + offset++; + offset++; + } + else if (categories.contains("harvest")) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } + + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } + + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + + float trueSpeed = mineSpeed / (heads * 100f); + + float stoneboundSpeed = (float) Math.log(durability / 90f + 1) * 2 * stonebound; + DecimalFormat df = new DecimalFormat("##.##"); + df.setRoundingMode(RoundingMode.DOWN); + trueSpeed += stoneboundSpeed; + if (trueSpeed < 0) + trueSpeed = 0; + fontRenderer.drawString("Mining Speed: " + df.format(trueSpeed), xSize + 8, base + offset * 10, 0xffffff); + offset++; + if (stoneboundSpeed != 0) + { + String bloss = stoneboundSpeed > 0 ? "Bonus: " : "Loss: "; + fontRenderer.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff); + offset++; + } + fontRenderer.drawString("Mining Level: " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, base + offset * 10, 0xffffff); + offset++; + offset++; + } + else if (categories.contains("utility")) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + float trueSpeed = mineSpeed / (100f); + fontRenderer.drawString("Usage Speed: " + trueSpeed, xSize + 8, base + offset * 10, 0xffffff); + offset++; + offset++; + } + + int modifiers = tags.getInteger("Modifiers"); + if (modifiers > 0) + { + fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, base + offset * 10, 0xffffff); + offset++; + } + if (tags.hasKey("Tooltip1")) + { + fontRenderer.drawString("Modifiers:", xSize + 8, base + offset * 10, 0xffffff); + } + + boolean displayToolTips = true; + int tipNum = 0; + while (displayToolTips) + { + tipNum++; + String tooltip = "ModifierTip" + tipNum; + if (tags.hasKey(tooltip)) + { + String tipName = tags.getString(tooltip); + fontRenderer.drawString("- " + tipName, xSize + 8, base + (offset + tipNum) * 10, 0xffffff); + } + else + displayToolTips = false; + } + } + + void drawToolInformation () + { + this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 0xffffff); + fontRenderer.drawSplitString(body, xSize + 8, 24, 115, 0xffffff); + } + + String getHarvestLevelName (int num) + { + switch (num) + { + case 0: + return "Stone"; + case 1: + return "Iron"; + case 2: + return "Redstone"; + case 3: + return "Obsidian"; //Mithril + case 4: + return "Cobalt"; + case 5: + return "Manyullyn"; + default: + return String.valueOf(num); + } + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/toolstation.png"); + private static final ResourceLocation icons = new ResourceLocation("tinker", "textures/gui/icons.png"); + private static final ResourceLocation description = new ResourceLocation("tinker", "textures/gui/description.png"); + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3) + { + // Draw the background + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(background); + int cornerX = (this.width - this.xSize) / 2; + int cornerY = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize); + + if (active) + { + this.drawTexturedModalRect(cornerX + 62, cornerY, 0, this.ySize, 112, 22); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(icons); + // Draw the slots + + for (int i = 0; i < slotX.length; i++) + { + this.drawTexturedModalRect(cornerX + slotX[i] - 4, cornerY + slotY[i] - 4, 140, 212, 28, 28); + if (!logic.isStackInSlot(i + 1)) + { + this.drawTexturedModalRect(cornerX + slotX[i], cornerY + slotY[i], 18 * iconX[i], 18 * iconY[i], 18, 18); + } + } + + // Draw description + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.func_110434_K().func_110577_a(description); + cornerX = (this.width + this.xSize) / 2; + cornerY = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(cornerX, cornerY, 0, 0, 126, this.ySize + 30); + + } + + protected void keyTyped (char par1, int keyCode) + { + if (keyCode == 1 || (!active && keyCode == this.mc.gameSettings.keyBindInventory.keyCode)) + { + logic.setToolname(""); + updateServer(""); + Keyboard.enableRepeatEvents(false); + this.mc.thePlayer.closeScreen(); + } + else if (active) + { + text.textboxKeyTyped(par1, keyCode); + toolName = text.getText().trim(); + logic.setToolname(toolName); + updateServer(toolName); + } + } + + void updateServer (String name) + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(1); + outputStream.writeInt(logic.worldObj.provider.dimensionId); + outputStream.writeInt(logic.xCoord); + outputStream.writeInt(logic.yCoord); + outputStream.writeInt(logic.zCoord); + outputStream.writeUTF(name); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "TConstruct"; + packet.data = bos.toByteArray(); + packet.length = bos.size(); + + PacketDispatcher.sendPacketToServer(packet); + } + + /*protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + text.mouseClicked(par1, par2, par3); + }*/ +} diff --git a/tconstruct/client/gui/TurnPageButton.java b/tconstruct/client/gui/TurnPageButton.java new file mode 100644 index 00000000..c601afe4 --- /dev/null +++ b/tconstruct/client/gui/TurnPageButton.java @@ -0,0 +1,54 @@ +package tconstruct.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class TurnPageButton extends GuiButton +{ + /** + * True for pointing right (next page), false for pointing left (previous page). + */ + private final boolean nextPage; + + public TurnPageButton(int par1, int par2, int par3, boolean par4) + { + super(par1, par2, par3, 23, 13, ""); + this.nextPage = par4; + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/bookleft.png"); + + /** + * Draws this button to the screen. + */ + public void drawButton (Minecraft par1Minecraft, int par2, int par3) + { + if (this.drawButton) + { + boolean var4 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + par1Minecraft.func_110434_K().func_110577_a(background); + int var5 = 0; + int var6 = 192; + + if (var4) + { + var5 += 23; + } + + if (!this.nextPage) + { + var6 += 13; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, var5, var6, 23, 13); + } + } +} diff --git a/tconstruct/client/pages/BlankPage.java b/tconstruct/client/pages/BlankPage.java new file mode 100644 index 00000000..3665dc1d --- /dev/null +++ b/tconstruct/client/pages/BlankPage.java @@ -0,0 +1,18 @@ +package tconstruct.client.pages; + +import org.w3c.dom.Element; + +public class BlankPage extends BookPage +{ + + @Override + public void readPageFromXML (Element element) + { + } + + @Override + public void renderContentLayer (int localwidth, int localheight) + { + } + +} diff --git a/tconstruct/client/pages/BlockCastPage.java b/tconstruct/client/pages/BlockCastPage.java new file mode 100644 index 00000000..c1ceb078 --- /dev/null +++ b/tconstruct/client/pages/BlockCastPage.java @@ -0,0 +1,67 @@ +package tconstruct.client.pages; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import tconstruct.library.client.TConstructClientRegistry; + + +public class BlockCastPage extends BookPage +{ + String text; + ItemStack[] icons; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("text"); + if (nodes != null) + text = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("recipe"); + if (nodes != null) + icons = TConstructClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + if (text != null) + manual.fonts.drawString("\u00a7n" + text, localWidth + 70, localHeight + 4, 0); + + GL11.glScalef(2f, 2f, 2f); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + manual.renderitem.zLevel = 100; + + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 138) / 2, (localHeight + 110) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[1], (localWidth + 70) / 2, (localHeight + 74) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[2], (localWidth + 70) / 2, (localHeight + 110) / 2); + + if (icons[0].stackSize > 1) + manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(icons[0].stackSize)); + + manual.renderitem.zLevel = 0; + GL11.glScalef(0.5F, 0.5F, 0.5F); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + manual.fonts.drawString("Ingredients:", localWidth + 120, localHeight + 32, 0); + manual.fonts.drawString("- " + icons[1].getDisplayName(), localWidth + 120, localHeight + 42, 0); + if (icons[2] != null) + manual.fonts.drawString("- " + icons[2].getDisplayName(), localWidth + 120, localHeight + 50, 0); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/booksmeltery.png"); + public void renderBackgroundLayer (int localWidth, int localHeight) + { + manual.getMC().func_110434_K().func_110577_a(background); + manual.drawTexturedModalRect(localWidth, localHeight + 32, 0, 0, 174, 115); + manual.drawTexturedModalRect(localWidth + 62, localHeight + 105, 2, 118, 45, 45); + } +} diff --git a/tconstruct/client/pages/BookPage.java b/tconstruct/client/pages/BookPage.java new file mode 100644 index 00000000..02f3f239 --- /dev/null +++ b/tconstruct/client/pages/BookPage.java @@ -0,0 +1,26 @@ +package tconstruct.client.pages; + + +import org.w3c.dom.Element; + +import tconstruct.client.gui.GuiManual; + +public abstract class BookPage +{ + protected GuiManual manual; + protected int side; + + public void init (GuiManual manual, int side) + { + this.manual = manual; + this.side = side; + } + + public abstract void readPageFromXML (Element element); + + public void renderBackgroundLayer (int localwidth, int localheight) + { + } + + public abstract void renderContentLayer (int localwidth, int localheight); +} diff --git a/tconstruct/client/pages/ContentsTablePage.java b/tconstruct/client/pages/ContentsTablePage.java new file mode 100644 index 00000000..b7b847c2 --- /dev/null +++ b/tconstruct/client/pages/ContentsTablePage.java @@ -0,0 +1,58 @@ +package tconstruct.client.pages; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import tconstruct.library.client.TConstructClientRegistry; + + +public class ContentsTablePage extends BookPage +{ + String text; + String[] iconText; + ItemStack[] icons; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("text"); + if (nodes != null) + text = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("link"); + iconText = new String[nodes.getLength()]; + icons = new ItemStack[nodes.getLength()]; + for (int i = 0; i < nodes.getLength(); i++) + { + NodeList children = nodes.item(i).getChildNodes(); + iconText[i] = children.item(1).getTextContent(); + icons[i] = TConstructClientRegistry.getManualIcon(children.item(3).getTextContent()); + } + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + if (text != null) + manual.fonts.drawString("\u00a7n" + text, localWidth + 25 + manual.fonts.getStringWidth(text) / 2, localHeight + 4, 0); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + manual.renderitem.zLevel = 100; + for (int i = 0; i < icons.length; i++) + { + manual.renderitem.renderItemIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 16, localHeight + 18 * i + 18); + int yOffset = 18; + if (iconText[i].length() > 40) + yOffset = 13; + manual.fonts.drawString(iconText[i], localWidth + 38, localHeight + 18 * i + yOffset, 0); + } + manual.renderitem.zLevel = 0; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } +} diff --git a/tconstruct/client/pages/CraftingPage.java b/tconstruct/client/pages/CraftingPage.java new file mode 100644 index 00000000..cdb055bb --- /dev/null +++ b/tconstruct/client/pages/CraftingPage.java @@ -0,0 +1,105 @@ +package tconstruct.client.pages; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import tconstruct.library.client.TConstructClientRegistry; + + +public class CraftingPage extends BookPage +{ + String text; + String size; + ItemStack[] icons; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("text"); + if (nodes != null) + text = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("name"); + if (nodes != null) + icons = TConstructClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); + + nodes = element.getElementsByTagName("size"); + if (nodes != null) + size = nodes.item(0).getTextContent(); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + if (size.equals("two")) + drawCraftingPage(text, icons, 2, localWidth, localHeight + 12); + if (size.equals("three")) + drawCraftingPage(text, icons, 3, localWidth + (side != 1 ? 6 : 0), localHeight + 12); + } + + public void drawCraftingPage (String info, ItemStack[] icons, int recipeSize, int localWidth, int localHeight) + { + if (info != null) + manual.fonts.drawString("\u00a7n" + info, localWidth + 50, localHeight + 4, 0); + + GL11.glScalef(2f, 2f, 2f); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + manual.renderitem.zLevel = 100; + + if (recipeSize == 2) + { + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2); + if (icons[0].stackSize > 1) + manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + for (int i = 0; i < icons.length - 1; i++) + { + if (icons[i + 1] != null) + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i + 1], (localWidth + 14 + 36 * (i % 2)) / 2, (localHeight + 36 * (i / 2) + 52) / 2); + } + } + + if (recipeSize == 3) + { + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 138) / 2, (localHeight + 70) / 2); + if (icons[0].stackSize > 1) + manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + for (int i = 0; i < icons.length - 1; i++) + { + if (icons[i + 1] != null) + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i + 1], (localWidth - 2 + 36 * (i % 3)) / 2, (localHeight + 36 * (i / 3) + 34) / 2); + } + } + + manual.renderitem.zLevel = 0; + GL11.glScalef(0.5F, 0.5F, 0.5F); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + + public void renderBackgroundLayer (int localwidth, int localheight) + { + if (size.equals("two")) + drawBackground(2, localwidth, localheight + 12); + + if (size.equals("three")) + drawBackground(3, localwidth + (side != 1 ? 6 : 0), localheight + 12); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/bookcrafting.png"); + public void drawBackground (int size, int localWidth, int localHeight) + { + manual.getMC().func_110434_K().func_110577_a(background); + if (size == 2) + manual.drawTexturedModalRect(localWidth + 8, localHeight + 46, 0, 116, 154, 78); + if (size == 3) + manual.drawTexturedModalRect(localWidth - 8, localHeight + 28, 0, 0, 183, 114); + } + +} diff --git a/tconstruct/client/pages/FurnacePage.java b/tconstruct/client/pages/FurnacePage.java new file mode 100644 index 00000000..cc90c614 --- /dev/null +++ b/tconstruct/client/pages/FurnacePage.java @@ -0,0 +1,62 @@ +package tconstruct.client.pages; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import tconstruct.library.client.TConstructClientRegistry; + + +public class FurnacePage extends BookPage +{ + String text; + ItemStack[] icons; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("text"); + if (nodes != null) + text = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("recipe"); + if (nodes != null) + icons = TConstructClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + if (text != null) + manual.fonts.drawString("\u00a7n" + text, localWidth + 50, localHeight + 4, 0); + + GL11.glScalef(2f, 2f, 2f); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + manual.renderitem.zLevel = 100; + + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, TConstructClientRegistry.getManualIcon("coal"), (localWidth + 38) / 2, (localHeight + 110) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[1], (localWidth + 38) / 2, (localHeight + 38) / 2); + + if (icons[0].stackSize > 1) + manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(icons[0].stackSize)); + + manual.renderitem.zLevel = 0; + GL11.glScalef(0.5F, 0.5F, 0.5F); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/bookfurnace.png"); + + public void renderBackgroundLayer (int localWidth, int localHeight) + { + manual.getMC().func_110434_K().func_110577_a(background); + manual.drawTexturedModalRect(localWidth + 32, localHeight + 32, 0, 0, 111, 114); + } +} diff --git a/tconstruct/client/pages/MaterialPage.java b/tconstruct/client/pages/MaterialPage.java new file mode 100644 index 00000000..aa7a317f --- /dev/null +++ b/tconstruct/client/pages/MaterialPage.java @@ -0,0 +1,134 @@ +package tconstruct.client.pages; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import tconstruct.client.gui.PartCrafterGui; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.client.TConstructClientRegistry; +import tconstruct.library.crafting.PatternBuilder; +import tconstruct.library.tools.ToolMaterial; + +public class MaterialPage extends BookPage +{ + String title; + ItemStack[] icons; + String iconText; + ToolMaterial material; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("title"); + if (nodes != null) + title = nodes.item(0).getTextContent(); + + icons = new ItemStack[4]; + + nodes = element.getElementsByTagName("text"); + if (nodes != null) + iconText = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("icon"); + if (nodes != null) + icons[0] = TConstructClientRegistry.getManualIcon(nodes.item(0).getTextContent()); + + nodes = element.getElementsByTagName("toolmaterial"); + if (nodes != null && nodes.getLength() > 0) + material = TConstructRegistry.getMaterial(nodes.item(0).getTextContent()); + else + material = TConstructRegistry.getMaterial(title); + + nodes = element.getElementsByTagName("material").item(0).getChildNodes(); + + icons[1] = TConstructClientRegistry.getManualIcon(nodes.item(1).getTextContent()); + icons[2] = PatternBuilder.instance.getShardFromSet(material.name()); + icons[3] = PatternBuilder.instance.getRodFromSet(material.name()); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + manual.fonts.drawString("\u00a7n" + title, localWidth + 70, localHeight + 4, 0); + manual.fonts.drawSplitString(iconText, localWidth, localHeight + 16, 178, 0); + + manual.fonts.drawString("Material: ", localWidth + 108, localHeight + 40, 0); + manual.fonts.drawString("Shard: ", localWidth + 108, localHeight + 72, 0); + manual.fonts.drawString("Rod: ", localWidth + 108, localHeight + 104, 0); + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + manual.renderitem.zLevel = 100; + //renderitem.renderItemAndEffectIntoGUI(fonts, getMC().renderEngine, icons[0], localWidth + 50, localHeight + 0); + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[1], localWidth + 108, localHeight + 50); + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[2], localWidth + 108, localHeight + 82); + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[3], localWidth + 108, localHeight + 114); + manual.renderitem.zLevel = 0; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + + String icon = icons[1].getTooltip(manual.getMC().thePlayer, false).get((0)).toString(); + int iconOffset = icon.length() > 12 ? 0 : 3; + manual.fonts.drawSplitString(icon, localWidth + 128, localHeight + 50 + iconOffset, 52, 0); + + if (icons[2] != null) + { + icon = icons[2].getTooltip(manual.getMC().thePlayer, false).get((0)).toString(); + iconOffset = icon.length() > 12 ? 0 : 3; + manual.fonts.drawSplitString(icons[2].getTooltip(manual.getMC().thePlayer, false).get((0)).toString(), localWidth + 128, localHeight + 82 + iconOffset, 52, 0); + } + if (icons[3] != null) + { + icon = icons[3].getTooltip(manual.getMC().thePlayer, false).get((0)).toString(); + iconOffset = icon.length() > 12 ? 0 : 3; + manual.fonts.drawSplitString(icons[3].getTooltip(manual.getMC().thePlayer, false).get((0)).toString(), localWidth + 128, localHeight + 114 + iconOffset, 52, 0); + } + + manual.fonts.drawString("Durability: " + material.durability(), localWidth, localHeight + 40, 0); + manual.fonts.drawString("Handle Modifier: " + material.handleDurability() + "x", localWidth, localHeight + 50, 0); + manual.fonts.drawString("Full Tool Durability: " + (int) (material.durability() * material.handleDurability()), localWidth, localHeight + 60, 0); + + manual.fonts.drawString("Mining Speed: " + material.toolSpeed() / 100f, localWidth, localHeight + 80, 0); + manual.fonts.drawString("Mining Level: " + material.harvestLevel() + " (" + PartCrafterGui.getHarvestLevelName(material.harvestLevel()) + ")", localWidth, localHeight + 90, 0); + int attack = material.attack(); + String heart = attack == 2 ? " Heart" : " Hearts"; + if (attack % 2 == 0) + manual.fonts.drawString("Base Attack: " + material.attack() / 2 + heart, localWidth, localHeight + 100, 0); + else + manual.fonts.drawString("Base Attack: " + material.attack() / 2f + heart, localWidth, localHeight + 100, 0); + + int offset = 0; + String ability = material.ability(); + if (!ability.equals("")) + { + manual.fonts.drawString("Material ability: " + material.ability(), localWidth, localHeight + 120 + 10 * offset, 0); + offset++; + if (ability.equals("Writable")) + manual.fonts.drawString("+1 Modifiers", localWidth, localHeight + 120 + 10 * offset, 0); + } + + if (material.reinforced() > 0) + { + manual.fonts.drawString("Material ability: Reinforced", localWidth, localHeight + 120 + 10 * offset, 0); + offset++; + manual.fonts.drawString("Reinforced level: " + material.reinforced(), localWidth, localHeight + 120 + 10 * offset, 0); + offset++; + } + + if (material.shoddy() > 0) + { + manual.fonts.drawString("Stonebound level: " + material.shoddy(), localWidth, localHeight + 120 + 10 * offset, 0); + offset++; + } + else if (material.shoddy() < 0) + { + manual.fonts.drawString("Splintering level: " + -material.shoddy(), localWidth, localHeight + 120 + 10 * offset, 0); + offset++; + } + } +} diff --git a/tconstruct/client/pages/ModifierPage.java b/tconstruct/client/pages/ModifierPage.java new file mode 100644 index 00000000..2621cb8d --- /dev/null +++ b/tconstruct/client/pages/ModifierPage.java @@ -0,0 +1,63 @@ +package tconstruct.client.pages; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import tconstruct.library.client.TConstructClientRegistry; + + +public class ModifierPage extends BookPage +{ + String type; + ItemStack[] icons; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("tooltype"); + if (nodes != null) + type = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("recipe"); + if (nodes != null) + icons = TConstructClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + manual.fonts.drawString("\u00a7nTool Station", localWidth + 60, localHeight + 4, 0); + GL11.glScalef(2f, 2f, 2f); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + + ItemStack toolstack = TConstructClientRegistry.getManualIcon("ironpick"); + if (type.equals("weapon")) + toolstack = TConstructClientRegistry.getManualIcon("ironlongsword"); + + manual.renderitem.zLevel = 100; + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, toolstack, (localWidth + 54) / 2, (localHeight + 54) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 130) / 2, (localHeight + 54) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[1], (localWidth + 18) / 2, (localHeight + 36) / 2); + if (icons[2] != null) + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[2], (localWidth + 18) / 2, (localHeight + 74) / 2); + manual.renderitem.zLevel = 0; + + GL11.glScalef(0.5F, 0.5F, 0.5F); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/bookmodify.png"); + public void renderBackgroundLayer (int localWidth, int localHeight) + { + manual.getMC().func_110434_K().func_110577_a(background); + manual.drawTexturedModalRect(localWidth + 12, localHeight + 32, 0, 0, 154, 78); + } +} diff --git a/tconstruct/client/pages/PicturePage.java b/tconstruct/client/pages/PicturePage.java new file mode 100644 index 00000000..6bcd66d4 --- /dev/null +++ b/tconstruct/client/pages/PicturePage.java @@ -0,0 +1,38 @@ +package tconstruct.client.pages; + +import net.minecraft.util.ResourceLocation; + +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +public class PicturePage extends BookPage +{ + String text; + String location; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("text"); + if (nodes != null) + text = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("location"); + if (nodes != null) + location = nodes.item(0).getTextContent(); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + manual.fonts.drawSplitString(text, localWidth + 8, localHeight, 178, 0); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/bookcrafting.png"); + public void renderBackgroundLayer (int localWidth, int localHeight) + { + manual.getMC().func_110434_K().func_110577_a(background); + //manual.getMC().renderEngine.bindTexture(location); + manual.drawTexturedModalRect(localWidth, localHeight + 12, 0, 0, 170, 144); + } +} diff --git a/tconstruct/client/pages/SectionPage.java b/tconstruct/client/pages/SectionPage.java new file mode 100644 index 00000000..e790c894 --- /dev/null +++ b/tconstruct/client/pages/SectionPage.java @@ -0,0 +1,29 @@ +package tconstruct.client.pages; + +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +public class SectionPage extends BookPage +{ + String title; + String body; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("title"); + if (nodes != null) + title = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("text"); + if (nodes != null) + body = nodes.item(0).getTextContent(); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + manual.fonts.drawSplitString("\u00a7n" + title, localWidth + 70, localHeight + 4, 178, 0); + manual.fonts.drawSplitString(body, localWidth, localHeight + 16, 190, 0); + } +} diff --git a/tconstruct/client/pages/SidebarPage.java b/tconstruct/client/pages/SidebarPage.java new file mode 100644 index 00000000..0c3f19bf --- /dev/null +++ b/tconstruct/client/pages/SidebarPage.java @@ -0,0 +1,58 @@ +package tconstruct.client.pages; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import tconstruct.library.client.TConstructClientRegistry; + + +public class SidebarPage extends BookPage +{ + String text; + String[] iconText; + ItemStack[] icons; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("text"); + if (nodes != null) + text = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("item"); + iconText = new String[nodes.getLength()]; + icons = new ItemStack[nodes.getLength()]; + for (int i = 0; i < nodes.getLength(); i++) + { + NodeList children = nodes.item(i).getChildNodes(); + iconText[i] = children.item(1).getTextContent(); + icons[i] = TConstructClientRegistry.getManualIcon(children.item(3).getTextContent()); + } + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + manual.renderitem.zLevel = 100; + int offset = text.length() / 4 + 10; + for (int i = 0; i < icons.length; i++) + { + manual.renderitem.renderItemIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 8, localHeight + 18 * i + offset); + int yOffset = 39; + if (iconText[i].length() > 40) + yOffset = 34; + manual.fonts.drawSplitString(iconText[i], localWidth + 30, localHeight + 18 * i + offset, 140, 0); + } + manual.renderitem.zLevel = 0; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } +} diff --git a/tconstruct/client/pages/TextPage.java b/tconstruct/client/pages/TextPage.java new file mode 100644 index 00000000..4f795009 --- /dev/null +++ b/tconstruct/client/pages/TextPage.java @@ -0,0 +1,23 @@ +package tconstruct.client.pages; + +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +public class TextPage extends BookPage +{ + String text; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("text"); + if (nodes != null) + text = nodes.item(0).getTextContent(); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0); + } +} diff --git a/tconstruct/client/pages/TitlePage.java b/tconstruct/client/pages/TitlePage.java new file mode 100644 index 00000000..249f0c81 --- /dev/null +++ b/tconstruct/client/pages/TitlePage.java @@ -0,0 +1,23 @@ +package tconstruct.client.pages; + +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +public class TitlePage extends BookPage +{ + String text; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("text"); + if (nodes != null) + text = nodes.item(0).getTextContent(); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0); + } +} diff --git a/tconstruct/client/pages/ToolPage.java b/tconstruct/client/pages/ToolPage.java new file mode 100644 index 00000000..956b198f --- /dev/null +++ b/tconstruct/client/pages/ToolPage.java @@ -0,0 +1,94 @@ +package tconstruct.client.pages; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import tconstruct.library.client.TConstructClientRegistry; + + +public class ToolPage extends BookPage +{ + String title; + ItemStack[] icons; + String[] iconText; + + @Override + public void readPageFromXML (Element element) + { + NodeList nodes = element.getElementsByTagName("title"); + if (nodes != null) + title = nodes.item(0).getTextContent(); + + nodes = element.getElementsByTagName("item"); + iconText = new String[nodes.getLength() + 2]; + icons = new ItemStack[nodes.getLength() + 1]; + + for (int i = 0; i < nodes.getLength(); i++) + { + NodeList children = nodes.item(i).getChildNodes(); + iconText[i + 2] = children.item(1).getTextContent(); + icons[i + 1] = TConstructClientRegistry.getManualIcon(children.item(3).getTextContent()); + } + + nodes = element.getElementsByTagName("text"); + if (nodes != null) + { + iconText[0] = nodes.item(0).getTextContent(); + iconText[1] = nodes.item(1).getTextContent(); + } + + nodes = element.getElementsByTagName("icon"); + if (nodes != null) + icons[0] = TConstructClientRegistry.getManualIcon(nodes.item(0).getTextContent()); + } + + @Override + public void renderContentLayer (int localWidth, int localHeight) + { + manual.fonts.drawString("\u00a7n" + title, localWidth + 70, localHeight + 4, 0); + manual.fonts.drawSplitString(iconText[0], localWidth, localHeight + 16, 178, 0); + int size = iconText[0].length() / 48; + manual.fonts.drawSplitString(iconText[1], localWidth, localHeight + 28 + 10 * size, 118, 0); + + manual.fonts.drawString("Crafting Parts: ", localWidth + 124, localHeight + 28 + 10 * size, 0); + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + manual.renderitem.zLevel = 100; + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], localWidth + 50, localHeight + 0); + for (int i = 1; i < icons.length; i++) + { + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 120, localHeight + 20 + 10 * size + 18 * i); + int partOffset = iconText[i + 1].length() > 11 ? -3 : 0; + manual.fonts.drawSplitString(iconText[i + 1], localWidth + 140, localHeight + 24 + 10 * size + 18 * i + partOffset, 44, 0); + } + manual.renderitem.zLevel = 0; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + /*manual.fonts.drawString("\u00a7n" + title, localWidth + 70, localHeight + 4, 0); + manual.fonts.drawSplitString(iconText[0], localWidth, localHeight + 16, 178, 0); + int size = iconText[0].length() / 48; + manual.fonts.drawSplitString(iconText[1], localWidth, localHeight + 28 + 10 * size, 118, 0); + + manual.fonts.drawString("Crafting Parts: ", localWidth + 124, localHeight + 28 + 10 * size, 0); + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + manual.renderitem.zLevel = 100; + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], localWidth + 50, localHeight + 0); + for (int i = 1; i < icons.length; i++) + { + manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 120, localHeight + 20 + 10 * size + 18 * i); + int partOffset = iconText[i + 1].length() > 11 ? -3 : 0; + manual.fonts.drawSplitString(iconText[i + 1], localWidth + 140, localHeight + 24 + 10 * size + 18 * i + partOffset, 44, 0); + } + manual.renderitem.zLevel = 0; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL);*/ + } +} diff --git a/tconstruct/common/TContent.java b/tconstruct/common/TContent.java new file mode 100644 index 00000000..45f631c6 --- /dev/null +++ b/tconstruct/common/TContent.java @@ -0,0 +1,2063 @@ +package tconstruct.common; + +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockDispenser; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.block.material.MaterialLiquid; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.RecipesTools; +import net.minecraft.item.crafting.RecipesWeapons; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; +import tconstruct.TConstruct; +import tconstruct.blocks.Aggregator; +import tconstruct.blocks.DryingRack; +import tconstruct.blocks.EquipBlock; +import tconstruct.blocks.GlassBlockConnected; +import tconstruct.blocks.GlassBlockConnectedMeta; +import tconstruct.blocks.GlassPane; +import tconstruct.blocks.GlassPaneStained; +import tconstruct.blocks.GravelOre; +import tconstruct.blocks.LavaTankBlock; +import tconstruct.blocks.LightCrystalBase; +import tconstruct.blocks.LiquidMetalFinite; +import tconstruct.blocks.MetalOre; +import tconstruct.blocks.MultiBrick; +import tconstruct.blocks.MultiBrickFancy; +import tconstruct.blocks.OreberryBush; +import tconstruct.blocks.OreberryBushEssence; +import tconstruct.blocks.RedstoneMachine; +import tconstruct.blocks.SearedBlock; +import tconstruct.blocks.SearedSlab; +import tconstruct.blocks.SmelteryBlock; +import tconstruct.blocks.SoilBlock; +import tconstruct.blocks.SpeedBlock; +import tconstruct.blocks.SpeedSlab; +import tconstruct.blocks.StoneTorch; +import tconstruct.blocks.TMetalBlock; +import tconstruct.blocks.ToolForgeBlock; +import tconstruct.blocks.ToolStationBlock; +import tconstruct.blocks.logic.CastingBasinLogic; +import tconstruct.blocks.logic.CastingTableLogic; +import tconstruct.blocks.logic.DrawbridgeLogic; +import tconstruct.blocks.logic.DryingRackLogic; +import tconstruct.blocks.logic.FaucetLogic; +import tconstruct.blocks.logic.FirestarterLogic; +import tconstruct.blocks.logic.FrypanLogic; +import tconstruct.blocks.logic.GlowstoneAggregator; +import tconstruct.blocks.logic.LavaTankLogic; +import tconstruct.blocks.logic.MultiServantLogic; +import tconstruct.blocks.logic.PartCrafterLogic; +import tconstruct.blocks.logic.PatternChestLogic; +import tconstruct.blocks.logic.SmelteryDrainLogic; +import tconstruct.blocks.logic.SmelteryLogic; +import tconstruct.blocks.logic.StencilTableLogic; +import tconstruct.blocks.logic.ToolForgeLogic; +import tconstruct.blocks.logic.ToolStationLogic; +import tconstruct.entity.Automaton; +import tconstruct.entity.BlueSlime; +import tconstruct.entity.Crystal; +import tconstruct.entity.FancyEntityItem; +import tconstruct.entity.MiniGardy; +import tconstruct.entity.SlimeClone; +import tconstruct.entity.projectile.ArrowEntity; +import tconstruct.entity.projectile.DaggerEntity; +import tconstruct.entity.projectile.LaunchedPotion; +import tconstruct.items.Bowstring; +import tconstruct.items.CraftingItem; +import tconstruct.items.DiamondApple; +import tconstruct.items.FilledBucket; +import tconstruct.items.Fletching; +import tconstruct.items.GoldenHead; +import tconstruct.items.Manual; +import tconstruct.items.MaterialItem; +import tconstruct.items.MetalPattern; +import tconstruct.items.OreBerries; +import tconstruct.items.Pattern; +import tconstruct.items.StrangeFood; +import tconstruct.items.TitleIcon; +import tconstruct.items.ToolPart; +import tconstruct.items.ToolPartHidden; +import tconstruct.items.ToolShard; +import tconstruct.items.armor.Glove; +import tconstruct.items.armor.HeartCanister; +import tconstruct.items.armor.Knapsack; +import tconstruct.items.armor.TArmorBase; +import tconstruct.items.blocks.CraftedSoilItemBlock; +import tconstruct.items.blocks.GlassBlockItem; +import tconstruct.items.blocks.GlassPaneItem; +import tconstruct.items.blocks.GravelOreItem; +import tconstruct.items.blocks.LavaTankItemBlock; +import tconstruct.items.blocks.LightCrystalItem; +import tconstruct.items.blocks.MetalItemBlock; +import tconstruct.items.blocks.MetalOreItemBlock; +import tconstruct.items.blocks.MultiBrickFancyItem; +import tconstruct.items.blocks.MultiBrickItem; +import tconstruct.items.blocks.OreberryBushItem; +import tconstruct.items.blocks.OreberryBushSecondItem; +import tconstruct.items.blocks.RedstoneMachineItem; +import tconstruct.items.blocks.SearedSlabItem; +import tconstruct.items.blocks.SearedTableItemBlock; +import tconstruct.items.blocks.SmelteryItemBlock; +import tconstruct.items.blocks.SpeedBlockItem; +import tconstruct.items.blocks.SpeedSlabItem; +import tconstruct.items.blocks.StainedGlassClearItem; +import tconstruct.items.blocks.StainedGlassClearPaneItem; +import tconstruct.items.blocks.ToolForgeItemBlock; +import tconstruct.items.blocks.ToolStationItemBlock; +import tconstruct.items.tools.Arrow; +import tconstruct.items.tools.BattleSign; +import tconstruct.items.tools.Battleaxe; +import tconstruct.items.tools.Broadsword; +import tconstruct.items.tools.Chisel; +import tconstruct.items.tools.Cleaver; +import tconstruct.items.tools.Cutlass; +import tconstruct.items.tools.Dagger; +import tconstruct.items.tools.Excavator; +import tconstruct.items.tools.FryingPan; +import tconstruct.items.tools.Hammer; +import tconstruct.items.tools.Hatchet; +import tconstruct.items.tools.Longsword; +import tconstruct.items.tools.LumberAxe; +import tconstruct.items.tools.Mattock; +import tconstruct.items.tools.Pickaxe; +import tconstruct.items.tools.PotionLauncher; +import tconstruct.items.tools.Rapier; +import tconstruct.items.tools.Scythe; +import tconstruct.items.tools.Shortbow; +import tconstruct.items.tools.Shovel; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.client.TConstructClientRegistry; +import tconstruct.library.crafting.Detailing; +import tconstruct.library.crafting.DryingRackRecipes; +import tconstruct.library.crafting.LiquidCasting; +import tconstruct.library.crafting.PatternBuilder; +import tconstruct.library.crafting.Smeltery; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.tools.ToolCore; +import tconstruct.library.util.IPattern; +import tconstruct.modifiers.ModAntiSpider; +import tconstruct.modifiers.ModAttack; +import tconstruct.modifiers.ModAutoSmelt; +import tconstruct.modifiers.ModBlaze; +import tconstruct.modifiers.ModButtertouch; +import tconstruct.modifiers.ModDurability; +import tconstruct.modifiers.ModElectric; +import tconstruct.modifiers.ModExtraModifier; +import tconstruct.modifiers.ModInteger; +import tconstruct.modifiers.ModLapis; +import tconstruct.modifiers.ModPiston; +import tconstruct.modifiers.ModRedstone; +import tconstruct.modifiers.ModReinforced; +import tconstruct.modifiers.ModRepair; +import tconstruct.modifiers.ModSmite; +import tconstruct.modifiers.TActiveOmniMod; +import tconstruct.util.PHConstruct; +import tconstruct.util.RecipeRemover; +import tconstruct.util.TDispenserBehaviorSpawnEgg; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import extrabiomes.api.BiomeManager; + +public class TContent implements IFuelHandler +{ + //Patterns and other materials + public static Item blankPattern; + public static Item materials; + public static Item toolRod; + public static Item toolShard; + public static Item woodPattern; + public static Item metalPattern; + + public static Item manualBook; + public static Item buckets; + public static Item titleIcon; + + public static Item strangeFood; + public static Item diamondApple; + //public static Item stonePattern; + //public static Item netherPattern; + + //Tools + public static ToolCore pickaxe; + public static ToolCore shovel; + public static ToolCore hatchet; + public static ToolCore broadsword; + public static ToolCore longsword; + public static ToolCore rapier; + public static ToolCore dagger; + public static ToolCore cutlass; + + public static ToolCore frypan; + public static ToolCore battlesign; + public static ToolCore chisel; + public static ToolCore mattock; + + public static ToolCore scythe; + public static ToolCore lumberaxe; + public static ToolCore cleaver; + public static ToolCore excavator; + public static ToolCore hammer; + public static ToolCore battleaxe; + + public static ToolCore shortbow; + public static ToolCore arrow; + + public static Item potionLauncher; + + //Tool parts + public static Item binding; + public static Item toughBinding; + public static Item toughRod; + public static Item heavyPlate; + + public static Item pickaxeHead; + public static Item shovelHead; + public static Item hatchetHead; + public static Item frypanHead; + public static Item signHead; + public static Item chiselHead; + public static Item scytheBlade; + public static Item broadAxeHead; + public static Item excavatorHead; + public static Item hammerHead; + + public static Item swordBlade; + public static Item largeSwordBlade; + public static Item knifeBlade; + + public static Item wideGuard; + public static Item handGuard; + public static Item crossbar; + public static Item fullGuard; + + public static Item bowstring; + public static Item arrowhead; + public static Item fletching; + + //Crafting blocks + public static Block toolStationWood; + public static Block toolStationStone; + public static Block toolForge; + public static Block heldItemBlock; + public static Block craftedSoil; + + public static Block smeltery; + public static Block lavaTank; + public static Block searedBlock; + public static Block metalBlock; + + public static Block redstoneMachine; + public static Block dryingRack; + + //Decoration + public static Block stoneTorch; + public static Block multiBrick; + public static Block multiBrickFancy; + + public static Block searedSlab; + public static Block speedSlab; + + //Traps + public static Block landmine; + public static Block barricade; + + //InfiBlocks + public static Block speedBlock; + public static Block glass; + //public static Block stainedGlass; + public static Block stainedGlassClear; + public static Block glassPane; + //public static Block stainedGlassPane; + public static Block stainedGlassClearPane; + public static Block glassMagicSlab; + public static Block stainedGlassMagicSlab; + public static Block stainedGlassClearMagicSlab; + + //Crystalline + public static Block aggregator; + public static Block lightCrystalBase; + + //Liquids + //public static Block liquidMetalFlowing; + //public static Block liquidMetalStill; + /*String[] names = new String[] { "Molten Iron", "Molten Gold", "Molten Copper", "Molten Tin", "Molten Aluminum", "Molten Cobalt", "Molten Ardite", "Molten Bronze", "Molten Aluminum Brass", + "Molten Manyullyn", "Molten Alumite", "Molten Obsidian", "Molten Steel", "Molten Glass", "Seared Stone", "Molten Emerald", "Blood" };*/ + public static Material liquidMetal; + + public static Fluid moltenIronFluid; + public static Fluid moltenGoldFluid; + public static Fluid moltenCopperFluid; + public static Fluid moltenTinFluid; + public static Fluid moltenAluminumFluid; + public static Fluid moltenCobaltFluid; + public static Fluid moltenArditeFluid; + public static Fluid moltenBronzeFluid; + public static Fluid moltenAlubrassFluid; + public static Fluid moltenManyullynFluid; + public static Fluid moltenAlumiteFluid; + public static Fluid moltenObsidianFluid; + public static Fluid moltenSteelFluid; + public static Fluid moltenGlassFluid; + public static Fluid moltenStoneFluid; + public static Fluid moltenEmeraldFluid; + public static Fluid bloodFluid; + public static Fluid moltenNickelFluid; + public static Fluid moltenLeadFluid; + public static Fluid moltenSilverFluid; + public static Fluid moltenShinyFluid; + public static Fluid moltenInvarFluid; + public static Fluid moltenElectrumFluid; + + public static Block moltenIron; + public static Block moltenGold; + public static Block moltenCopper; + public static Block moltenTin; + public static Block moltenAluminum; + public static Block moltenCobalt; + public static Block moltenArdite; + public static Block moltenBronze; + public static Block moltenAlubrass; + public static Block moltenManyullyn; + public static Block moltenAlumite; + public static Block moltenObsidian; + public static Block moltenSteel; + public static Block moltenGlass; + public static Block moltenStone; + public static Block moltenEmerald; + public static Block blood; + public static Block moltenNickel; + public static Block moltenLead; + public static Block moltenSilver; + public static Block moltenShiny; + public static Block moltenInvar; + public static Block moltenElectrum; + + //Ores + public static Block oreSlag; + public static Block oreGravel; + public static OreberryBush oreBerry; + public static OreberryBush oreBerrySecond; + public static Item oreBerries; + + //Tool modifiers + public static ModElectric modE; + public static ModLapis modL; + + //Golems + /*public static Block glowSapling; + public static Block glowLeaves; + public static Block glowLog;*/ + + public static Block redstoneBallRepeater; + public static Item redstoneBallRepeaterItem; + + public static Block golemCore; + public static Block golemPedestal; + public static Block golemHead; + + public static Item golemWand; + public static Item golemRecharger; + public static Item corestone; + public static Item notebook; + public static Item note; + + //Wearables + public static Item heavyHelmet; + public static Item heavyChestplate; + public static Item heavyPants; + public static Item heavyBoots; + public static Item glove; + public static Item knapsack; + + public static Item heartCanister; + public static Item goldHead; + + //Chest hooks + public static ChestGenHooks tinkerHouseChest; + public static ChestGenHooks tinkerHousePatterns; + + public TContent() + { + registerItems(); + registerBlocks(); + registerMaterials(); + addCraftingRecipes(); + setupToolTabs(); + addLoot(); + } + + public void createEntities () + { + EntityRegistry.registerModEntity(FancyEntityItem.class, "Fancy Item", 0, TConstruct.instance, 32, 5, true); + EntityRegistry.registerModEntity(DaggerEntity.class, "Dagger", 1, TConstruct.instance, 32, 5, true); + EntityRegistry.registerModEntity(Crystal.class, "Crystal", 2, TConstruct.instance, 32, 3, true); + EntityRegistry.registerModEntity(LaunchedPotion.class, "Launched Potion", 3, TConstruct.instance, 32, 3, true); + EntityRegistry.registerModEntity(ArrowEntity.class, "Arrow", 4, TConstruct.instance, 32, 5, true); + //EntityRegistry.registerModEntity(CartEntity.class, "Small Wagon", 1, TConstruct.instance, 32, 5, true); + + //EntityRegistry.registerModEntity(Skyla.class, "Skyla", 10, TConstruct.instance, 32, 5, true); + EntityRegistry.registerModEntity(SlimeClone.class, "SlimeClone", 10, TConstruct.instance, 32, 3, true); + EntityRegistry.registerModEntity(Automaton.class, "Automaton", 11, TConstruct.instance, 64, 3, true); + EntityRegistry.registerModEntity(BlueSlime.class, "EdibleSlime", 12, TConstruct.instance, 64, 5, true); + EntityRegistry.registerModEntity(MiniGardy.class, "MiniGardy", 13, TConstruct.instance, 64, 3, true); + //EntityRegistry.registerModEntity(MetalSlime.class, "MetalSlime", 13, TConstruct.instance, 64, 5, true); + + BiomeGenBase[] plains = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.PLAINS); + BiomeGenBase[] mountain = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.MOUNTAIN); + BiomeGenBase[] hills = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.HILLS); + BiomeGenBase[] swamp = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.SWAMP); + BiomeGenBase[] desert = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.DESERT); + BiomeGenBase[] frozen = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.FROZEN); + BiomeGenBase[] jungle = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.JUNGLE); + BiomeGenBase[] wasteland = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.WASTELAND); + + BiomeGenBase[] nether = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.NETHER); + + /*if (PHConstruct.superfunWorld) + { + EntityRegistry.addSpawn(NitroCreeper.class, 1000, 100, 100, EnumCreatureType.monster, plains); + EntityRegistry.addSpawn(NitroCreeper.class, 1000, 100, 100, EnumCreatureType.monster, mountain); + EntityRegistry.addSpawn(NitroCreeper.class, 1000, 100, 100, EnumCreatureType.monster, hills); + EntityRegistry.addSpawn(NitroCreeper.class, 1000, 100, 100, EnumCreatureType.monster, swamp); + EntityRegistry.addSpawn(NitroCreeper.class, 1000, 100, 100, EnumCreatureType.monster, desert); + EntityRegistry.addSpawn(NitroCreeper.class, 1000, 100, 100, EnumCreatureType.monster, frozen); + EntityRegistry.addSpawn(NitroCreeper.class, 1000, 100, 100, EnumCreatureType.monster, jungle); + EntityRegistry.addSpawn(NitroCreeper.class, 1000, 100, 100, EnumCreatureType.monster, wasteland); + DimensionManager.unregisterProviderType(0); + DimensionManager.registerProviderType(0, OverworldProvider.class, true); + }*/ + if (PHConstruct.blueSlime) + { + EntityRegistry.addSpawn(BlueSlime.class, PHConstruct.blueSlimeWeight, 4, 4, EnumCreatureType.monster, plains); + EntityRegistry.addSpawn(BlueSlime.class, PHConstruct.blueSlimeWeight, 4, 4, EnumCreatureType.monster, mountain); + EntityRegistry.addSpawn(BlueSlime.class, PHConstruct.blueSlimeWeight, 4, 4, EnumCreatureType.monster, hills); + EntityRegistry.addSpawn(BlueSlime.class, PHConstruct.blueSlimeWeight, 4, 4, EnumCreatureType.monster, swamp); + EntityRegistry.addSpawn(BlueSlime.class, PHConstruct.blueSlimeWeight, 4, 4, EnumCreatureType.monster, desert); + EntityRegistry.addSpawn(BlueSlime.class, PHConstruct.blueSlimeWeight, 4, 4, EnumCreatureType.monster, frozen); + EntityRegistry.addSpawn(BlueSlime.class, PHConstruct.blueSlimeWeight, 4, 4, EnumCreatureType.monster, jungle); + EntityRegistry.addSpawn(BlueSlime.class, PHConstruct.blueSlimeWeight, 4, 4, EnumCreatureType.monster, wasteland); + } + + try + { + Class.forName("extrabiomes.api.BiomeManager"); + Collection ebxlCollection = BiomeManager.getBiomes(); + BiomeGenBase[] ebxlBiomes = (BiomeGenBase[]) ebxlCollection.toArray(); + EntityRegistry.addSpawn(BlueSlime.class, PHConstruct.blueSlimeWeight, 4, 4, EnumCreatureType.monster, ebxlBiomes); + } + catch (Exception e) + { + + } + //EntityRegistry.addSpawn(MetalSlime.class, 1, 4, 4, EnumCreatureType.monster, overworldBiomes); + } + + public static Fluid[] fluids = new Fluid[23]; + public static Block[] fluidBlocks = new Block[23]; + + void registerBlocks () + { + //Tool Station + toolStationWood = new ToolStationBlock(PHConstruct.woodCrafter, Material.wood).setUnlocalizedName("ToolStation"); + GameRegistry.registerBlock(toolStationWood, ToolStationItemBlock.class, "ToolStationBlock"); + GameRegistry.registerTileEntity(ToolStationLogic.class, "ToolStation"); + GameRegistry.registerTileEntity(PartCrafterLogic.class, "PartCrafter"); + GameRegistry.registerTileEntity(PatternChestLogic.class, "PatternHolder"); + GameRegistry.registerTileEntity(StencilTableLogic.class, "PatternShaper"); + + toolForge = new ToolForgeBlock(PHConstruct.toolForge, Material.iron).setUnlocalizedName("ToolForge"); + GameRegistry.registerBlock(toolForge, ToolForgeItemBlock.class, "ToolForgeBlock"); + GameRegistry.registerTileEntity(ToolForgeLogic.class, "ToolForge"); + + heldItemBlock = new EquipBlock(PHConstruct.heldItemBlock, Material.wood).setUnlocalizedName("Frypan"); + GameRegistry.registerBlock(heldItemBlock, "HeldItemBlock"); + GameRegistry.registerTileEntity(FrypanLogic.class, "FrypanLogic"); + + craftedSoil = new SoilBlock(PHConstruct.craftedSoil).setUnlocalizedName("TConstruct.Soil"); + craftedSoil.stepSound = Block.soundGravelFootstep; + GameRegistry.registerBlock(craftedSoil, CraftedSoilItemBlock.class, "CraftedSoil"); + + searedSlab = new SearedSlab(PHConstruct.searedSlab).setUnlocalizedName("SearedSlab"); + searedSlab.stepSound = Block.soundStoneFootstep; + GameRegistry.registerBlock(searedSlab, SearedSlabItem.class, "SearedSlab"); + + speedSlab = new SpeedSlab(PHConstruct.speedSlab).setUnlocalizedName("SpeedSlab"); + speedSlab.stepSound = Block.soundStoneFootstep; + GameRegistry.registerBlock(speedSlab, SpeedSlabItem.class, "SpeedSlab"); + + metalBlock = new TMetalBlock(PHConstruct.metalBlock, Material.iron, 10.0F).setUnlocalizedName("tconstruct.metalblock"); + metalBlock.stepSound = Block.soundMetalFootstep; + GameRegistry.registerBlock(metalBlock, MetalItemBlock.class, "MetalBlock"); + + //Smeltery + smeltery = new SmelteryBlock(PHConstruct.smeltery).setUnlocalizedName("Smeltery"); + GameRegistry.registerBlock(smeltery, SmelteryItemBlock.class, "Smeltery"); + GameRegistry.registerTileEntity(SmelteryLogic.class, "TConstruct.Smeltery"); + GameRegistry.registerTileEntity(SmelteryDrainLogic.class, "TConstruct.SmelteryDrain"); + GameRegistry.registerTileEntity(MultiServantLogic.class, "TConstruct.Servants"); + + lavaTank = new LavaTankBlock(PHConstruct.lavaTank).setUnlocalizedName("LavaTank"); + lavaTank.setStepSound(Block.soundGlassFootstep); + GameRegistry.registerBlock(lavaTank, LavaTankItemBlock.class, "LavaTank"); + GameRegistry.registerTileEntity(LavaTankLogic.class, "TConstruct.LavaTank"); + + searedBlock = new SearedBlock(PHConstruct.searedTable).setUnlocalizedName("SearedBlock"); + GameRegistry.registerBlock(searedBlock, SearedTableItemBlock.class, "SearedBlock"); + GameRegistry.registerTileEntity(CastingTableLogic.class, "CastingTable"); + GameRegistry.registerTileEntity(FaucetLogic.class, "Faucet"); + GameRegistry.registerTileEntity(CastingBasinLogic.class, "CastingBasin"); + + //Redstone machines + redstoneMachine = new RedstoneMachine(PHConstruct.redstoneMachine).setUnlocalizedName("Redstone.Machine"); + GameRegistry.registerBlock(redstoneMachine, RedstoneMachineItem.class, "Redstone.Machine"); + GameRegistry.registerTileEntity(DrawbridgeLogic.class, "Drawbridge"); + GameRegistry.registerTileEntity(FirestarterLogic.class, "Firestarter"); + + dryingRack = new DryingRack(PHConstruct.dryingRack).setUnlocalizedName("Armor.DryingRack"); + GameRegistry.registerBlock(dryingRack, "Armor.DryingRack"); + GameRegistry.registerTileEntity(DryingRackLogic.class, "Armor.DryingRack"); + + //Traps + /*landmine = new Landmine(PHConstruct.landmine, 0, EnumMobType.mobs, Material.cactus).setUnlocalizedName("landmine"); + GameRegistry.registerBlock(landmine, "landmine");*/ + + //Liquids + liquidMetal = new MaterialLiquid(MapColor.tntColor); + + System.out.println("Engaging liquid metals!"); + + moltenIronFluid = new Fluid("Molten Iron"); + moltenIron = new LiquidMetalFinite(PHConstruct.moltenIron, moltenIronFluid, "liquid_iron").setUnlocalizedName("metal.molten.iron"); + moltenIronFluid.setBlockID(moltenIron).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[0] = moltenIronFluid; + fluidBlocks[0] = moltenIron; + FluidRegistry.registerFluid(moltenIronFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenIronFluid, 1), new ItemStack(buckets, 1, 0), new ItemStack(Item.bucketEmpty))); + + moltenGoldFluid = new Fluid("Molten Gold"); + moltenGold = new LiquidMetalFinite(PHConstruct.moltenGold, moltenGoldFluid, "liquid_gold").setUnlocalizedName("metal.molten.gold"); + moltenGoldFluid.setBlockID(moltenGold).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[1] = moltenGoldFluid; + fluidBlocks[1] = moltenGold; + FluidRegistry.registerFluid(moltenGoldFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenGoldFluid, 1), new ItemStack(buckets, 1, 1), new ItemStack(Item.bucketEmpty))); + + moltenCopperFluid = new Fluid("Molten Copper"); + moltenCopper = new LiquidMetalFinite(PHConstruct.moltenCopper, moltenCopperFluid, "liquid_copper").setUnlocalizedName("metal.molten.copper"); + moltenCopperFluid.setBlockID(moltenCopper).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[2] = moltenCopperFluid; + fluidBlocks[2] = moltenCopper; + FluidRegistry.registerFluid(moltenCopperFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenCopperFluid, 1), new ItemStack(buckets, 1, 2), new ItemStack(Item.bucketEmpty))); + + moltenTinFluid = new Fluid("Molten Tin"); + moltenTin = new LiquidMetalFinite(PHConstruct.moltenTin, moltenTinFluid, "liquid_tin").setUnlocalizedName("metal.molten.tin"); + moltenTinFluid.setBlockID(moltenTin).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[3] = moltenTinFluid; + fluidBlocks[3] = moltenTin; + FluidRegistry.registerFluid(moltenTinFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenTinFluid, 1), new ItemStack(buckets, 1, 3), new ItemStack(Item.bucketEmpty))); + + moltenAluminumFluid = new Fluid("Molten Aluminum"); + moltenAluminum = new LiquidMetalFinite(PHConstruct.moltenAluminum, moltenAluminumFluid, "liquid_aluminum").setUnlocalizedName("metal.molten.aluminum"); + moltenAluminumFluid.setBlockID(moltenAluminum).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[4] = moltenAluminumFluid; + fluidBlocks[4] = moltenAluminum; + FluidRegistry.registerFluid(moltenAluminumFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenAluminumFluid, 1), new ItemStack(buckets, 1, 4), new ItemStack(Item.bucketEmpty))); + + moltenCobaltFluid = new Fluid("Molten Cobalt"); + moltenCobalt = new LiquidMetalFinite(PHConstruct.moltenCobalt, moltenCobaltFluid, "liquid_cobalt").setUnlocalizedName("metal.molten.cobalt"); + moltenCobaltFluid.setBlockID(moltenCobalt).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[5] = moltenCobaltFluid; + fluidBlocks[5] = moltenCobalt; + FluidRegistry.registerFluid(moltenCobaltFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenCobaltFluid, 1), new ItemStack(buckets, 1, 5), new ItemStack(Item.bucketEmpty))); + + moltenArditeFluid = new Fluid("Molten Ardite"); + moltenArdite = new LiquidMetalFinite(PHConstruct.moltenArdite, moltenArditeFluid, "liquid_ardite").setUnlocalizedName("metal.molten.ardite"); + moltenArditeFluid.setBlockID(moltenArdite).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[6] = moltenArditeFluid; + fluidBlocks[6] = moltenArdite; + FluidRegistry.registerFluid(moltenArditeFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenArditeFluid, 1), new ItemStack(buckets, 1, 6), new ItemStack(Item.bucketEmpty))); + + moltenBronzeFluid = new Fluid("Molten Bronze"); + moltenBronze = new LiquidMetalFinite(PHConstruct.moltenBronze, moltenBronzeFluid, "liquid_bronze").setUnlocalizedName("metal.molten.bronze"); + moltenBronzeFluid.setBlockID(moltenBronze).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[7] = moltenBronzeFluid; + fluidBlocks[7] = moltenBronze; + FluidRegistry.registerFluid(moltenBronzeFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenBronzeFluid, 1), new ItemStack(buckets, 1, 7), new ItemStack(Item.bucketEmpty))); + + moltenAlubrassFluid = new Fluid("Molten Aluminum Brass"); + moltenAlubrass = new LiquidMetalFinite(PHConstruct.moltenAlubrass, moltenAlubrassFluid, "liquid_alubrass").setUnlocalizedName("metal.molten.alubrass"); + moltenAlubrassFluid.setBlockID(moltenAlubrass).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[8] = moltenAlubrassFluid; + fluidBlocks[8] = moltenAlubrass; + FluidRegistry.registerFluid(moltenAlubrassFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenAlubrassFluid, 1), new ItemStack(buckets, 1, 8), new ItemStack(Item.bucketEmpty))); + + moltenManyullynFluid = new Fluid("Molten Manyullyn"); + moltenManyullyn = new LiquidMetalFinite(PHConstruct.moltenManyullyn, moltenManyullynFluid, "liquid_manyullyn").setUnlocalizedName("metal.molten.manyullyn"); + moltenManyullynFluid.setBlockID(moltenManyullyn).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[9] = moltenManyullynFluid; + fluidBlocks[9] = moltenManyullyn; + FluidRegistry.registerFluid(moltenManyullynFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenManyullynFluid, 1), new ItemStack(buckets, 1, 9), new ItemStack(Item.bucketEmpty))); + + moltenAlumiteFluid = new Fluid("Molten Alumite"); + moltenAlumite = new LiquidMetalFinite(PHConstruct.moltenAlumite, moltenAlumiteFluid, "liquid_alumite").setUnlocalizedName("metal.molten.alumite"); + moltenAlumiteFluid.setBlockID(moltenAlumite).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[10] = moltenAlumiteFluid; + fluidBlocks[10] = moltenAlumite; + FluidRegistry.registerFluid(moltenAlumiteFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenAlumiteFluid, 1), new ItemStack(buckets, 1, 10), new ItemStack(Item.bucketEmpty))); + + moltenObsidianFluid = new Fluid("Molten Obsidian"); + moltenObsidian = new LiquidMetalFinite(PHConstruct.moltenObsidian, moltenObsidianFluid, "liquid_obsidian").setUnlocalizedName("metal.molten.obsidian"); + moltenObsidianFluid.setBlockID(moltenObsidian).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[11] = moltenObsidianFluid; + fluidBlocks[11] = moltenObsidian; + FluidRegistry.registerFluid(moltenObsidianFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenObsidianFluid, 1), new ItemStack(buckets, 1, 11), new ItemStack(Item.bucketEmpty))); + + moltenSteelFluid = new Fluid("Molten Steel"); + moltenSteel = new LiquidMetalFinite(PHConstruct.moltenSteel, moltenSteelFluid, "liquid_steel").setUnlocalizedName("metal.molten.steel"); + moltenSteelFluid.setBlockID(moltenSteel).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[12] = moltenSteelFluid; + fluidBlocks[12] = moltenSteel; + FluidRegistry.registerFluid(moltenSteelFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenSteelFluid, 1), new ItemStack(buckets, 1, 12), new ItemStack(Item.bucketEmpty))); + + moltenGlassFluid = new Fluid("Molten Glass"); + moltenGlass = new LiquidMetalFinite(PHConstruct.moltenGlass, moltenGlassFluid, "liquid_glass").setUnlocalizedName("metal.molten.glass"); + moltenGlassFluid.setBlockID(moltenGlass).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[13] = moltenGlassFluid; + fluidBlocks[13] = moltenGlass; + FluidRegistry.registerFluid(moltenGlassFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenGlassFluid, 1), new ItemStack(buckets, 1, 13), new ItemStack(Item.bucketEmpty))); + + moltenStoneFluid = new Fluid("Seared Stone"); + moltenStone = new LiquidMetalFinite(PHConstruct.moltenStone, moltenStoneFluid, "liquid_stone").setUnlocalizedName("molten.stone"); + moltenStoneFluid.setBlockID(moltenStone).setLuminosity(12).setDensity(3000).setViscosity(6000); + fluids[14] = moltenStoneFluid; + fluidBlocks[14] = moltenStone; + FluidRegistry.registerFluid(moltenStoneFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenStoneFluid, 1), new ItemStack(buckets, 1, 14), new ItemStack(Item.bucketEmpty))); + + moltenEmeraldFluid = new Fluid("Molten Emerald"); + moltenEmerald = new LiquidMetalFinite(PHConstruct.moltenEmerald, moltenEmeraldFluid, "liquid_villager").setUnlocalizedName("molten.emerald"); + moltenEmeraldFluid.setBlockID(moltenEmerald).setDensity(3000).setViscosity(6000); + fluids[15] = moltenEmeraldFluid; + fluidBlocks[15] = moltenEmerald; + FluidRegistry.registerFluid(moltenEmeraldFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenEmeraldFluid, 1), new ItemStack(buckets, 1, 15), new ItemStack(Item.bucketEmpty))); + + bloodFluid = new Fluid("Blood"); + blood = new LiquidMetalFinite(PHConstruct.blood, bloodFluid, "liquid_cow").setUnlocalizedName("liquid.blood"); + bloodFluid.setBlockID(blood).setDensity(3000).setViscosity(6000); + fluids[16] = bloodFluid; + fluidBlocks[16] = blood; + FluidRegistry.registerFluid(bloodFluid); + FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(bloodFluid, 1), new ItemStack(buckets, 1, 16), new ItemStack(Item.bucketEmpty))); + + moltenNickelFluid = new Fluid("Molten Nickel"); + moltenNickel = new LiquidMetalFinite(PHConstruct.moltenNickel, moltenNickelFluid, "liquid_ferrous").setUnlocalizedName("metal.molten.nickel"); + moltenNickelFluid.setBlockID(moltenNickel).setDensity(3000).setViscosity(6000); + fluids[17] = moltenNickelFluid; + fluidBlocks[17] = moltenNickel; + FluidRegistry.registerFluid(moltenNickelFluid); + //FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenNickelFluid, 1), new ItemStack(buckets, 1, 17), new ItemStack(Item.bucketEmpty))); + + moltenLeadFluid = new Fluid("Molten Lead"); + moltenLead = new LiquidMetalFinite(PHConstruct.moltenLead, moltenLeadFluid, "liquid_lead").setUnlocalizedName("metal.molten.lead"); + moltenLeadFluid.setBlockID(moltenLead).setDensity(3000).setViscosity(6000); + fluids[18] = moltenLeadFluid; + fluidBlocks[18] = moltenLead; + FluidRegistry.registerFluid(moltenLeadFluid); + //FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenLeadFluid, 1), new ItemStack(buckets, 1, 18), new ItemStack(Item.bucketEmpty))); + + moltenSilverFluid = new Fluid("Molten Silver"); + moltenSilver = new LiquidMetalFinite(PHConstruct.moltenSilver, moltenSilverFluid, "liquid_silver").setUnlocalizedName("metal.molten.silver"); + moltenSilverFluid.setBlockID(moltenSilver).setDensity(3000).setViscosity(6000); + fluids[19] = moltenSilverFluid; + fluidBlocks[19] = moltenSilver; + FluidRegistry.registerFluid(moltenSilverFluid); + //FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenSilverFluid, 1), new ItemStack(buckets, 1, 19), new ItemStack(Item.bucketEmpty))); + + moltenShinyFluid = new Fluid("Molten Platinum"); + moltenShiny = new LiquidMetalFinite(PHConstruct.moltenShiny, moltenShinyFluid, "liquid_shiny").setUnlocalizedName("metal.molten.shiny"); + moltenShinyFluid.setBlockID(moltenShiny).setDensity(3000).setViscosity(6000); + fluids[20] = moltenLeadFluid; + fluidBlocks[20] = moltenShiny; + FluidRegistry.registerFluid(moltenShinyFluid); + //FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenShinyFluid, 1), new ItemStack(buckets, 1, 20), new ItemStack(Item.bucketEmpty))); + + moltenInvarFluid = new Fluid("Molten Invar"); + moltenInvar = new LiquidMetalFinite(PHConstruct.moltenInvar, moltenInvarFluid, "liquid_invar").setUnlocalizedName("metal.molten.invar"); + moltenInvarFluid.setBlockID(moltenInvar).setDensity(3000).setViscosity(6000); + fluids[21] = moltenInvarFluid; + fluidBlocks[21] = moltenInvar; + FluidRegistry.registerFluid(moltenInvarFluid); + //FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenInvarFluid, 1), new ItemStack(buckets, 1, 21), new ItemStack(Item.bucketEmpty))); + + moltenElectrumFluid = new Fluid("Molten Electrum"); + moltenElectrum = new LiquidMetalFinite(PHConstruct.moltenElectrum, moltenElectrumFluid, "liquid_electrum").setUnlocalizedName("metal.molten.electrum"); + moltenElectrumFluid.setBlockID(moltenElectrum).setDensity(3000).setViscosity(6000); + fluids[22] = moltenElectrumFluid; + fluidBlocks[22] = moltenElectrum; + FluidRegistry.registerFluid(moltenElectrumFluid); + //FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(moltenElectrumFluid, 1), new ItemStack(buckets, 1, 22), new ItemStack(Item.bucketEmpty))); + + //Decoration + stoneTorch = new StoneTorch(PHConstruct.stoneTorch).setUnlocalizedName("decoration.stonetorch"); + GameRegistry.registerBlock(stoneTorch, "decoration.stonetorch"); + + multiBrick = new MultiBrick(PHConstruct.multiBrick).setUnlocalizedName("Decoration.Brick"); + GameRegistry.registerBlock(multiBrick, MultiBrickItem.class, "decoration.multibrick"); + multiBrickFancy = new MultiBrickFancy(PHConstruct.multiBrickFancy).setUnlocalizedName("Decoration.BrickFancy"); + GameRegistry.registerBlock(multiBrickFancy, MultiBrickFancyItem.class, "decoration.multibrickfancy"); + + //Ores + String[] berryOres = new String[] { "berry_iron", "berry_gold", "berry_copper", "berry_tin", "berry_iron_ripe", "berry_gold_ripe", "berry_copper_ripe", "berry_tin_ripe" }; + oreBerry = (OreberryBush) new OreberryBush(PHConstruct.oreBerry, berryOres, 0, 4, new String[] { "oreIron", "oreGold", "oreCopper", "oreTin" }).setUnlocalizedName("ore.berries.one"); + GameRegistry.registerBlock(oreBerry, OreberryBushItem.class, "ore.berries.one"); + String[] berryOresTwo = new String[] { "berry_aluminum", "berry_essence", "", "", "berry_aluminum_ripe", "berry_essence_ripe", "", "" }; + oreBerrySecond = (OreberryBush) new OreberryBushEssence(PHConstruct.oreBerrySecond, berryOresTwo, 4, 2, new String[] { "oreAluminum", "oreSilver" }).setUnlocalizedName("ore.berries.two"); + GameRegistry.registerBlock(oreBerrySecond, OreberryBushSecondItem.class, "ore.berries.two"); + + String[] oreTypes = new String[] { "nether_slag", "nether_cobalt", "nether_ardite", "ore_copper", "ore_tin", "ore_aluminum", "ore_slag" }; + oreSlag = new MetalOre(PHConstruct.oreSlag, Material.iron, 10.0F, oreTypes).setUnlocalizedName("tconstruct.stoneore"); + GameRegistry.registerBlock(oreSlag, MetalOreItemBlock.class, "SearedBrick"); + MinecraftForge.setBlockHarvestLevel(oreSlag, 1, "pickaxe", 4); + MinecraftForge.setBlockHarvestLevel(oreSlag, 2, "pickaxe", 4); + MinecraftForge.setBlockHarvestLevel(oreSlag, 3, "pickaxe", 1); + MinecraftForge.setBlockHarvestLevel(oreSlag, 4, "pickaxe", 1); + MinecraftForge.setBlockHarvestLevel(oreSlag, 5, "pickaxe", 1); + + oreGravel = new GravelOre(PHConstruct.oreGravel).setUnlocalizedName("GravelOre").setUnlocalizedName("tconstruct.gravelore"); + GameRegistry.registerBlock(oreGravel, GravelOreItem.class, "GravelOre"); + + MinecraftForge.setBlockHarvestLevel(oreGravel, 0, "shovel", 1); + MinecraftForge.setBlockHarvestLevel(oreGravel, 1, "shovel", 2); + MinecraftForge.setBlockHarvestLevel(oreGravel, 2, "shovel", 1); + MinecraftForge.setBlockHarvestLevel(oreGravel, 3, "shovel", 1); + MinecraftForge.setBlockHarvestLevel(oreGravel, 4, "shovel", 1); + MinecraftForge.setBlockHarvestLevel(oreGravel, 5, "shovel", 4); + + speedBlock = new SpeedBlock(PHConstruct.speedBlock).setUnlocalizedName("SpeedBlock"); + GameRegistry.registerBlock(speedBlock, SpeedBlockItem.class, "SpeedBlock"); + + //Glass + glass = new GlassBlockConnected(PHConstruct.glass, "clear", false).setUnlocalizedName("GlassBlock"); + glass.stepSound = Block.soundGlassFootstep; + GameRegistry.registerBlock(glass, GlassBlockItem.class, "GlassBlock"); + + glassPane = new GlassPane(PHConstruct.glassPane); + GameRegistry.registerBlock(glassPane, GlassPaneItem.class, "GlassPane"); + + stainedGlassClear = new GlassBlockConnectedMeta(PHConstruct.stainedGlassClear, "stained", true, "white", "orange", "magenta", "light_blue", "yellow", "lime", "pink", "gray", "light_gray", "cyan", "purple", + "blue", "brown", "green", "red", "black").setUnlocalizedName("GlassBlock.StainedClear");//new GlassBlockStained(PHConstruct.stainedGlassClear, "stainedglass_").setUnlocalizedName("GlassBlock.StainedClear"); + stainedGlassClear.stepSound = Block.soundGlassFootstep; + GameRegistry.registerBlock(stainedGlassClear, StainedGlassClearItem.class, "GlassBlock.StainedClear"); + + stainedGlassClearPane = new GlassPaneStained(PHConstruct.stainedGlassClearPane); + GameRegistry.registerBlock(stainedGlassClearPane, StainedGlassClearPaneItem.class, "GlassPaneClearStained"); + + /*public static Block stainedGlass; + public static Block stainedGlassClear;*/ + + aggregator = new Aggregator(PHConstruct.aggregator).setUnlocalizedName("Aggregator"); + aggregator.stepSound = Block.soundMetalFootstep; + GameRegistry.registerBlock(aggregator, "Aggregator"); + GameRegistry.registerTileEntity(GlowstoneAggregator.class, "GlowstoneAggregator"); + + lightCrystalBase = new LightCrystalBase(PHConstruct.lightCrystalBase).setUnlocalizedName("LightCrystalBase"); + lightCrystalBase.stepSound = Block.soundGlassFootstep; + GameRegistry.registerBlock(lightCrystalBase, LightCrystalItem.class, "LightCrystalBase"); + + /*redstoneBallRepeater = new RedstoneBallRepeater(PHConstruct.redstoneBallRepeater, false).setUnlocalizedName("decoration.redstoneballrepeater"); + GameRegistry.registerBlock(redstoneBallRepeater, "decoration.redstoneballrepeater"); + Item.itemsList[PHConstruct.redstoneBallRepeater] = null; + redstoneBallRepeaterItem = new RedstoneBallRepeaterItem(PHConstruct.redstoneBallRepeater-256).setUnlocalizedName("decoration.redstoneballrepeater");*/ + + //Golems + /*golemCore = new GolemCoreBlock(PHConstruct.golemCore).setUnlocalizedName("golemcore"); + GameRegistry.registerBlock(golemCore, "Golem Core"); + GameRegistry.registerTileEntity(GolemCoreLogic.class, "TConstruct.GolemCore"); + + golemHead = new GolemHeadBlock(PHConstruct.golemHead).setUnlocalizedName("golemhead"); + GameRegistry.registerBlock(golemHead, "Golem Head");*/ + + /*golemPedestal = new GolemPedestalBlock(PHConstruct.golemPedestal).setUnlocalizedName("golempedestal"); + GameRegistry.registerBlock(golemPedestal, "Golem Pedestal"); + GameRegistry.registerTileEntity(GolemPedestalLogic.class, "TConstruct.GolemPedestal");*/ + + //Traps + /*landmine = new Landmine(PHConstruct.landmine, EnumMobType.mobs, Material.wood).setUnlocalizedName("tconstruct.landmine"); + GameRegistry.registerBlock(landmine, "Landmine"); + barricade = new BarricadeBlock(PHConstruct.barricade).setUnlocalizedName("tconstruct.barricade"); + GameRegistry.registerBlock(barricade, "Barricade");*/ + } + + void registerItems () + { + titleIcon = new TitleIcon(PHConstruct.uselessItem).setUnlocalizedName("tconstruct.titleicon"); + String[] blanks = new String[] { "blank_pattern", "blank_cast", "blank_cast" }; + blankPattern = new CraftingItem(PHConstruct.blankPattern, blanks, blanks, "materials/").setUnlocalizedName("tconstruct.Pattern"); + + materials = new MaterialItem(PHConstruct.materials).setUnlocalizedName("tconstruct.Materials"); + toolRod = new ToolPart(PHConstruct.toolRod, "_rod").setUnlocalizedName("tconstruct.ToolRod"); + toolShard = new ToolShard(PHConstruct.toolShard, "_chunk").setUnlocalizedName("tconstruct.ToolShard"); + woodPattern = new Pattern(PHConstruct.woodPattern, "WoodPattern", "pattern_", "materials/").setUnlocalizedName("tconstruct.Pattern"); + metalPattern = new MetalPattern(PHConstruct.metalPattern, "MetalPattern", "cast_", "materials/").setUnlocalizedName("tconstruct.MetalPattern"); + //netherPattern = new Pattern(PHTools.netherPattern, 128, patternTexture).setUnlocalizedName("tconstruct.Pattern"); + + TConstructRegistry.addItemToDirectory("blankPattern", blankPattern); + TConstructRegistry.addItemToDirectory("woodPattern", woodPattern); + TConstructRegistry.addItemToDirectory("metalPattern", metalPattern); + + String[] patternTypes = { "ingot", "toolRod", "pickaxeHead", "shovelHead", "hatchetHead", "swordBlade", "wideGuard", "handGuard", "crossbar", "binding", "frypanHead", "signHead", + "knifeBlade", "chiselHead", "toughRod", "toughBinding", "largePlate", "broadAxeHead", "scytheHead", "excavatorHead", "largeBlade", "hammerHead", "fullGuard" }; + + for (int i = 1; i < patternTypes.length; i++) + { + TConstructRegistry.addItemStackToDirectory(patternTypes[i] + "Pattern", new ItemStack(woodPattern, 1, i)); + } + for (int i = 0; i < patternTypes.length; i++) + { + TConstructRegistry.addItemStackToDirectory(patternTypes[i] + "Cast", new ItemStack(metalPattern, 1, i)); + } + + manualBook = new Manual(PHConstruct.manual); + buckets = new FilledBucket(PHConstruct.buckets); + + pickaxe = new Pickaxe(PHConstruct.pickaxe); + shovel = new Shovel(PHConstruct.shovel); + hatchet = new Hatchet(PHConstruct.axe); + broadsword = new Broadsword(PHConstruct.broadsword); + longsword = new Longsword(PHConstruct.longsword); + rapier = new Rapier(PHConstruct.rapier); + dagger = new Dagger(PHConstruct.dagger); + cutlass = new Cutlass(PHConstruct.cutlass); + + frypan = new FryingPan(PHConstruct.frypan); + battlesign = new BattleSign(PHConstruct.battlesign); + mattock = new Mattock(PHConstruct.mattock); + chisel = new Chisel(PHConstruct.chisel); + + lumberaxe = new LumberAxe(PHConstruct.lumberaxe); + cleaver = new Cleaver(PHConstruct.cleaver); + scythe = new Scythe(PHConstruct.scythe); + excavator = new Excavator(PHConstruct.excavator); + hammer = new Hammer(PHConstruct.hammer); + battleaxe = new Battleaxe(PHConstruct.battleaxe); + + shortbow = new Shortbow(PHConstruct.shortbow); + arrow = new Arrow(PHConstruct.arrow); + + Item[] tools = { pickaxe, shovel, hatchet, broadsword, longsword, rapier, cutlass, frypan, battlesign, mattock, chisel, lumberaxe, cleaver, scythe, excavator, hammer, battleaxe }; + String[] toolStrings = { "pickaxe", "shovel", "hatchet", "broadsword", "longsword", "rapier", "cutlass", "frypan", "battlesign", "mattock", "chisel", "lumberaxe", "cleaver", "scythe", + "excavator", "hammer", "battleaxe" }; + + for (int i = 0; i < tools.length; i++) + { + TConstructRegistry.addItemToDirectory(toolStrings[i], tools[i]); + } + + potionLauncher = new PotionLauncher(PHConstruct.potionLauncher).setUnlocalizedName("tconstruct.PotionLauncher"); + + pickaxeHead = new ToolPart(PHConstruct.pickaxeHead, "_pickaxe_head").setUnlocalizedName("tconstruct.PickaxeHead"); + shovelHead = new ToolPart(PHConstruct.shovelHead, "_shovel_head").setUnlocalizedName("tconstruct.ShovelHead"); + hatchetHead = new ToolPart(PHConstruct.axeHead, "_axe_head").setUnlocalizedName("tconstruct.AxeHead"); + binding = new ToolPart(PHConstruct.binding, "_binding").setUnlocalizedName("tconstruct.Binding"); + toughBinding = new ToolPart(PHConstruct.toughBinding, "_toughbind").setUnlocalizedName("tconstruct.ThickBinding"); + toughRod = new ToolPart(PHConstruct.toughRod, "_toughrod").setUnlocalizedName("tconstruct.ThickRod"); + heavyPlate = new ToolPart(PHConstruct.largePlate, "_largeplate").setUnlocalizedName("tconstruct.LargePlate"); + + swordBlade = new ToolPart(PHConstruct.swordBlade, "_sword_blade").setUnlocalizedName("tconstruct.SwordBlade"); + wideGuard = new ToolPart(PHConstruct.largeGuard, "_large_guard").setUnlocalizedName("tconstruct.LargeGuard"); + handGuard = new ToolPart(PHConstruct.medGuard, "_medium_guard").setUnlocalizedName("tconstruct.MediumGuard"); + crossbar = new ToolPart(PHConstruct.crossbar, "_crossbar").setUnlocalizedName("tconstruct.Crossbar"); + knifeBlade = new ToolPart(PHConstruct.knifeBlade, "_knife_blade").setUnlocalizedName("tconstruct.KnifeBlade"); + fullGuard = new ToolPartHidden(PHConstruct.fullGuard, "_full_guard").setUnlocalizedName("tconstruct.FullGuard"); + + frypanHead = new ToolPart(PHConstruct.frypanHead, "_frypan_head").setUnlocalizedName("tconstruct.FrypanHead"); + signHead = new ToolPart(PHConstruct.signHead, "_battlesign_head").setUnlocalizedName("tconstruct.SignHead"); + chiselHead = new ToolPart(PHConstruct.chiselHead, "_chisel_head").setUnlocalizedName("tconstruct.ChiselHead"); + + scytheBlade = new ToolPart(PHConstruct.scytheBlade, "_scythe_head").setUnlocalizedName("tconstruct.ScytheBlade"); + broadAxeHead = new ToolPart(PHConstruct.lumberHead, "_lumberaxe_head").setUnlocalizedName("tconstruct.LumberHead"); + excavatorHead = new ToolPart(PHConstruct.excavatorHead, "_excavator_head").setUnlocalizedName("tconstruct.ExcavatorHead"); + largeSwordBlade = new ToolPart(PHConstruct.largeSwordBlade, "_large_sword_blade").setUnlocalizedName("tconstruct.LargeSwordBlade"); + hammerHead = new ToolPart(PHConstruct.hammerHead, "_hammer_head").setUnlocalizedName("tconstruct.HammerHead"); + + bowstring = new Bowstring(PHConstruct.bowstring).setUnlocalizedName("tconstruct.Bowstring"); + arrowhead = new ToolPart(PHConstruct.arrowhead, "_arrowhead").setUnlocalizedName("tconstruct.Arrowhead"); + fletching = new Fletching(PHConstruct.fletching).setUnlocalizedName("tconstruct.Fletching"); + + Item[] toolParts = { toolRod, toolShard, pickaxeHead, shovelHead, hatchetHead, binding, toughBinding, toughRod, heavyPlate, swordBlade, wideGuard, handGuard, crossbar, knifeBlade, fullGuard, + frypanHead, signHead, chiselHead, scytheBlade, broadAxeHead, excavatorHead, largeSwordBlade, hammerHead, bowstring, fletching, arrowhead }; + String[] toolPartStrings = { "toolRod", "toolShard", "pickaxeHead", "shovelHead", "hatchetHead", "binding", "toughBinding", "toughRod", "heavyPlate", "swordBlade", "wideGuard", "handGuard", + "crossbar", "knifeBlade", "fullGuard", "frypanHead", "signHead", "chiselHead", "scytheBlade", "broadAxeHead", "excavatorHead", "largeSwordBlade", "hammerHead", "bowstring", + "fletching", "arrowhead" }; + + for (int i = 0; i < toolParts.length; i++) + { + TConstructRegistry.addItemToDirectory(toolPartStrings[i], toolParts[i]); + } + + diamondApple = new DiamondApple(PHConstruct.diamondApple).setUnlocalizedName("tconstruct.apple.diamond"); + strangeFood = new StrangeFood(PHConstruct.slimefood).setUnlocalizedName("tconstruct.strangefood"); + oreBerries = new OreBerries(PHConstruct.oreChunks).setUnlocalizedName("oreberry"); + + //Wearables + //heavyHelmet = new TArmorBase(PHConstruct.heavyHelmet, 0).setUnlocalizedName("tconstruct.HeavyHelmet"); + heartCanister = new HeartCanister(PHConstruct.heartCanister).setUnlocalizedName("tconstruct.canister"); + heavyBoots = new TArmorBase(PHConstruct.heavyBoots, 3).setUnlocalizedName("tconstruct.HeavyBoots"); + glove = new Glove(PHConstruct.glove).setUnlocalizedName("tconstruct.Glove"); + knapsack = new Knapsack(PHConstruct.knapsack).setUnlocalizedName("tconstruct.storage"); + /*public static Item heavyHelmet; + public static Item heavyChestplate; + public static Item heavyPants; + public static Item heavyBoots;*/ + + goldHead = new GoldenHead(PHConstruct.goldHead, 4, 1.2F, false).setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 10, 0, 1.0F).setUnlocalizedName("goldenhead"); + + String[] materialStrings = { "paperStack", "greenSlimeCrystal", "searedBrick", "ingotCobalt", "ingotArdite", "ingotManyullyn", "mossBall", "lavaCrystal", "necroticBone", "ingotCopper", + "ingotTin", "ingotAluminum", "rawAluminum", "ingotBronze", "ingotAluminumBrass", "ingotAlumite", "ingotSteel", "blueSlimeCrystal", "ingotObsidian", "nuggetIron", "nuggetCopper", + "nuggetTin", "nuggetAluminum", "nuggetSilver", "nuggetAluminumBrass", "silkyCloth", "silkyJewel", "nuggetObsidian", "nuggetCobalt", "nuggetArdite", "nuggetManyullyn", "nuggetBronze", + "nuggetAlumite", "nuggetSteel" }; + + for (int i = 0; i < materialStrings.length; i++) + { + TConstructRegistry.addItemStackToDirectory(materialStrings[i], new ItemStack(materials, 1, i)); + } + + String[] oreberries = { "Iron", "Gold", "Copper", "Tin", "Aluminum", "Essence" }; + + for (int i = 0; i < oreberries.length; i++) + { + TConstructRegistry.addItemStackToDirectory("oreberry" + oreberries[i], new ItemStack(oreBerries, 1, i)); + } + + TConstructRegistry.addItemStackToDirectory("diamondApple", new ItemStack(diamondApple, 1, 0)); + TConstructRegistry.addItemStackToDirectory("blueSlimeFood", new ItemStack(strangeFood, 1, 0)); + + TConstructRegistry.addItemStackToDirectory("canisterEmpty", new ItemStack(heartCanister, 1, 0)); + TConstructRegistry.addItemStackToDirectory("miniRedHeart", new ItemStack(heartCanister, 1, 1)); + TConstructRegistry.addItemStackToDirectory("canisterRedHeart", new ItemStack(heartCanister, 1, 2)); + + //Vanilla stack sizes + Item.doorWood.setMaxStackSize(16); + Item.doorIron.setMaxStackSize(16); + Item.snowball.setMaxStackSize(64); + Item.boat.setMaxStackSize(16); + Item.minecartEmpty.setMaxStackSize(3); + Item.minecartCrate.setMaxStackSize(3); + Item.minecartPowered.setMaxStackSize(3); + //Block.torchWood.setTickRandomly(false); + } + + void registerMaterials () + { + TConstructRegistry.addToolMaterial(0, "Wood", "Wooden ", 0, 59, 200, 0, 1.0F, 0, 0f, "\u00A7e", ""); + TConstructRegistry.addToolMaterial(1, "Stone", 1, 131, 400, 1, 0.5F, 0, 1f, "", "Stonebound"); + TConstructRegistry.addToolMaterial(2, "Iron", 2, 250, 600, 2, 1.3F, 1, 0f, "\u00A7f", ""); + TConstructRegistry.addToolMaterial(3, "Flint", 1, 171, 525, 2, 0.7F, 0, 0f, "\u00A78", ""); + TConstructRegistry.addToolMaterial(4, "Cactus", 1, 150, 500, 2, 1.0F, 0, -1f, "\u00A72", "Jagged"); + TConstructRegistry.addToolMaterial(5, "Bone", 1, 200, 400, 1, 1.0F, 0, 0f, "\u00A7e", ""); + TConstructRegistry.addToolMaterial(6, "Obsidian", 3, 89, 700, 2, 0.8F, 3, 0f, "\u00A7d", ""); + TConstructRegistry.addToolMaterial(7, "Netherrack", 2, 131, 400, 1, 1.2F, 0, 1f, "\u00A74", "Stonebound"); + TConstructRegistry.addToolMaterial(8, "Slime", 3, 1500, 150, 0, 2.0F, 0, 0f, "\u00A7a", ""); + TConstructRegistry.addToolMaterial(9, "Paper", 0, 30, 200, 0, 0.3F, 0, 0f, "\u00A7f", "Writable"); + TConstructRegistry.addToolMaterial(10, "Cobalt", 4, 800, 1100, 3, 1.75F, 2, 0f, "\u00A73", ""); + TConstructRegistry.addToolMaterial(11, "Ardite", 4, 600, 800, 3, 2.0F, 0, 2f, "\u00A74", "Stonebound"); + TConstructRegistry.addToolMaterial(12, "Manyullyn", 5, 1200, 900, 4, 2.5F, 0, 0f, "\u00A75", ""); + TConstructRegistry.addToolMaterial(13, "Copper", 1, 180, 500, 2, 1.15F, 0, 0f, "\u00A7c", ""); + TConstructRegistry.addToolMaterial(14, "Bronze", 2, 350, 700, 2, 1.3F, 1, 0f, "\u00A76", ""); + TConstructRegistry.addToolMaterial(15, "Alumite", 4, 550, 800, 3, 1.3F, 2, 0f, "\u00A7d", ""); + TConstructRegistry.addToolMaterial(16, "Steel", 4, 750, 800, 3, 1.3F, 2, 0f, "", ""); + TConstructRegistry.addToolMaterial(17, "BlueSlime", "Slime ", 1, 500, 150, 0, 1.5F, 0, 0f, "\u00A7b", ""); + + TConstructRegistry.addBowMaterial(0, 384, 20, 1.0f); //Wood + TConstructRegistry.addBowMaterial(1, 10, 80, 0.2f); //Stone + TConstructRegistry.addBowMaterial(2, 576, 40, 1.2f); //Iron + TConstructRegistry.addBowMaterial(3, 10, 80, 0.2f); //Flint + TConstructRegistry.addBowMaterial(4, 384, 20, 1.0f); //Cactus + TConstructRegistry.addBowMaterial(5, 192, 30, 1.0f); //Bone + TConstructRegistry.addBowMaterial(6, 10, 80, 0.2f); //Obsidian + TConstructRegistry.addBowMaterial(7, 10, 80, 0.2f); //Netherrack + TConstructRegistry.addBowMaterial(8, 1536, 20, 1.2f); //Slime + TConstructRegistry.addBowMaterial(9, 48, 25, 0.5f); //Paper + TConstructRegistry.addBowMaterial(10, 1152, 40, 1.2f); //Cobalt + TConstructRegistry.addBowMaterial(11, 960, 40, 1.2f); //Ardite + TConstructRegistry.addBowMaterial(12, 1536, 40, 1.2f); //Manyullyn + TConstructRegistry.addBowMaterial(13, 384, 40, 1.2f); //Copper + TConstructRegistry.addBowMaterial(14, 576, 40, 1.2f); //Bronze + TConstructRegistry.addBowMaterial(15, 768, 40, 1.2f); //Alumite + TConstructRegistry.addBowMaterial(16, 768, 40, 1.2f); //Steel + TConstructRegistry.addBowMaterial(17, 576, 20, 1.2f); //Blue Slime + + //Material ID, mass, fragility + TConstructRegistry.addArrowMaterial(0, 0.69F, 1.0F, 100F); //Wood + TConstructRegistry.addArrowMaterial(1, 2.5F, 5.0F, 100F); //Stone + TConstructRegistry.addArrowMaterial(2, 7.2F, 0.5F, 100F); //Iron + TConstructRegistry.addArrowMaterial(3, 2.65F, 1.0F, 100F); //Flint + TConstructRegistry.addArrowMaterial(4, 0.76F, 1.0F, 100F); //Cactus + TConstructRegistry.addArrowMaterial(5, 0.69F, 1.0F, 100); //Bone + TConstructRegistry.addArrowMaterial(6, 2.4F, 1.0F, 100F); //Obsidian + TConstructRegistry.addArrowMaterial(7, 3.5F, 1.0F, 100F); //Netherrack + TConstructRegistry.addArrowMaterial(8, 0.42F, 0.0F, 100F); //Slime + TConstructRegistry.addArrowMaterial(9, 1.1F, 3.0F, 90F); //Paper + TConstructRegistry.addArrowMaterial(10, 8.9F, 0.25F, 100F); //Cobalt + TConstructRegistry.addArrowMaterial(11, 7.2F, 0.25F, 100F); //Ardite + TConstructRegistry.addArrowMaterial(12, 10.6F, 0.1F, 100F); //Manyullyn + TConstructRegistry.addArrowMaterial(13, 8.96F, 0.5F, 100F); //Copper + TConstructRegistry.addArrowMaterial(14, 7.9F, 0.25F, 100F); //Bronze + TConstructRegistry.addArrowMaterial(15, 4.7F, 0.25F, 100F); //Alumite + TConstructRegistry.addArrowMaterial(16, 7.6F, 0.25F, 100F); //Steel + TConstructRegistry.addArrowMaterial(17, 0.42F, 0.0F, 100F); //Blue Slime + + TConstructRegistry.addBowstringMaterial(0, 2, new ItemStack(Item.silk), new ItemStack(bowstring, 1, 0), 1F, 1F, 1f); //String + TConstructRegistry.addFletchingMaterial(0, 2, new ItemStack(Item.feather), new ItemStack(fletching, 1, 0), 100F, 0F, 0.05F); //Feather + TConstructRegistry.addFletchingMaterial(1, 2, new ItemStack(Block.leaves), new ItemStack(fletching, 1, 1), 75F, 0F, 0.2F); //Leaves + TConstructRegistry.addFletchingMaterial(2, 2, new ItemStack(materials, 1, 1), new ItemStack(fletching, 1, 2), 100F, 0F, 0.12F); //Slime + TConstructRegistry.addFletchingMaterial(3, 2, new ItemStack(materials, 1, 17), new ItemStack(fletching, 1, 3), 100F, 0F, 0.12F); //BlueSlime + + PatternBuilder pb = PatternBuilder.instance; + if (PHConstruct.enableTWood) + pb.registerFullMaterial(Block.planks, 2, "Wood", new ItemStack(Item.stick), new ItemStack(Item.stick), 0); + else + pb.registerMaterialSet("Wood", new ItemStack(Item.stick, 2), new ItemStack(Item.stick), 0); + if (PHConstruct.enableTStone) + { + pb.registerFullMaterial(Block.stone, 2, "Stone", new ItemStack(TContent.toolShard, 1, 1), new ItemStack(TContent.toolRod, 1, 1), 1); + pb.registerMaterial(Block.cobblestone, 2, "Stone"); + } + else + pb.registerMaterialSet("Stone", new ItemStack(TContent.toolShard, 1, 1), new ItemStack(TContent.toolRod, 1, 1), 0); + pb.registerFullMaterial(Item.ingotIron, 2, "Iron", new ItemStack(TContent.toolShard, 1, 2), new ItemStack(TContent.toolRod, 1, 2), 2); + if (PHConstruct.enableTFlint) + pb.registerFullMaterial(Item.flint, 2, "Flint", new ItemStack(TContent.toolShard, 1, 3), new ItemStack(TContent.toolRod, 1, 3), 3); + else + pb.registerMaterialSet("Flint", new ItemStack(TContent.toolShard, 1, 3), new ItemStack(TContent.toolRod, 1, 3), 3); + if (PHConstruct.enableTCactus) + pb.registerFullMaterial(Block.cactus, 2, "Cactus", new ItemStack(TContent.toolShard, 1, 4), new ItemStack(TContent.toolRod, 1, 4), 4); + else + pb.registerMaterialSet("Cactus", new ItemStack(TContent.toolShard, 1, 4), new ItemStack(TContent.toolRod, 1, 4), 4); + if (PHConstruct.enableTBone) + pb.registerFullMaterial(Item.bone, 2, "Bone", new ItemStack(Item.dyePowder, 1, 15), new ItemStack(Item.bone), 5); + else + pb.registerMaterialSet("Bone", new ItemStack(Item.dyePowder, 1, 15), new ItemStack(Item.bone), 5); + pb.registerFullMaterial(Block.obsidian, 2, "Obsidian", new ItemStack(TContent.toolShard, 1, 6), new ItemStack(TContent.toolRod, 1, 6), 6); + pb.registerMaterial(new ItemStack(materials, 1, 18), 2, "Obsidian"); + if (PHConstruct.enableTNetherrack) + pb.registerFullMaterial(Block.netherrack, 2, "Netherrack", new ItemStack(TContent.toolShard, 1, 7), new ItemStack(TContent.toolRod, 1, 7), 7); + else + pb.registerMaterialSet("Netherrack", new ItemStack(TContent.toolShard, 1, 7), new ItemStack(TContent.toolRod, 1, 7), 7); + if (PHConstruct.enableTSlime) + pb.registerFullMaterial(new ItemStack(materials, 1, 1), 2, "Slime", new ItemStack(toolShard, 1, 8), new ItemStack(toolRod, 1, 8), 8); + else + pb.registerMaterialSet("Slime", new ItemStack(TContent.toolShard, 1, 8), new ItemStack(TContent.toolRod, 1, 17), 8); + if (PHConstruct.enableTPaper) + pb.registerFullMaterial(new ItemStack(materials, 1, 0), 2, "Paper", new ItemStack(Item.paper, 2), new ItemStack(toolRod, 1, 9), 9); + else + pb.registerMaterialSet("BlueSlime", new ItemStack(Item.paper, 2), new ItemStack(TContent.toolRod, 1, 9), 9); + pb.registerMaterialSet("Cobalt", new ItemStack(toolShard, 1, 10), new ItemStack(toolRod, 1, 10), 10); + pb.registerMaterialSet("Ardite", new ItemStack(toolShard, 1, 11), new ItemStack(toolRod, 1, 11), 11); + pb.registerMaterialSet("Manyullyn", new ItemStack(toolShard, 1, 12), new ItemStack(toolRod, 1, 12), 12); + pb.registerMaterialSet("Copper", new ItemStack(toolShard, 1, 13), new ItemStack(toolRod, 1, 13), 13); + pb.registerMaterialSet("Bronze", new ItemStack(toolShard, 1, 14), new ItemStack(toolRod, 1, 14), 14); + pb.registerMaterialSet("Alumite", new ItemStack(toolShard, 1, 15), new ItemStack(toolRod, 1, 15), 15); + pb.registerMaterialSet("Steel", new ItemStack(toolShard, 1, 16), new ItemStack(toolRod, 1, 16), 16); + if (PHConstruct.enableTBlueSlime) + pb.registerFullMaterial(new ItemStack(materials, 1, 17), 2, "BlueSlime", new ItemStack(toolShard, 1, 17), new ItemStack(toolRod, 1, 17), 17); + else + pb.registerMaterialSet("BlueSlime", new ItemStack(TContent.toolShard, 1, 17), new ItemStack(TContent.toolRod, 1, 17), 17); + + pb.addToolPattern((IPattern) woodPattern); + } + + public static Item[] patternOutputs; + public static FluidStack[] liquids; + + void addCraftingRecipes () + { + /* Tools */ + patternOutputs = new Item[] { toolRod, pickaxeHead, shovelHead, hatchetHead, swordBlade, wideGuard, handGuard, crossbar, binding, frypanHead, signHead, knifeBlade, chiselHead, toughRod, + toughBinding, heavyPlate, broadAxeHead, scytheBlade, excavatorHead, largeSwordBlade, hammerHead, fullGuard, null, null, arrowhead }; + + int[] nonMetals = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 17 }; + + if (PHConstruct.craftMetalTools) + { + for (int mat = 0; mat < 18; mat++) + { + for (int meta = 0; meta < patternOutputs.length; meta++) + { + if (patternOutputs[meta] != null) + TConstructRegistry.addPartMapping(woodPattern.itemID, meta + 1, mat, new ItemStack(patternOutputs[meta], 1, mat)); + } + } + } + else + { + for (int mat = 0; mat < nonMetals.length; mat++) + { + for (int meta = 0; meta < patternOutputs.length; meta++) + { + if (patternOutputs[meta] != null) + TConstructRegistry.addPartMapping(woodPattern.itemID, meta + 1, nonMetals[mat], new ItemStack(patternOutputs[meta], 1, nonMetals[mat])); + } + } + } + + ToolBuilder tb = ToolBuilder.instance; + tb.addNormalToolRecipe(pickaxe, pickaxeHead, toolRod, binding); + tb.addNormalToolRecipe(broadsword, swordBlade, toolRod, wideGuard); + tb.addNormalToolRecipe(hatchet, hatchetHead, toolRod); + tb.addNormalToolRecipe(shovel, shovelHead, toolRod); + tb.addNormalToolRecipe(longsword, swordBlade, toolRod, handGuard); + tb.addNormalToolRecipe(rapier, swordBlade, toolRod, crossbar); + tb.addNormalToolRecipe(frypan, frypanHead, toolRod); + tb.addNormalToolRecipe(battlesign, signHead, toolRod); + tb.addNormalToolRecipe(mattock, hatchetHead, toolRod, shovelHead); + tb.addNormalToolRecipe(dagger, knifeBlade, toolRod, crossbar); + tb.addNormalToolRecipe(cutlass, swordBlade, toolRod, fullGuard); + tb.addNormalToolRecipe(chisel, chiselHead, toolRod); + + tb.addNormalToolRecipe(scythe, scytheBlade, toughRod, toughBinding, toughRod); + tb.addNormalToolRecipe(lumberaxe, broadAxeHead, toughRod, heavyPlate, toughBinding); + tb.addNormalToolRecipe(cleaver, largeSwordBlade, toughRod, heavyPlate, toughRod); + tb.addNormalToolRecipe(excavator, excavatorHead, toughRod, heavyPlate, toughBinding); + tb.addNormalToolRecipe(hammer, hammerHead, toughRod, heavyPlate, heavyPlate); + tb.addNormalToolRecipe(battleaxe, broadAxeHead, toughRod, broadAxeHead, toughBinding); + + tb.addNormalToolRecipe(shortbow, toolRod, bowstring, toolRod); + tb.addNormalToolRecipe(arrow, arrowhead, toolRod, fletching); + + ItemStack diamond = new ItemStack(Item.diamond); + tb.registerToolMod(new ModRepair()); + tb.registerToolMod(new ModDurability(new ItemStack[] { diamond }, 0, 500, 0f, 3, "Diamond", "\u00a7bDurability +500", "\u00a7b")); + tb.registerToolMod(new ModDurability(new ItemStack[] { new ItemStack(Item.emerald) }, 1, 0, 0.5f, 2, "Emerald", "\u00a72Durability +50%", "\u00a72")); + + modE = new ModElectric(); + tb.registerToolMod(modE); + + ItemStack redstoneItem = new ItemStack(Item.redstone); + ItemStack redstoneBlock = new ItemStack(Block.blockRedstone); + tb.registerToolMod(new ModRedstone(new ItemStack[] { redstoneItem }, 2, 1)); + tb.registerToolMod(new ModRedstone(new ItemStack[] { redstoneItem, redstoneItem }, 2, 2)); + tb.registerToolMod(new ModRedstone(new ItemStack[] { redstoneBlock }, 2, 9)); + tb.registerToolMod(new ModRedstone(new ItemStack[] { redstoneItem, redstoneBlock }, 2, 10)); + tb.registerToolMod(new ModRedstone(new ItemStack[] { redstoneBlock, redstoneBlock }, 2, 18)); + + ItemStack lapisItem = new ItemStack(Item.dyePowder, 1, 4); + ItemStack lapisBlock = new ItemStack(Block.blockLapis); + modL = new ModLapis(new ItemStack[] { lapisItem }, 10, 1); + tb.registerToolMod(modL); + tb.registerToolMod(new ModLapis(new ItemStack[] { lapisItem, lapisItem }, 10, 2)); + tb.registerToolMod(new ModLapis(new ItemStack[] { lapisBlock }, 10, 9)); + tb.registerToolMod(new ModLapis(new ItemStack[] { lapisItem, lapisBlock }, 10, 10)); + tb.registerToolMod(new ModLapis(new ItemStack[] { lapisBlock, lapisBlock }, 10, 18)); + + tb.registerToolMod(new ModInteger(new ItemStack[] { new ItemStack(materials, 1, 6) }, 4, "Moss", 3, "\u00a72", "Auto-Repair")); + ItemStack blazePowder = new ItemStack(Item.blazePowder); + tb.registerToolMod(new ModBlaze(new ItemStack[] { blazePowder }, 7, 1)); + tb.registerToolMod(new ModBlaze(new ItemStack[] { blazePowder, blazePowder }, 7, 2)); + tb.registerToolMod(new ModAutoSmelt(new ItemStack[] { new ItemStack(materials, 1, 7) }, 6, "Lava", "\u00a74", "Auto-Smelt")); + tb.registerToolMod(new ModInteger(new ItemStack[] { new ItemStack(materials, 1, 8) }, 8, "Necrotic", 1, "\u00a78", "Life Steal")); + + ItemStack quartzItem = new ItemStack(Item.netherQuartz); + ItemStack quartzBlock = new ItemStack(Block.blockNetherQuartz, 1, Short.MAX_VALUE); + tb.registerToolMod(new ModAttack("Quartz", new ItemStack[] { quartzItem }, 11, 1)); + tb.registerToolMod(new ModAttack("Quartz", new ItemStack[] { quartzItem, quartzItem }, 11, 2)); + tb.registerToolMod(new ModAttack("Quartz", new ItemStack[] { quartzBlock }, 11, 4)); + tb.registerToolMod(new ModAttack("Quartz", new ItemStack[] { quartzItem, quartzBlock }, 11, 5)); + tb.registerToolMod(new ModAttack("Quartz", new ItemStack[] { quartzBlock, quartzBlock }, 11, 8)); + + tb.registerToolMod(new ModExtraModifier(new ItemStack[] { diamond, new ItemStack(Block.blockGold) }, "Tier1Free")); + tb.registerToolMod(new ModExtraModifier(new ItemStack[] { new ItemStack(Item.netherStar) }, "Tier2Free")); + + ItemStack silkyJewel = new ItemStack(materials, 1, 26); + tb.registerToolMod(new ModButtertouch(new ItemStack[] { silkyJewel }, 12)); + + ItemStack piston = new ItemStack(Block.pistonBase); + tb.registerToolMod(new ModPiston(new ItemStack[] { piston }, 3, 1)); + tb.registerToolMod(new ModPiston(new ItemStack[] { piston, piston }, 3, 2)); + + tb.registerToolMod(new ModInteger(new ItemStack[] { new ItemStack(Block.obsidian), new ItemStack(Item.enderPearl) }, 13, "Beheading", 1, "\u00a7d", "Beheading")); + + ItemStack holySoil = new ItemStack(craftedSoil, 1, 4); + tb.registerToolMod(new ModSmite("Smite", new ItemStack[] { holySoil }, 14, 1)); + tb.registerToolMod(new ModSmite("Smite", new ItemStack[] { holySoil, holySoil }, 14, 2)); + + ItemStack spidereyeball = new ItemStack(Item.fermentedSpiderEye); + tb.registerToolMod(new ModAntiSpider("Anti-Spider", new ItemStack[] { spidereyeball }, 15, 1)); + tb.registerToolMod(new ModAntiSpider("Anti-Spider", new ItemStack[] { spidereyeball, spidereyeball }, 15, 2)); + + ItemStack obsidianPlate = new ItemStack(heavyPlate, 1, 6); + tb.registerToolMod(new ModReinforced(new ItemStack[] { obsidianPlate }, 16, 1)); + + TConstructRegistry.registerActiveToolMod(new TActiveOmniMod()); + + /* Smeltery */ + ItemStack ingotcast = new ItemStack(metalPattern, 1, 0); + ItemStack jewelCast = new ItemStack(metalPattern, 1, 23); + + LiquidCasting tableCasting = TConstructRegistry.instance.getTableCasting(); + //Blank + tableCasting.addCastingRecipe(new ItemStack(blankPattern, 1, 1), new FluidStack(moltenAlubrassFluid, TConstruct.ingotLiquidValue), 80); + tableCasting.addCastingRecipe(new ItemStack(blankPattern, 1, 2), new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 2), 80); + + //Ingots + tableCasting.addCastingRecipe(new ItemStack(Item.ingotIron), new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //Iron + tableCasting.addCastingRecipe(new ItemStack(Item.ingotGold), new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //gold + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 9), new FluidStack(moltenCopperFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //copper + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 10), new FluidStack(moltenTinFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //tin + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 11), new FluidStack(moltenAluminumFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //aluminum + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 3), new FluidStack(moltenCobaltFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //cobalt + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 4), new FluidStack(moltenArditeFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //ardite + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 13), new FluidStack(moltenBronzeFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //bronze + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 14), new FluidStack(moltenAlubrassFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //albrass + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 5), new FluidStack(moltenManyullynFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //manyullyn + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 15), new FluidStack(moltenAlumiteFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //alumite + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 18), new FluidStack(moltenObsidianFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //obsidian + tableCasting.addCastingRecipe(new ItemStack(materials, 1, 16), new FluidStack(moltenSteelFluid, TConstruct.ingotLiquidValue), ingotcast, 80); //steel + + //Buckets + ItemStack bucket = new ItemStack(Item.bucketEmpty); + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 0), new FluidStack(moltenIronFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //Iron + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 1), new FluidStack(moltenGoldFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //gold + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 2), new FluidStack(moltenCopperFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //copper + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 3), new FluidStack(moltenTinFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //tin + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 4), new FluidStack(moltenAluminumFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //aluminum + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 5), new FluidStack(moltenCobaltFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //cobalt + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 6), new FluidStack(moltenArditeFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //ardite + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 7), new FluidStack(moltenBronzeFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //bronze + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 8), new FluidStack(moltenAlubrassFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //alubrass + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 9), new FluidStack(moltenManyullynFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //manyullyn + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 10), new FluidStack(moltenAlumiteFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //alumite + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 11), new FluidStack(moltenObsidianFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10);// obsidian + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 12), new FluidStack(moltenSteelFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //steel + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 13), new FluidStack(moltenGlassFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //glass + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 14), new FluidStack(moltenStoneFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //seared stone + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 15), new FluidStack(moltenEmeraldFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10); //emerald + + tableCasting.addCastingRecipe(new ItemStack(glassPane), new FluidStack(moltenGlassFluid, 250), null, 80); + + liquids = new FluidStack[] { new FluidStack(moltenIronFluid, 1), new FluidStack(moltenCopperFluid, 1), new FluidStack(moltenCobaltFluid, 1), new FluidStack(moltenArditeFluid, 1), + new FluidStack(moltenManyullynFluid, 1), new FluidStack(moltenBronzeFluid, 1), new FluidStack(moltenAlumiteFluid, 1), new FluidStack(moltenObsidianFluid, 1), + new FluidStack(moltenSteelFluid, 1) }; + int[] liquidDamage = new int[] { 2, 13, 10, 11, 12, 14, 15, 6, 16 }; + + for (int iter = 0; iter < patternOutputs.length; iter++) + { + if (patternOutputs[iter] != null) + { + ItemStack cast = new ItemStack(metalPattern, 1, iter + 1); + + tableCasting.addCastingRecipe(cast, new FluidStack(moltenAlubrassFluid, TConstruct.ingotLiquidValue), new ItemStack(patternOutputs[iter], 1, Short.MAX_VALUE), false, 50); + tableCasting.addCastingRecipe(cast, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 2), new ItemStack(patternOutputs[iter], 1, Short.MAX_VALUE), false, 50); + + for (int iterTwo = 0; iterTwo < liquids.length; iterTwo++) + { + ItemStack metalCast = new ItemStack(patternOutputs[iter], 1, liquidDamage[iterTwo]); + tableCasting.addCastingRecipe(metalCast, new FluidStack(liquids[iterTwo].getFluid(), ((IPattern) metalPattern).getPatternCost(metalCast) * TConstruct.ingotLiquidValue / 2), cast, + 50); + } + } + } + + ItemStack fullguardCast = new ItemStack(metalPattern, 1, 22); + tableCasting.addCastingRecipe(fullguardCast, new FluidStack(moltenAlubrassFluid, TConstruct.ingotLiquidValue), new ItemStack(fullGuard, 1, Short.MAX_VALUE), false, 50); + tableCasting.addCastingRecipe(fullguardCast, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 2), new ItemStack(fullGuard, 1, Short.MAX_VALUE), false, 50); + LiquidCasting basinCasting = TConstructRegistry.getBasinCasting(); + basinCasting.addCastingRecipe(new ItemStack(Block.blockIron), new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //Iron + basinCasting.addCastingRecipe(new ItemStack(Block.blockGold), new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //gold + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 3), new FluidStack(moltenCopperFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //copper + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 5), new FluidStack(moltenTinFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //tin + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 6), new FluidStack(moltenAluminumFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //aluminum + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 0), new FluidStack(moltenCobaltFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //cobalt + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 1), new FluidStack(moltenArditeFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //ardite + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 4), new FluidStack(moltenBronzeFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //bronze + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 7), new FluidStack(moltenAlubrassFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //albrass + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 2), new FluidStack(moltenManyullynFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //manyullyn + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 8), new FluidStack(moltenAlumiteFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //alumite + basinCasting.addCastingRecipe(new ItemStack(Block.obsidian), new FluidStack(moltenObsidianFluid, TConstruct.ingotLiquidValue * 2), null, true, 100);// obsidian + basinCasting.addCastingRecipe(new ItemStack(metalBlock, 1, 9), new FluidStack(moltenSteelFluid, TConstruct.ingotLiquidValue * 9), null, true, 100); //steel + basinCasting.addCastingRecipe(new ItemStack(glass, 1, 0), new FluidStack(moltenGlassFluid, FluidContainerRegistry.BUCKET_VOLUME), null, true, 100); //glass + basinCasting.addCastingRecipe(new ItemStack(smeltery, 1, 4), new FluidStack(moltenStoneFluid, TConstruct.ingotLiquidValue), null, true, 100); //seared stone + + basinCasting.addCastingRecipe(new ItemStack(speedBlock, 1, 0), new FluidStack(moltenTinFluid, TConstruct.ingotLiquidValue / 9), new ItemStack(Block.gravel), true, 100); //brownstone + + //Ore + Smeltery.addMelting(Block.oreIron, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(Block.oreGold, 0, 400, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(oreGravel, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(oreGravel, 1, 400, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 2)); + + //Items + Smeltery.addMelting(new ItemStack(Item.ingotIron, 4), Block.blockIron.blockID, 0, 500, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue)); + Smeltery.addMelting(new ItemStack(Item.ingotGold, 4), Block.blockGold.blockID, 0, 300, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue)); + Smeltery.addMelting(new ItemStack(Item.goldNugget, 4), Block.blockGold.blockID, 0, 150, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue / 9)); + + Smeltery.addMelting(new ItemStack(materials, 1, 18), Block.obsidian.blockID, 0, 750, new FluidStack(moltenObsidianFluid, TConstruct.ingotLiquidValue)); //Obsidian ingot + + Smeltery.addMelting(new ItemStack(blankPattern, 4, 1), metalBlock.blockID, 7, 150, new FluidStack(moltenAlubrassFluid, TConstruct.ingotLiquidValue)); + Smeltery.addMelting(new ItemStack(blankPattern, 4, 2), metalBlock.blockID, 7, 150, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 2)); + + //Blocks + Smeltery.addMelting(Block.blockIron, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 9)); + Smeltery.addMelting(Block.blockGold, 0, 400, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 9)); + Smeltery.addMelting(Block.obsidian, 0, 800, new FluidStack(moltenObsidianFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(Block.ice, 0, 75, new FluidStack(FluidRegistry.getFluid("water"), 1000)); + Smeltery.addMelting(Block.sand, 0, 625, new FluidStack(moltenGlassFluid, FluidContainerRegistry.BUCKET_VOLUME)); + Smeltery.addMelting(Block.glass, 0, 625, new FluidStack(moltenGlassFluid, FluidContainerRegistry.BUCKET_VOLUME)); + Smeltery.addMelting(Block.stone, 0, 800, new FluidStack(moltenStoneFluid, TConstruct.ingotLiquidValue / 18)); + Smeltery.addMelting(Block.cobblestone, 0, 800, new FluidStack(moltenStoneFluid, TConstruct.ingotLiquidValue / 18)); + + Smeltery.addMelting(glass, 0, 500, new FluidStack(moltenGlassFluid, 1000)); + Smeltery.addMelting(glassPane, 0, 350, new FluidStack(moltenGlassFluid, 250)); + + for (int i = 0; i < 16; i++) + { + Smeltery.addMelting(stainedGlassClear, i, 500, new FluidStack(moltenGlassFluid, 1000)); + Smeltery.addMelting(stainedGlassClearPane, i, 350, new FluidStack(moltenGlassFluid, 250)); + } + + //Alloys + Smeltery.addAlloyMixing(new FluidStack(moltenBronzeFluid, 16), new FluidStack(moltenCopperFluid, 24), new FluidStack(moltenTinFluid, 8)); //Bronze + Smeltery.addAlloyMixing(new FluidStack(moltenAlubrassFluid, 16), new FluidStack(moltenAluminumFluid, 24), new FluidStack(moltenCopperFluid, 8)); //Aluminum Brass + Smeltery.addAlloyMixing(new FluidStack(moltenManyullynFluid, 16), new FluidStack(moltenCobaltFluid, 32), new FluidStack(moltenArditeFluid, 32)); //Manyullyn + Smeltery.addAlloyMixing(new FluidStack(moltenAlumiteFluid, 48), new FluidStack(moltenAluminumFluid, 80), new FluidStack(moltenIronFluid, 32), new FluidStack(moltenObsidianFluid, 32)); //Alumite + + //Oreberries + Smeltery.addMelting(new ItemStack(oreBerries, 4, 0), Block.blockIron.blockID, 0, 100, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue / 9)); //Iron + Smeltery.addMelting(new ItemStack(oreBerries, 4, 1), Block.blockGold.blockID, 0, 100, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue / 9)); //Gold + Smeltery.addMelting(new ItemStack(oreBerries, 4, 2), metalBlock.blockID, 3, 100, new FluidStack(moltenCopperFluid, TConstruct.ingotLiquidValue / 9)); //Copper + Smeltery.addMelting(new ItemStack(oreBerries, 4, 3), metalBlock.blockID, 5, 100, new FluidStack(moltenTinFluid, TConstruct.ingotLiquidValue / 9)); //Tin + Smeltery.addMelting(new ItemStack(oreBerries, 4, 4), metalBlock.blockID, 6, 100, new FluidStack(moltenAluminumFluid, TConstruct.ingotLiquidValue / 9)); //Aluminum + + //Vanilla Armor + Smeltery.addMelting(new ItemStack(Item.helmetIron, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 5)); + Smeltery.addMelting(new ItemStack(Item.plateIron, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 8)); + Smeltery.addMelting(new ItemStack(Item.legsIron, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 7)); + Smeltery.addMelting(new ItemStack(Item.bootsIron, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 4)); + + Smeltery.addMelting(new ItemStack(Item.helmetGold, 1, 0), Block.blockGold.blockID, 0, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 5)); + Smeltery.addMelting(new ItemStack(Item.plateGold, 1, 0), Block.blockGold.blockID, 0, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 8)); + Smeltery.addMelting(new ItemStack(Item.legsGold, 1, 0), Block.blockGold.blockID, 0, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 7)); + Smeltery.addMelting(new ItemStack(Item.bootsGold, 1, 0), Block.blockGold.blockID, 0, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 4)); + + Smeltery.addMelting(new ItemStack(Item.helmetChain, 1, 0), this.metalBlock.blockID, 9, 700, new FluidStack(moltenSteelFluid, TConstruct.ingotLiquidValue)); + Smeltery.addMelting(new ItemStack(Item.plateChain, 1, 0), this.metalBlock.blockID, 9, 700, new FluidStack(moltenSteelFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(new ItemStack(Item.legsChain, 1, 0), this.metalBlock.blockID, 9, 700, new FluidStack(moltenSteelFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(new ItemStack(Item.bootsChain, 1, 0), this.metalBlock.blockID, 9, 700, new FluidStack(moltenSteelFluid, TConstruct.ingotLiquidValue)); + + //Vanilla tools + Smeltery.addMelting(new ItemStack(Item.hoeIron, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(new ItemStack(Item.swordIron, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(new ItemStack(Item.shovelIron, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 1)); + Smeltery.addMelting(new ItemStack(Item.pickaxeIron, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 3)); + Smeltery.addMelting(new ItemStack(Item.axeIron, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 3)); + + Smeltery.addMelting(new ItemStack(Item.hoeGold, 1, 0), Block.blockGold.blockID, 0, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(new ItemStack(Item.swordGold, 1, 0), Block.blockGold.blockID, 0, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(new ItemStack(Item.shovelGold, 1, 0), Block.blockGold.blockID, 0, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 1)); + Smeltery.addMelting(new ItemStack(Item.pickaxeGold, 1, 0), Block.blockGold.blockID, 0, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 3)); + Smeltery.addMelting(new ItemStack(Item.axeGold, 1, 0), Block.blockGold.blockID, 0, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 3)); + + //Vanilla items + Smeltery.addMelting(new ItemStack(Item.flintAndSteel, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue)); + Smeltery.addMelting(new ItemStack(Item.compass, 1, 0), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 4)); + + //Vanilla blocks + Smeltery.addMelting(new ItemStack(Item.bucketEmpty), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 3)); + Smeltery.addMelting(new ItemStack(Item.minecartEmpty), Block.blockIron.blockID, 8, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 5)); + Smeltery.addMelting(new ItemStack(Item.doorIron), Block.blockIron.blockID, 8, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 6)); + Smeltery.addMelting(new ItemStack(Block.fenceIron), Block.blockIron.blockID, 8, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 6 / 16)); + Smeltery.addMelting(new ItemStack(Block.pressurePlateIron), Block.blockIron.blockID, 0, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(new ItemStack(Block.pressurePlateGold, 4), Block.blockGold.blockID, 0, 600, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue * 2)); + Smeltery.addMelting(new ItemStack(Block.rail), Block.blockIron.blockID, 8, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 6 / 16)); + Smeltery.addMelting(new ItemStack(Block.railPowered), Block.blockGold.blockID, 8, 350, new FluidStack(moltenGoldFluid, TConstruct.ingotLiquidValue)); + Smeltery.addMelting(new ItemStack(Block.railDetector), Block.blockIron.blockID, 8, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue)); + Smeltery.addMelting(new ItemStack(Block.railActivator), Block.blockIron.blockID, 8, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue)); + Smeltery.addMelting(new ItemStack(Block.enchantmentTable), Block.obsidian.blockID, 0, 750, new FluidStack(moltenObsidianFluid, TConstruct.ingotLiquidValue * 4)); + Smeltery.addMelting(new ItemStack(Block.cauldron), Block.blockIron.blockID, 8, 600, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 7)); + Smeltery.addMelting(new ItemStack(Block.anvil, 1, 0), Block.blockIron.blockID, 8, 800, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 31)); + Smeltery.addMelting(new ItemStack(Block.anvil, 1, 1), Block.blockIron.blockID, 8, 800, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 31)); + Smeltery.addMelting(new ItemStack(Block.anvil, 1, 2), Block.blockIron.blockID, 8, 800, new FluidStack(moltenIronFluid, TConstruct.ingotLiquidValue * 31)); + + /* Detailing */ + Detailing chiseling = TConstructRegistry.getChiselDetailing(); + chiseling.addDetailing(Block.stone, 0, Block.stoneBrick, 0, chisel); + chiseling.addDetailing(speedBlock, 0, speedBlock, 1, chisel); + chiseling.addDetailing(speedBlock, 2, speedBlock, 3, chisel); + chiseling.addDetailing(speedBlock, 3, speedBlock, 4, chisel); + chiseling.addDetailing(speedBlock, 4, speedBlock, 5, chisel); + chiseling.addDetailing(speedBlock, 5, speedBlock, 6, chisel); + + chiseling.addDetailing(Block.obsidian, 0, multiBrick, 0, chisel); + chiseling.addDetailing(Block.sandStone, 0, Block.sandStone, 2, chisel); + chiseling.addDetailing(Block.sandStone, 2, Block.sandStone, 1, chisel); + chiseling.addDetailing(Block.sandStone, 1, multiBrick, 1, chisel); + //chiseling.addDetailing(Block.netherrack, 0, multiBrick, 2, chisel); + //chiseling.addDetailing(Block.stone_refined, 0, multiBrick, 3, chisel); + chiseling.addDetailing(Item.ingotIron, 0, multiBrick, 4, chisel); + chiseling.addDetailing(Item.ingotGold, 0, multiBrick, 5, chisel); + chiseling.addDetailing(Item.dyePowder, 4, multiBrick, 6, chisel); + chiseling.addDetailing(Item.diamond, 0, multiBrick, 7, chisel); + chiseling.addDetailing(Item.redstone, 0, multiBrick, 8, chisel); + chiseling.addDetailing(Item.bone, 0, multiBrick, 9, chisel); + chiseling.addDetailing(Item.slimeBall, 0, multiBrick, 10, chisel); + chiseling.addDetailing(strangeFood, 0, multiBrick, 11, chisel); + chiseling.addDetailing(Block.whiteStone, 0, multiBrick, 12, chisel); + chiseling.addDetailing(materials, 18, multiBrick, 13, chisel); + + chiseling.addDetailing(multiBrick, 0, multiBrickFancy, 0, chisel); + chiseling.addDetailing(multiBrick, 1, multiBrickFancy, 1, chisel); + chiseling.addDetailing(multiBrick, 2, multiBrickFancy, 2, chisel); + chiseling.addDetailing(multiBrick, 3, multiBrickFancy, 3, chisel); + chiseling.addDetailing(multiBrick, 4, multiBrickFancy, 4, chisel); + chiseling.addDetailing(multiBrick, 5, multiBrickFancy, 5, chisel); + chiseling.addDetailing(multiBrick, 6, multiBrickFancy, 6, chisel); + chiseling.addDetailing(multiBrick, 7, multiBrickFancy, 7, chisel); + chiseling.addDetailing(multiBrick, 8, multiBrickFancy, 8, chisel); + chiseling.addDetailing(multiBrick, 9, multiBrickFancy, 9, chisel); + chiseling.addDetailing(multiBrick, 10, multiBrickFancy, 10, chisel); + chiseling.addDetailing(multiBrick, 11, multiBrickFancy, 11, chisel); + chiseling.addDetailing(multiBrick, 12, multiBrickFancy, 12, chisel); + chiseling.addDetailing(multiBrick, 13, multiBrickFancy, 13, chisel); + + chiseling.addDetailing(Block.stoneBrick, 0, multiBrickFancy, 15, chisel); + chiseling.addDetailing(multiBrickFancy, 15, multiBrickFancy, 14, chisel); + chiseling.addDetailing(multiBrickFancy, 14, Block.stoneBrick, 3, chisel); + /*chiseling.addDetailing(multiBrick, 14, multiBrickFancy, 14, chisel); + chiseling.addDetailing(multiBrick, 15, multiBrickFancy, 15, chisel);*/ + + chiseling.addDetailing(smeltery, 4, smeltery, 6, chisel); + chiseling.addDetailing(smeltery, 6, smeltery, 11, chisel); + chiseling.addDetailing(smeltery, 11, smeltery, 2, chisel); + chiseling.addDetailing(smeltery, 2, smeltery, 8, chisel); + chiseling.addDetailing(smeltery, 8, smeltery, 9, chisel); + chiseling.addDetailing(smeltery, 9, smeltery, 10, chisel); + + GameRegistry.addRecipe(new ItemStack(toolForge, 1, 0), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', Block.blockIron); + GameRegistry.addRecipe(new ItemStack(toolForge, 1, 1), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', Block.blockGold); + GameRegistry.addRecipe(new ItemStack(toolForge, 1, 2), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', Block.blockDiamond); + GameRegistry.addRecipe(new ItemStack(toolForge, 1, 3), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', Block.blockEmerald); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 4), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', + "blockCobalt")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 5), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', + "blockArdite")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 6), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', + "blockManyullyn")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 7), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', + "blockCopper")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 8), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', + "blockBronze")); + GameRegistry + .addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 9), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', "blockTin")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 10), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', + "blockNaturalAluminum")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 11), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', + "blockAluminumBrass")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 12), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', + "blockAlumite")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolForge, 1, 13), "bbb", "msm", "m m", 'b', new ItemStack(smeltery, 1, 2), 's', new ItemStack(toolStationWood, 1, 0), 'm', + "blockSteel")); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(redstoneMachine, 1, 0), "aca", "#d#", "#r#", '#', "ingotBronze", 'a', "ingotAluminumBrass", 'c', new ItemStack(blankPattern, 1, 1), + 'r', new ItemStack(Item.redstone), 'd', new ItemStack(Block.dispenser))); //Drawbridge + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(redstoneMachine, 1, 0), "aca", "#d#", "#r#", '#', "ingotBronze", 'a', "ingotAluminumBrass", 'c', new ItemStack(blankPattern, 1, 2), + 'r', new ItemStack(Item.redstone), 'd', new ItemStack(Block.dispenser))); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(redstoneMachine, 1, 1), "aca", "#d#", "#r#", '#', "ingotBronze", 'a', "ingotAluminumBrass", 'c', new ItemStack(heavyPlate, 1, 7), 'r', + new ItemStack(Item.redstone), 'd', new ItemStack(Item.flintAndSteel))); //Igniter + + /* Crafting */ + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 0), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', Block.workbench); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolStationWood, 1, 1), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', "crafterWood")); + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 1), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', new ItemStack(Block.wood, 1, 0)); + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 2), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', new ItemStack(Block.wood, 1, 1)); + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 3), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', new ItemStack(Block.wood, 1, 2)); + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 4), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', new ItemStack(Block.wood, 1, 3)); + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 5), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', Block.chest); + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 10), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', new ItemStack(Block.planks, 1, 0)); + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 11), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', new ItemStack(Block.planks, 1, 1)); + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 12), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', new ItemStack(Block.planks, 1, 2)); + GameRegistry.addRecipe(new ItemStack(toolStationWood, 1, 13), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', new ItemStack(Block.planks, 1, 3)); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolStationWood, 1, 1), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', "logWood")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolStationWood, 1, 10), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', "plankWood")); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blankPattern, 1, 0), "ps", "sp", 'p', "plankWood", 's', "stickWood")); + GameRegistry.addRecipe(new ItemStack(manualBook), "wp", 'w', new ItemStack(blankPattern, 1, 0), 'p', Item.paper); + GameRegistry.addShapelessRecipe(new ItemStack(manualBook, 2, 0), new ItemStack(manualBook, 1, 0), Item.book); + GameRegistry.addShapelessRecipe(new ItemStack(manualBook, 1, 1), new ItemStack(manualBook, 1, 0)); + GameRegistry.addShapelessRecipe(new ItemStack(manualBook, 2, 1), new ItemStack(manualBook, 1, 1), Item.book); + GameRegistry.addShapelessRecipe(new ItemStack(manualBook, 1, 2), new ItemStack(manualBook, 1, 1)); + GameRegistry.addShapelessRecipe(new ItemStack(manualBook, 2, 2), new ItemStack(manualBook, 1, 2), Item.book); + + GameRegistry.addRecipe(new ItemStack(materials, 1, 0), "pp", "pp", 'p', Item.paper); //Paper stack + OreDictionary.registerOre("mossystone", new ItemStack(Block.stoneBrick, 1, 1)); + OreDictionary.registerOre("mossystone", new ItemStack(Block.cobblestoneMossy)); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(materials, 1, 6), "ppp", "ppp", "ppp", 'p', "mossystone")); //Moss ball + GameRegistry.addRecipe(new ItemStack(materials, 1, 6), "ppp", "ppp", "ppp", 'p', new ItemStack(Block.stoneBrick, 1, 1)); //Moss ball + GameRegistry.addRecipe(new ItemStack(materials, 1, 7), "xcx", "cbc", "xcx", 'b', Item.bucketLava, 'c', Item.fireballCharge, 'x', Item.blazeRod); //Auto-smelt + GameRegistry.addRecipe(new ItemStack(materials, 1, 7), "xcx", "cbc", "xcx", 'b', Item.bucketLava, 'x', Item.fireballCharge, 'c', Item.blazeRod); //Auto-smelt + + GameRegistry.addShapelessRecipe(new ItemStack(craftedSoil, 1, 0), Item.slimeBall, Item.slimeBall, Item.slimeBall, Item.slimeBall, Block.sand, Block.dirt); //Slimy sand + GameRegistry.addShapelessRecipe(new ItemStack(craftedSoil, 1, 2), strangeFood, strangeFood, strangeFood, strangeFood, Block.sand, Block.dirt); //Slimy sand + GameRegistry.addShapelessRecipe(new ItemStack(craftedSoil, 2, 1), Item.clay, Block.sand, Block.gravel); //Grout + GameRegistry.addShapelessRecipe(new ItemStack(craftedSoil, 8, 1), Block.blockClay, Block.sand, Block.gravel, Block.sand, Block.gravel, Block.sand, Block.gravel, Block.sand, Block.gravel); //Grout + GameRegistry.addShapelessRecipe(new ItemStack(craftedSoil, 1, 3), Block.dirt, Item.rottenFlesh, new ItemStack(Item.dyePowder, 1, 15)); //Graveyard Soil + FurnaceRecipes.smelting().addSmelting(craftedSoil.blockID, 3, new ItemStack(craftedSoil, 1, 4), 0.2f); //Concecrated Soil + + FurnaceRecipes.smelting().addSmelting(craftedSoil.blockID, 0, new ItemStack(materials, 1, 1), 2f); //Slime + FurnaceRecipes.smelting().addSmelting(craftedSoil.blockID, 1, new ItemStack(materials, 1, 2), 2f); //Seared brick item + FurnaceRecipes.smelting().addSmelting(craftedSoil.blockID, 2, new ItemStack(materials, 1, 17), 2f); //Blue Slime + //GameRegistry.addRecipe(new ItemStack(oreSlag, 1, 0), "pp", "pp", 'p', new ItemStack(materials, 1, 2)); //Seared brick block + + GameRegistry.addRecipe(new ItemStack(materials, 1, 25), "sss", "sns", "sss", 'n', new ItemStack(materials, 1, 24), 's', new ItemStack(Item.silk)); //Silky Cloth + GameRegistry.addRecipe(new ItemStack(materials, 1, 25), "sss", "sns", "sss", 'n', new ItemStack(Item.goldNugget), 's', new ItemStack(Item.silk)); + GameRegistry.addRecipe(new ItemStack(materials, 1, 26), " c ", "cec", " c ", 'c', new ItemStack(materials, 1, 25), 'e', new ItemStack(Item.emerald)); //Silky Jewel + + //FurnaceRecipes.smelting().addSmelting(oreSlag.blockID, 1, new ItemStack(materials, 1, 3), 3f); + //FurnaceRecipes.smelting().addSmelting(oreSlag.blockID, 2, new ItemStack(materials, 1, 4), 3f); + FurnaceRecipes.smelting().addSmelting(oreSlag.blockID, 3, new ItemStack(materials, 1, 9), 0.5f); + FurnaceRecipes.smelting().addSmelting(oreSlag.blockID, 4, new ItemStack(materials, 1, 10), 0.5f); + FurnaceRecipes.smelting().addSmelting(oreSlag.blockID, 5, new ItemStack(materials, 1, 12), 0.5f); + + FurnaceRecipes.smelting().addSmelting(oreBerries.itemID, 0, new ItemStack(materials, 1, 19), 0.2f); + FurnaceRecipes.smelting().addSmelting(oreBerries.itemID, 1, new ItemStack(Item.goldNugget), 0.2f); + FurnaceRecipes.smelting().addSmelting(oreBerries.itemID, 2, new ItemStack(materials, 1, 20), 0.2f); + FurnaceRecipes.smelting().addSmelting(oreBerries.itemID, 3, new ItemStack(materials, 1, 21), 0.2f); + FurnaceRecipes.smelting().addSmelting(oreBerries.itemID, 4, new ItemStack(materials, 1, 22), 0.2f); + //FurnaceRecipes.smelting().addSmelting(oreBerries.itemID, 5, new ItemStack(materials, 1, 23), 0.2f); + + FurnaceRecipes.smelting().addSmelting(oreGravel.blockID, 0, new ItemStack(Item.ingotIron), 0.2f); + FurnaceRecipes.smelting().addSmelting(oreGravel.blockID, 1, new ItemStack(Item.ingotGold), 0.2f); + FurnaceRecipes.smelting().addSmelting(oreGravel.blockID, 2, new ItemStack(materials, 1, 9), 0.2f); + FurnaceRecipes.smelting().addSmelting(oreGravel.blockID, 3, new ItemStack(materials, 1, 10), 0.2f); + FurnaceRecipes.smelting().addSmelting(oreGravel.blockID, 4, new ItemStack(materials, 1, 12), 0.2f); + + FurnaceRecipes.smelting().addSmelting(speedBlock.blockID, 0, new ItemStack(speedBlock, 1, 2), 0.2f); + + //Metal conversion + GameRegistry.addRecipe(new ItemStack(materials, 9, 9), "m", 'm', new ItemStack(metalBlock, 1, 3)); //Copper + GameRegistry.addRecipe(new ItemStack(materials, 9, 10), "m", 'm', new ItemStack(metalBlock, 1, 5)); //Tin + GameRegistry.addRecipe(new ItemStack(materials, 9, 12), "m", 'm', new ItemStack(metalBlock, 1, 6)); //Aluminum + GameRegistry.addRecipe(new ItemStack(materials, 9, 13), "m", 'm', new ItemStack(metalBlock, 1, 4)); //Bronze + GameRegistry.addRecipe(new ItemStack(materials, 9, 14), "m", 'm', new ItemStack(metalBlock, 1, 7)); //AluBrass + GameRegistry.addRecipe(new ItemStack(materials, 9, 3), "m", 'm', new ItemStack(metalBlock, 1, 0)); //Cobalt + GameRegistry.addRecipe(new ItemStack(materials, 9, 4), "m", 'm', new ItemStack(metalBlock, 1, 1)); //Ardite + GameRegistry.addRecipe(new ItemStack(materials, 9, 5), "m", 'm', new ItemStack(metalBlock, 1, 2)); //Manyullyn + GameRegistry.addRecipe(new ItemStack(materials, 9, 15), "m", 'm', new ItemStack(metalBlock, 1, 8)); //Alumite + GameRegistry.addRecipe(new ItemStack(materials, 9, 16), "m", 'm', new ItemStack(metalBlock, 1, 9)); //Steel + + GameRegistry.addRecipe(new ItemStack(Item.ingotIron), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 19)); //Iron + GameRegistry.addRecipe(new ItemStack(materials, 1, 9), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 20)); //Copper + GameRegistry.addRecipe(new ItemStack(materials, 1, 10), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 21)); //Tin + GameRegistry.addRecipe(new ItemStack(materials, 1, 12), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 22)); //Aluminum + GameRegistry.addRecipe(new ItemStack(materials, 1, 14), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 24)); //Aluminum Brass + GameRegistry.addRecipe(new ItemStack(materials, 1, 18), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 27)); //Obsidian + GameRegistry.addRecipe(new ItemStack(materials, 1, 3), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 28)); //Cobalt + GameRegistry.addRecipe(new ItemStack(materials, 1, 4), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 29)); //Ardite + GameRegistry.addRecipe(new ItemStack(materials, 1, 5), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 30)); //Manyullyn + GameRegistry.addRecipe(new ItemStack(materials, 1, 13), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 31)); //Bronze + GameRegistry.addRecipe(new ItemStack(materials, 1, 15), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 32)); //Alumite + GameRegistry.addRecipe(new ItemStack(materials, 1, 16), "mmm", "mmm", "mmm", 'm', new ItemStack(materials, 1, 33)); //Steel + + GameRegistry.addRecipe(new ItemStack(materials, 9, 19), "m", 'm', new ItemStack(Item.ingotIron)); //Iron + GameRegistry.addRecipe(new ItemStack(materials, 9, 20), "m", 'm', new ItemStack(materials, 1, 9)); //Copper + GameRegistry.addRecipe(new ItemStack(materials, 9, 21), "m", 'm', new ItemStack(materials, 1, 10)); //Tin + GameRegistry.addRecipe(new ItemStack(materials, 9, 22), "m", 'm', new ItemStack(materials, 1, 12)); //Aluminum + GameRegistry.addRecipe(new ItemStack(materials, 9, 24), "m", 'm', new ItemStack(materials, 1, 14)); //Aluminum Brass + GameRegistry.addRecipe(new ItemStack(materials, 9, 27), "m", 'm', new ItemStack(materials, 1, 18)); //Obsidian + GameRegistry.addRecipe(new ItemStack(materials, 9, 28), "m", 'm', new ItemStack(materials, 1, 3)); //Cobalt + GameRegistry.addRecipe(new ItemStack(materials, 9, 29), "m", 'm', new ItemStack(materials, 1, 4)); //Ardite + GameRegistry.addRecipe(new ItemStack(materials, 9, 30), "m", 'm', new ItemStack(materials, 1, 5)); //Manyullyn + GameRegistry.addRecipe(new ItemStack(materials, 9, 31), "m", 'm', new ItemStack(materials, 1, 13)); //Bronze + GameRegistry.addRecipe(new ItemStack(materials, 9, 32), "m", 'm', new ItemStack(materials, 1, 15)); //Alumite + GameRegistry.addRecipe(new ItemStack(materials, 9, 33), "m", 'm', new ItemStack(materials, 1, 16)); //Steel + + //Dyes + String[] pattern = { "###", "#m#", "###" }; + String[] dyeTypes = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", + "dyeMagenta", "dyeOrange", "dyeWhite" }; + for (int i = 0; i < 16; i++) + { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Block.cloth, 8, i), pattern, 'm', dyeTypes[15 - i], '#', new ItemStack(Block.cloth, 1, Short.MAX_VALUE))); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(stainedGlassClear, 8, i), pattern, 'm', dyeTypes[15 - i], '#', glass)); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(stainedGlassClear, 1, i), dyeTypes[15 - i], glass)); + } + + //Smeltery + ItemStack searedBrick = new ItemStack(materials, 1, 2); + GameRegistry.addRecipe(new ItemStack(smeltery, 1, 0), "bbb", "b b", "bbb", 'b', searedBrick); //Controller + GameRegistry.addRecipe(new ItemStack(smeltery, 1, 1), "b b", "b b", "b b", 'b', searedBrick); //Drain + GameRegistry.addRecipe(new ItemStack(smeltery, 1, 2), "bb", "bb", 'b', searedBrick); //Bricks + + GameRegistry.addRecipe(new ItemStack(lavaTank, 1, 0), "bbb", "bgb", "bbb", 'b', searedBrick, 'g', Block.glass); //Tank + GameRegistry.addRecipe(new ItemStack(lavaTank, 1, 1), "bgb", "ggg", "bgb", 'b', searedBrick, 'g', Block.glass); //Glass + GameRegistry.addRecipe(new ItemStack(lavaTank, 1, 2), "bgb", "bgb", "bgb", 'b', searedBrick, 'g', Block.glass); //Window + + GameRegistry.addRecipe(new ItemStack(searedBlock, 1, 0), "bbb", "b b", "b b", 'b', searedBrick); //Table + GameRegistry.addRecipe(new ItemStack(searedBlock, 1, 1), "b b", " b ", 'b', searedBrick); //Faucet + GameRegistry.addRecipe(new ItemStack(searedBlock, 1, 2), "b b", "b b", "bbb", 'b', searedBrick); //Basin + + GameRegistry.addRecipe(new ItemStack(Block.pumpkinLantern, 1, 0), "p", "s", 'p', new ItemStack(Block.pumpkin), 'w', new ItemStack(toolRod, 1, 1)); + GameRegistry.addRecipe(new ItemStack(stoneTorch, 4), "p", "w", 'p', new ItemStack(Item.coal, 1, Short.MAX_VALUE), 'w', new ItemStack(toolRod, 1, 1)); + GameRegistry.addRecipe(new ItemStack(toolRod, 4, 1), "c", "c", 'c', new ItemStack(Block.stone)); + GameRegistry.addRecipe(new ItemStack(toolRod, 2, 1), "c", "c", 'c', new ItemStack(Block.cobblestone)); + + ItemStack aluBrass = new ItemStack(materials, 1, 14); + GameRegistry.addRecipe(new ItemStack(Item.pocketSundial), " i ", "iri", " i ", 'i', aluBrass, 'r', new ItemStack(Item.redstone)); + GameRegistry.addRecipe(new ItemStack(Block.pressurePlateGold), "ii", 'i', aluBrass); + + ItemStack necroticBone = new ItemStack(materials, 1, 8); + + //Accessories + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(heartCanister, 1, 0), "##", "##", '#', "ingotNaturalAluminum")); + GameRegistry.addRecipe(new ItemStack(diamondApple), " d ", "d#d", " d ", 'd', new ItemStack(Item.diamond), '#', new ItemStack(Item.appleRed)); + GameRegistry.addShapelessRecipe(new ItemStack(heartCanister, 1, 2), new ItemStack(diamondApple), necroticBone, new ItemStack(heartCanister, 1, 0), new ItemStack(heartCanister, 1, 1)); + GameRegistry.addRecipe(new ItemStack(knapsack, 1, 0), "###", "rmr", "###", '#', new ItemStack(Item.leather), 'r', new ItemStack(toughRod, 1, 2), 'm', new ItemStack(Item.ingotGold)); + GameRegistry.addRecipe(new ItemStack(knapsack, 1, 0), "###", "rmr", "###", '#', new ItemStack(Item.leather), 'r', new ItemStack(toughRod, 1, 2), 'm', new ItemStack(materials, 1, 14)); + + //Armor + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(dryingRack, 1, 0), "bbb", 'b', "slabWood")); + + //Remove vanilla recipes + if (!PHConstruct.vanillaMetalBlocks) + { + RecipeRemover.removeShapedRecipe(new ItemStack(Block.blockIron)); + RecipeRemover.removeShapedRecipe(new ItemStack(Block.blockGold)); + } + + //Ultra hardcore recipes + String[] surround = { "###", "#m#", "###" }; + if (PHConstruct.goldAppleRecipe) + { + RecipeRemover.removeShapedRecipe(new ItemStack(Item.appleGold)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.goldenCarrot)); + RecipeRemover.removeShapelessRecipe(new ItemStack(Item.speckledMelon)); + + GameRegistry.addRecipe(new ItemStack(Item.appleGold), surround, '#', new ItemStack(Item.ingotGold), 'm', new ItemStack(Item.appleRed)); + GameRegistry.addRecipe(new ItemStack(Item.goldenCarrot), surround, '#', new ItemStack(Item.ingotGold), 'm', new ItemStack(Item.carrot)); + GameRegistry.addRecipe(new ItemStack(goldHead), surround, '#', new ItemStack(Item.ingotGold), 'm', new ItemStack(Item.skull, 1, 3)); + GameRegistry.addShapelessRecipe(new ItemStack(Item.speckledMelon), new ItemStack(Block.blockGold), new ItemStack(Item.melon)); + } + else + { + GameRegistry.addRecipe(new ItemStack(goldHead), surround, '#', new ItemStack(Item.goldNugget), 'm', new ItemStack(Item.skull, 1, 3)); + } + + //Drying rack + DryingRackRecipes.addDryingRecipe(Item.rottenFlesh, 20, Item.leather); + + //Slabs + for (int i = 0; i < 7; i++) + { + GameRegistry.addRecipe(new ItemStack(speedSlab, 6, i), "bbb", 'b', new ItemStack(speedBlock, 1, i)); + } + GameRegistry.addRecipe(new ItemStack(searedSlab, 6, 0), "bbb", 'b', new ItemStack(smeltery, 1, 2)); + GameRegistry.addRecipe(new ItemStack(searedSlab, 6, 1), "bbb", 'b', new ItemStack(smeltery, 1, 4)); + GameRegistry.addRecipe(new ItemStack(searedSlab, 6, 2), "bbb", 'b', new ItemStack(smeltery, 1, 5)); + GameRegistry.addRecipe(new ItemStack(searedSlab, 6, 3), "bbb", 'b', new ItemStack(smeltery, 1, 6)); + GameRegistry.addRecipe(new ItemStack(searedSlab, 6, 4), "bbb", 'b', new ItemStack(smeltery, 1, 8)); + GameRegistry.addRecipe(new ItemStack(searedSlab, 6, 5), "bbb", 'b', new ItemStack(smeltery, 1, 9)); + GameRegistry.addRecipe(new ItemStack(searedSlab, 6, 6), "bbb", 'b', new ItemStack(smeltery, 1, 10)); + GameRegistry.addRecipe(new ItemStack(searedSlab, 6, 7), "bbb", 'b', new ItemStack(smeltery, 1, 11)); + } + + void setupToolTabs () + { + TConstructRegistry.materialTab.init(new ItemStack(titleIcon, 1, 255)); + TConstructRegistry.blockTab.init(new ItemStack(toolStationWood)); + ItemStack tool = new ItemStack(longsword, 1, 0); + + NBTTagCompound compound = new NBTTagCompound(); + compound.setCompoundTag("InfiTool", new NBTTagCompound()); + compound.getCompoundTag("InfiTool").setInteger("RenderHead", 2); + compound.getCompoundTag("InfiTool").setInteger("RenderHandle", 0); + compound.getCompoundTag("InfiTool").setInteger("RenderAccessory", 10); + tool.setTagCompound(compound); + + //TConstruct. + TConstructRegistry.toolTab.init(tool); + } + + public void addLoot () + { + //Item, min, max, weight + ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(heartCanister, 1, 1), 1, 1, 5)); + ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_DESERT_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(heartCanister, 1, 1), 1, 1, 10)); + ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(heartCanister, 1, 1), 1, 1, 10)); + + tinkerHouseChest = new ChestGenHooks("TinkerHouse", new WeightedRandomChestContent[0], 3, 27); + tinkerHouseChest.addItem(new WeightedRandomChestContent(new ItemStack(heartCanister, 1, 1), 1, 1, 1)); + int[] validTypes = { 0, 1, 2, 3, 4, 5, 6, 8, 9, 13, 14, 17 }; + Item[] partTypes = { pickaxeHead, shovelHead, hatchetHead, binding, swordBlade, wideGuard, handGuard, crossbar, knifeBlade, frypanHead, signHead, chiselHead }; + + for (int partIter = 0; partIter < partTypes.length; partIter++) + { + for (int typeIter = 0; typeIter < validTypes.length; typeIter++) + { + tinkerHouseChest.addItem(new WeightedRandomChestContent(new ItemStack(partTypes[partIter], 1, validTypes[typeIter]), 1, 1, 15)); + } + } + + tinkerHousePatterns = new ChestGenHooks("TinkerPatterns", new WeightedRandomChestContent[0], 5, 30); + for (int i = 0; i < 13; i++) + { + tinkerHousePatterns.addItem(new WeightedRandomChestContent(new ItemStack(woodPattern, 1, i + 1), 1, 3, 20)); + } + tinkerHousePatterns.addItem(new WeightedRandomChestContent(new ItemStack(woodPattern, 1, 22), 1, 3, 40)); + } + + public static String[] liquidNames; + + public void oreRegistry () + { + OreDictionary.registerOre("oreCobalt", new ItemStack(oreSlag, 1, 1)); + OreDictionary.registerOre("oreArdite", new ItemStack(oreSlag, 1, 2)); + OreDictionary.registerOre("oreCopper", new ItemStack(oreSlag, 1, 3)); + OreDictionary.registerOre("oreTin", new ItemStack(oreSlag, 1, 4)); + OreDictionary.registerOre("oreNaturalAluminum", new ItemStack(oreSlag, 1, 5)); + + OreDictionary.registerOre("oreIron", new ItemStack(oreGravel, 1, 0)); + OreDictionary.registerOre("oreGold", new ItemStack(oreGravel, 1, 1)); + OreDictionary.registerOre("oreCobalt", new ItemStack(oreGravel, 1, 5)); + OreDictionary.registerOre("oreCopper", new ItemStack(oreGravel, 1, 2)); + OreDictionary.registerOre("oreTin", new ItemStack(oreGravel, 1, 3)); + OreDictionary.registerOre("oreNaturalAluminum", new ItemStack(oreGravel, 1, 4)); + + OreDictionary.registerOre("ingotCobalt", new ItemStack(materials, 1, 3)); + OreDictionary.registerOre("ingotArdite", new ItemStack(materials, 1, 4)); + OreDictionary.registerOre("ingotManyullyn", new ItemStack(materials, 1, 5)); + OreDictionary.registerOre("ingotCopper", new ItemStack(materials, 1, 9)); + OreDictionary.registerOre("ingotTin", new ItemStack(materials, 1, 10)); + OreDictionary.registerOre("ingotNaturalAluminum", new ItemStack(materials, 1, 11)); + OreDictionary.registerOre("naturalAluminum", new ItemStack(materials, 1, 12)); + OreDictionary.registerOre("ingotBronze", new ItemStack(materials, 1, 13)); + OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(materials, 1, 14)); + OreDictionary.registerOre("ingotAlumite", new ItemStack(materials, 1, 15)); + OreDictionary.registerOre("ingotSteel", new ItemStack(materials, 1, 16)); + + OreDictionary.registerOre("blockCobalt", new ItemStack(metalBlock, 1, 0)); + OreDictionary.registerOre("blockArdite", new ItemStack(metalBlock, 1, 1)); + OreDictionary.registerOre("blockManyullyn", new ItemStack(metalBlock, 1, 2)); + OreDictionary.registerOre("blockCopper", new ItemStack(metalBlock, 1, 3)); + OreDictionary.registerOre("blockBronze", new ItemStack(metalBlock, 1, 4)); + OreDictionary.registerOre("blockTin", new ItemStack(metalBlock, 1, 5)); + OreDictionary.registerOre("blockNaturalAluminum", new ItemStack(metalBlock, 1, 6)); + OreDictionary.registerOre("blockAluminumBrass", new ItemStack(metalBlock, 1, 7)); + OreDictionary.registerOre("blockAlumite", new ItemStack(metalBlock, 1, 8)); + OreDictionary.registerOre("blockSteel", new ItemStack(metalBlock, 1, 9)); + + OreDictionary.registerOre("nuggetCopper", new ItemStack(materials, 1, 20)); + OreDictionary.registerOre("nuggetTin", new ItemStack(materials, 1, 21)); + OreDictionary.registerOre("nuggetNaturalAluminum", new ItemStack(materials, 1, 22)); + OreDictionary.registerOre("nuggetAluminumBrass", new ItemStack(materials, 1, 24)); + OreDictionary.registerOre("nuggetObsidian", new ItemStack(materials, 1, 27)); + OreDictionary.registerOre("nuggetCobalt", new ItemStack(materials, 1, 28)); + OreDictionary.registerOre("nuggetArdite", new ItemStack(materials, 1, 29)); + OreDictionary.registerOre("nuggetManyullyn", new ItemStack(materials, 1, 30)); + OreDictionary.registerOre("nuggetBronze", new ItemStack(materials, 1, 31)); + OreDictionary.registerOre("nuggetAlumite", new ItemStack(materials, 1, 32)); + OreDictionary.registerOre("nuggetSteel", new ItemStack(materials, 1, 33)); + + String[] glassTypes = { "glassBlack", "glassRed", "glassGreen", "glassBrown", "glassBlue", "glassPurple", "glassCyan", "glassLightGray", "glassGray", "glassPink", "glassLime", "glassYellow", + "glassLightBlue", "glassMagenta", "glassOrange", "glassWhite" }; + for (int i = 0; i < 16; i++) + { + OreDictionary.registerOre(glassTypes[15 - i], new ItemStack(stainedGlassClear, 1, i)); + } + + BlockDispenser.dispenseBehaviorRegistry.putObject(titleIcon, new TDispenserBehaviorSpawnEgg()); + + //Vanilla stuff + OreDictionary.registerOre("slimeball", new ItemStack(Item.slimeBall)); + OreDictionary.registerOre("slimeball", new ItemStack(strangeFood, 1, 0)); + RecipeRemover.removeShapedRecipe(new ItemStack(Block.pistonStickyBase)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.magmaCream)); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Block.pistonStickyBase), "slimeball", Block.pistonBase)); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Item.magmaCream), "slimeball", Item.blazePowder)); + } + + public static boolean thaumcraftAvailable; + + public void intermodCommunication () + { + FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(oreBerry, 1, 12)); + FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(oreBerry, 1, 13)); + FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(oreBerry, 1, 14)); + FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(oreBerry, 1, 15)); + FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(oreBerrySecond, 1, 12)); + FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(oreBerrySecond, 1, 13)); + + /* FORESTRY + * Edit these strings to change what items are added to the backpacks + * Format info: "[backpack ID]@[item ID].[metadata or *]:[next item]" and so on + * Avaliable backpack IDs: forester, miner, digger, hunter, adventurer, builder + * May add more backpack items later - Spyboticsguy + */ + + String builderItems = "builder@" + String.valueOf(stoneTorch.blockID) + ":*"; + + FMLInterModComms.sendMessage("Forestry", "add-backpack-items", builderItems); + } + + private static boolean initRecipes; + + public static void modRecipes () + { + if (!initRecipes) + { + initRecipes = true; + if (PHConstruct.removeVanillaToolRecipes) + { + RecipeRemover.removeShapedRecipe(new ItemStack(Item.pickaxeWood)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.axeWood)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.shovelWood)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.hoeWood)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.swordWood)); + + RecipeRemover.removeShapedRecipe(new ItemStack(Item.pickaxeStone)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.axeStone)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.shovelStone)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.hoeStone)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.swordStone)); + + RecipeRemover.removeShapedRecipe(new ItemStack(Item.pickaxeIron)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.axeIron)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.shovelIron)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.hoeIron)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.swordIron)); + + RecipeRemover.removeShapedRecipe(new ItemStack(Item.pickaxeDiamond)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.axeDiamond)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.shovelDiamond)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.hoeDiamond)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.swordDiamond)); + + RecipeRemover.removeShapedRecipe(new ItemStack(Item.pickaxeGold)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.axeGold)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.shovelGold)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.hoeGold)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.swordGold)); + } + else if (PHConstruct.deGreg) + { + CraftingManager cm = CraftingManager.getInstance(); + new RecipesTools().addRecipes(cm); + new RecipesWeapons().addRecipes(cm); + } + + if (!PHConstruct.vanillaMetalBlocks) + { + RecipeRemover.removeShapedRecipe(new ItemStack(Block.blockIron)); + RecipeRemover.removeShapedRecipe(new ItemStack(Block.blockGold)); + } + else if (PHConstruct.deGreg) + { + String[] blockPattern = new String[] { "###", "###", "###" }; + GameRegistry.addRecipe(new ItemStack(Block.blockIron), blockPattern, '#', new ItemStack(Item.ingotIron)); + GameRegistry.addRecipe(new ItemStack(Block.blockGold), blockPattern, '#', new ItemStack(Item.ingotGold)); + GameRegistry.addRecipe(new ItemStack(Block.blockDiamond), blockPattern, '#', new ItemStack(Item.diamond)); + GameRegistry.addRecipe(new ItemStack(Block.blockLapis), blockPattern, '#', new ItemStack(Item.dyePowder, 1, 4)); + GameRegistry.addRecipe(new ItemStack(Block.blockEmerald), blockPattern, '#', new ItemStack(Item.emerald)); + GameRegistry.addRecipe(new ItemStack(Block.blockRedstone), blockPattern, '#', new ItemStack(Item.redstone)); + GameRegistry.addRecipe(new ItemStack(Block.blockNetherQuartz, 1), "##", "##", '#', Item.netherQuartz); + } + + if (PHConstruct.deGreg) + { + GameRegistry.addRecipe(new ItemStack(Item.flintAndSteel, 1), "A ", " B", 'A', Item.ingotIron, 'B', Item.flint); + List recipes = CraftingManager.getInstance().getRecipeList(); + addShapedRecipeFirst(recipes, new ItemStack(Block.planks, 4, 0), "#", '#', new ItemStack(Block.wood, 1, 0)); + addShapedRecipeFirst(recipes, new ItemStack(Block.planks, 4, 1), "#", '#', new ItemStack(Block.wood, 1, 1)); + addShapedRecipeFirst(recipes, new ItemStack(Block.planks, 4, 2), "#", '#', new ItemStack(Block.wood, 1, 2)); + addShapedRecipeFirst(recipes, new ItemStack(Block.planks, 4, 3), "#", '#', new ItemStack(Block.wood, 1, 3)); + addShapedRecipeFirst(recipes, new ItemStack(Item.stick, 4), "#", "#", '#', new ItemStack(Block.wood, 1, 0)); + addShapedRecipeFirst(recipes, new ItemStack(Item.stick, 4), "#", "#", '#', new ItemStack(Block.wood, 1, 1)); + addShapedRecipeFirst(recipes, new ItemStack(Item.stick, 4), "#", "#", '#', new ItemStack(Block.wood, 1, 2)); + addShapedRecipeFirst(recipes, new ItemStack(Item.stick, 4), "#", "#", '#', new ItemStack(Block.wood, 1, 3)); + addShapedRecipeFirst(recipes, new ItemStack(Item.bucketEmpty), "# #", " # ", '#', new ItemStack(Item.ingotIron)); + } + } + } + + public static void addShapedRecipeFirst (List recipeList, ItemStack itemstack, Object... objArray) + { + String var3 = ""; + int var4 = 0; + int var5 = 0; + int var6 = 0; + + if (objArray[var4] instanceof String[]) + { + String[] var7 = (String[]) ((String[]) objArray[var4++]); + + for (int var8 = 0; var8 < var7.length; ++var8) + { + String var9 = var7[var8]; + ++var6; + var5 = var9.length(); + var3 = var3 + var9; + } + } + else + { + while (objArray[var4] instanceof String) + { + String var11 = (String) objArray[var4++]; + ++var6; + var5 = var11.length(); + var3 = var3 + var11; + } + } + + HashMap var12; + + for (var12 = new HashMap(); var4 < objArray.length; var4 += 2) + { + Character var13 = (Character) objArray[var4]; + ItemStack var14 = null; + + if (objArray[var4 + 1] instanceof Item) + { + var14 = new ItemStack((Item) objArray[var4 + 1]); + } + else if (objArray[var4 + 1] instanceof Block) + { + var14 = new ItemStack((Block) objArray[var4 + 1], 1, Short.MAX_VALUE); + } + else if (objArray[var4 + 1] instanceof ItemStack) + { + var14 = (ItemStack) objArray[var4 + 1]; + } + + var12.put(var13, var14); + } + + ItemStack[] var15 = new ItemStack[var5 * var6]; + + for (int var16 = 0; var16 < var5 * var6; ++var16) + { + char var10 = var3.charAt(var16); + + if (var12.containsKey(Character.valueOf(var10))) + { + var15[var16] = ((ItemStack) var12.get(Character.valueOf(var10))).copy(); + } + else + { + var15[var16] = null; + } + } + + ShapedRecipes var17 = new ShapedRecipes(var5, var6, var15, itemstack); + recipeList.add(0, var17); + } + + public void modIntegration () + { + ItemStack ironpick = ToolBuilder.instance.buildTool(new ItemStack(TContent.pickaxeHead, 1, 6), new ItemStack(TContent.toolRod, 1, 2), new ItemStack(TContent.binding, 1, 6), ""); + /* IC2 */ + ItemStack reBattery = ic2.api.item.Items.getItem("reBattery"); + if (reBattery != null) + modE.batteries.add(reBattery); + ItemStack chargedReBattery = ic2.api.item.Items.getItem("chargedReBattery"); + if (chargedReBattery != null) + { + modE.batteries.add(chargedReBattery); + } + ItemStack electronicCircuit = ic2.api.item.Items.getItem("electronicCircuit"); + if (electronicCircuit != null) + modE.circuits.add(electronicCircuit); + + if (chargedReBattery != null && electronicCircuit != null) + TConstructClientRegistry.registerManualModifier("electricmod", ironpick.copy(), chargedReBattery, electronicCircuit); + + /* Thaumcraft */ + Object obj = getStaticItem("itemResource", "thaumcraft.common.Config"); + if (obj != null) + { + System.out.println("[TConstruct] Thaumcraft detected. Adding thaumium tools."); + thaumcraftAvailable = true; + TConstructClientRegistry.addMaterialRenderMapping(31, "tinker", "thaumium", true); + TConstructRegistry.addToolMaterial(31, "Thaumium", 3, 400, 700, 2, 1.3F, 0, 0f, "\u00A75", "Thaumic"); + PatternBuilder.instance.registerFullMaterial(new ItemStack((Item) obj, 1, 2), 2, "Thaumium", new ItemStack(toolShard, 1, 31), new ItemStack(toolRod, 1, 31), 31); + for (int meta = 0; meta < patternOutputs.length; meta++) + { + if (patternOutputs[meta] != null) + TConstructRegistry.addPartMapping(woodPattern.itemID, meta + 1, 31, new ItemStack(patternOutputs[meta], 1, 31)); + } + + TConstructRegistry.addBowstringMaterial(1, 2, new ItemStack((Item) obj, 1, 7), new ItemStack(bowstring, 1, 1), 1F, 1F, 0.9f); + TConstructRegistry.addBowMaterial(31, 576, 40, 1.2f); + TConstructRegistry.addArrowMaterial(31, 1.8F, 0.5F, 100F); + } + else + { + System.out.println("[TConstruct] Thaumcraft not detected."); + } + } + + public static Object getStaticItem (String name, String classPackage) + { + try + { + Class clazz = Class.forName(classPackage); + Field field = clazz.getDeclaredField(name); + Object ret = field.get(null); + if (ret != null && (ret instanceof ItemStack || ret instanceof Item)) + return ret; + return null; + } + catch (Exception e) + { + //System.out.println("[TConstruct] Could not find " + name); + return null; + } + } + + @Override + public int getBurnTime (ItemStack fuel) + { + if (fuel.itemID == materials.itemID && fuel.getItemDamage() == 7) + return 26400; + return 0; + } +} \ No newline at end of file diff --git a/tconstruct/common/TProxyCommon.java b/tconstruct/common/TProxyCommon.java new file mode 100644 index 00000000..f70cd481 --- /dev/null +++ b/tconstruct/common/TProxyCommon.java @@ -0,0 +1,234 @@ +package tconstruct.common; + +import tconstruct.TConstruct; +import tconstruct.entity.MiniGardy; +import tconstruct.inventory.ArmorExtendedContainer; +import tconstruct.inventory.KnapsackContainer; +import tconstruct.inventory.MiniGardyContainer; +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.util.player.TPlayerStats; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.registry.LanguageRegistry; + +/** + * Common proxy class for InfiTools + */ + +public class TProxyCommon implements IGuiHandler +{ + public static int stationGuiID = 0; + public static int partGuiID = 1; + public static int pchestGuiID = 2; + public static int pshaperGuiID = 3; + public static int frypanGuiID = 4; + public static int toolForge = 5; + public static int smelteryGuiID = 7; + public static int glowstoneAggregatorGui = 8; + public static int drawbridgeGui = 9; + + public static int inventoryGui = 100; + public static int armorGuiID = 101; + public static int knapsackGuiID = 102; + + public static int miniGardyGui = 131; + + public static int manualGuiID = -1; + + @Override + public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) + { + if (ID < 0) + return null; + + else if (ID < 100) + { + TileEntity tile = world.getBlockTileEntity(x, y, z); + if (tile != null && tile instanceof InventoryLogic) + { + return ((InventoryLogic) tile).getGuiContainer(player.inventory, world, x, y, z); + } + } + else + { + if (ID == inventoryGui) + { + //GuiInventory inv = new GuiInventory(player); + return player.inventoryContainer; + } + if (ID == armorGuiID) + { + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + return new ArmorExtendedContainer(player.inventory, stats.armor); + } + if (ID == knapsackGuiID) + { + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + return new KnapsackContainer(player.inventory, stats.knapsack); + } + if (ID == miniGardyGui) + { + for (Object o : world.loadedEntityList) + { + Entity entity = (Entity) o; + if (entity.entityId == x) + { + return new MiniGardyContainer(player.inventory, (MiniGardy) entity); + } + } + return null; + } + } + return null; + } + + @Override + public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) + { + // TODO Auto-generated method stub + return null; + } + + public void registerTickHandler () + { + //TickRegistry.registerTickHandler(new TimeTicker(), Side.SERVER); + } + + /* Registers any rendering code. Does nothing server-side */ + public void registerRenderer () + { + } + + /* Ties an internal name to a visible one. */ + public void addNames () + { + + String langDir = "/assets/tinker/lang/"; + String[] langFiles = { "en_US.xml" }; + + for (String langFile : langFiles) + { + try + { + LanguageRegistry.instance().loadLocalization(langDir + langFile, langFile.substring(langFile.lastIndexOf('/') + 1, langFile.lastIndexOf('.')), true); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + for (int mat = 0; mat < materialTypes.length; mat++) + { + for (int type = 0; type < toolMaterialNames.length; type++) + { + String internalName = new StringBuilder().append("item.tconstruct.").append(materialTypes[mat]).append(".").append(toolMaterialNames[type]).append(".name").toString(); + String visibleName = new StringBuilder().append(toolMaterialNames[type]).append(materialNames[mat]).toString(); + LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName); + } + } + + for (int i = 0; i < shardNames.length; i++) + { + String internalName = "item.tconstruct.ToolShard." + toolMaterialNames[i] + ".name"; + String visibleName = shardNames[i]; + LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName); + } + + /*for (int i = 0; i < materialItemNames.length; i++) + { + String internalName = "item.tconstruct.Materials." + materialItemInternalNames[i] + ".name"; + String visibleName = materialItemNames[i]; + LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName); + }*/ + + for (int i = 0; i < patterns.length; i++) + { + String internalName = "item.tconstruct.Pattern." + patterns[i] + ".name"; + String visibleName = patternNames[i] + " Pattern"; + LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName); + internalName = "item.tconstruct.MetalPattern." + patterns[i] + ".name"; + visibleName = patternNames[i] + " Cast"; + LanguageRegistry.instance().addStringLocalization(internalName, "en_US", visibleName); + } + + //LanguageRegistry.addName(TContent.manualBook, "Tinker's Log"); + + //LanguageRegistry.instance().addStringLocalization("entity.TConstruct.UnstableCreeper.name", "en_US", "Nitro Creeper"); + //LanguageRegistry.instance().addStringLocalization("entity.TConstruct.EdibleSlime.name", "en_US", "Blue Slime"); + //LanguageRegistry.instance().addStringLocalization("entity.TConstruct.MetalSlime.name", "en_US", "Metal Slime"); + //LanguageRegistry.instance().addStringLocalization("item.tconstruct.diary.diary.name", "en_US", "Tinker's Log"); + LanguageRegistry.instance().addStringLocalization("item.tconstruct.Pattern.blank_pattern.name", "en_US", "Blank Pattern"); + LanguageRegistry.instance().addStringLocalization("item.tconstruct.Pattern.blank_cast.name", "en_US", "Blank Cast"); + //LanguageRegistry.addName(TContent.blankPattern, "Blank Pattern"); + LanguageRegistry.addName(TContent.pickaxe, "Pickaxe"); + LanguageRegistry.addName(TContent.shovel, "Shovel"); + LanguageRegistry.addName(TContent.hatchet, "Hatchet"); + LanguageRegistry.addName(TContent.broadsword, "Broadsword"); + LanguageRegistry.addName(TContent.longsword, "Longsword"); + LanguageRegistry.addName(TContent.rapier, "Rapier"); + LanguageRegistry.addName(TContent.frypan, "Frying Pan"); + LanguageRegistry.addName(TContent.battlesign, "Battlesign"); + LanguageRegistry.addName(TContent.mattock, "Mattock"); + LanguageRegistry.addName(TContent.potionLauncher, "Potion Launcher"); + LanguageRegistry.addName(TContent.dagger, "Dagger"); + LanguageRegistry.addName(TContent.chisel, "Chisel"); + LanguageRegistry.addName(TContent.scythe, "Scythe"); + LanguageRegistry.addName(TContent.lumberaxe, "Lumber Axe"); + LanguageRegistry.addName(TContent.cleaver, "Cleaver"); + LanguageRegistry.addName(TContent.excavator, "Excavator"); + LanguageRegistry.addName(TContent.hammer, "Hammer"); + LanguageRegistry.addName(TContent.battleaxe, "Battleaxe"); + LanguageRegistry.addName(TContent.cutlass, "Cutlass"); + LanguageRegistry.addName(TContent.aggregator, "Glowstone Aggregator"); + LanguageRegistry.addName(TContent.lightCrystalBase, "Lightstone Crystal"); + LanguageRegistry.addName(TContent.knapsack, "Knapsack"); + LanguageRegistry.addName(TContent.shortbow, "Shortbow"); + LanguageRegistry.addName(TContent.arrow, "Arrow"); + + } + + public void readManuals () + { + } + + public void registerKeys () + { + } + + public void spawnParticle (String slimeParticle, double xPos, double yPos, double zPos, double velX, double velY, double velZ) + { + } + + public static final String[] shardNames = new String[] { "Wood", "Stone Shard", "Iron Chunk", "Flint Shard", "Cactus Shard", "Bone", "Obsidian Shard", "Netherrack Shard", + "Slime Crystal Fragment", "Paper", "Cobalt Chunk", "Ardite Chunk", "Manyullyn Chunk", "Copper Chunk", "Bronze Chunk", "Alumite Chunk", "Steel Chunk", "Slime Crystal Fragment" }; + + /*public static final String[] materialItemInternalNames = new String[] { + "IronNugget", + "CopperNugget", "TinNugget", "AluminumNugget", "SilverNugget" }; + + public static final String[] materialItemNames = new String[] { + "Iron Nugget", + "Copper Nugget", "Tin Nugget", "Aluminum Nugget", "Silver Nugget" };*/ + + public static final String[] toolMaterialNames = new String[] { "Wood", "Stone", "Iron", "Flint", "Cactus", "Bone", "Obsidian", "Netherrack", "Slime", "Paper", "Cobalt", "Ardite", "Manyullyn", + "Copper", "Bronze", "Alumite", "Steel", "Blue Slime", "", "", "", "", "", "", "", "", "", "", "", "", "", "Thaumium" }; + + public static final String[] materialTypes = new String[] { "ToolRod", "PickaxeHead", "ShovelHead", "AxeHead", "SwordBlade", "LargeGuard", "MediumGuard", "Crossbar", "Binding", "FrypanHead", + "SignHead", "LumberHead", "KnifeBlade", "ChiselHead", "ScytheBlade", "LumberHead", "ThickRod", "ThickBinding", "LargeSwordBlade", "LargePlate", "ExcavatorHead", "HammerHead", "FullGuard", + "Bowstring", "Fletching", "Arrowhead" }; + + public static final String[] materialNames = new String[] { " Rod", " Pickaxe Head", " Shovel Head", " Axe Head", " Sword Blade", " Wide Guard", " Hand Guard", " Crossbar", " Binding", " Pan", + " Board", " Broad Axe Head", " Knife Blade", " Chisel Head", " Scythe Blade", " Broad Axe Head", " Tough Tool Rod", " Tough Binding", " Large Sword Blade", " Large Plate", + " Excavator Head", " Hammer Head", " Full Guard", " Bowstring", " Fletching", " Arrowhead" }; + + public static final String[] patterns = new String[] { "ingot", "rod", "pickaxe", "shovel", "axe", "swordblade", "largeguard", "mediumguard", "crossbar", "binding", "frypan", "sign", + "knifeblade", "chisel", "largerod", "toughbinding", "largeplate", "broadaxe", "scythe", "excavator", "largeblade", "hammerhead", "fullguard", "bowstring", "fletching", "arrowhead" }; + + public static final String[] patternNames = new String[] { "Ingot", "Tool Rod", "Pickaxe Head", "Shovel Head", "Axe Head", "Sword Blade", "Wide Guard", "Hand Guard", "Crossbar", "Tool Binding", + "Pan", "Board", "Knife Blade", "Chisel Head", "Tough Tool Rod", "Tough Binding", "Large Plate", "Broad Axe Head", "Scythe Head", "Broad Shovel Head", "Large Blade", "Hammer Head", + "Full Guard", "Bowstring", "Fletching", "Arrowhead" }; +} diff --git a/tconstruct/common/TimeTicker.java b/tconstruct/common/TimeTicker.java new file mode 100644 index 00000000..9cf6967e --- /dev/null +++ b/tconstruct/common/TimeTicker.java @@ -0,0 +1,42 @@ +package tconstruct.common; + +import java.util.EnumSet; + +import cpw.mods.fml.common.ITickHandler; +import cpw.mods.fml.common.TickType; + +public class TimeTicker implements ITickHandler +{ + public static long time = 0; + public static int tickParts = 0; + public static int seconds = 0; + public static int minutes = 0; + + @Override + public void tickStart (EnumSet type, Object... tickData) + { + System.out.println("Tick"); + time++; + tickParts = (int) (time % 20); + seconds = (int) (time / 20); + minutes = (int) (time / 1200); + } + + @Override + public void tickEnd (EnumSet type, Object... tickData) + { + } + + @Override + public EnumSet ticks () + { + return EnumSet.of(TickType.WORLD); + } + + @Override + public String getLabel () + { + return null; + } + +} diff --git a/tconstruct/crystal/TheftValueTracker.java b/tconstruct/crystal/TheftValueTracker.java new file mode 100644 index 00000000..b26d0b34 --- /dev/null +++ b/tconstruct/crystal/TheftValueTracker.java @@ -0,0 +1,44 @@ +package tconstruct.crystal; + +import java.util.HashMap; + +import tconstruct.library.util.ValueCoordTuple; + + + + +public class TheftValueTracker +{ + public static HashMap crystallinity = new HashMap(); + + //public static HashMap> crystallinity = new HashMap>(); + + public static void updateCrystallinity (int dim, int posX, int posZ, int value) + { + ValueCoordTuple coord = new ValueCoordTuple(dim, posX / 16, posZ / 16); + int crystal = crystallinity.get(coord); + crystal += value; + crystallinity.put(coord, crystal); + /*ChunkCoordTuple tuple = new ChunkCoordTuple(posX / 16, posZ / 16); + HashMap dimensionMap = crystallinity.get(world); + if (dimensionMap.containsKey(tuple)) + { + int level = dimensionMap.get(tuple); + level += value; + dimensionMap.put(tuple, level); + } + else + { + System.out.println("[TConstruct] Missing Theft value data at "+tuple); + + HashMap crystalMap = TheftValueTracker.crystallinity.get(world); + if (crystalMap == null) + { + crystalMap = new HashMap(); + TheftValueTracker.crystallinity.put(world, crystalMap); + } + crystalMap.put(tuple, value); + + }*/ + } +} diff --git a/tconstruct/dimension/TinkerChunkManager.java b/tconstruct/dimension/TinkerChunkManager.java new file mode 100644 index 00000000..8f69dabd --- /dev/null +++ b/tconstruct/dimension/TinkerChunkManager.java @@ -0,0 +1,117 @@ +package tconstruct.dimension; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; + +public class TinkerChunkManager extends WorldChunkManager +{ + /** The biome generator object. */ + private BiomeGenBase biomeGenerator; + private float hellTemperature; + + /** The rainfall in the world */ + private float rainfall; + + public TinkerChunkManager(BiomeGenBase par1BiomeGenBase, float par2, float par3) + { + this.biomeGenerator = par1BiomeGenBase; + this.hellTemperature = par2; + this.rainfall = par3; + } + + /** + * Returns the BiomeGenBase related to the x, z position on the world. + */ + public BiomeGenBase getBiomeGenAt (int par1, int par2) + { + return this.biomeGenerator; + } + + /** + * Returns an array of biomes for the location input. + */ + public BiomeGenBase[] getBiomesForGeneration (BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) + { + if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) + { + par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; + } + + Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, this.biomeGenerator); + return par1ArrayOfBiomeGenBase; + } + + /** + * Returns a list of temperatures to use for the specified blocks. Args: listToReuse, x, y, width, length + */ + public float[] getTemperatures (float[] par1ArrayOfFloat, int par2, int par3, int par4, int par5) + { + if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5) + { + par1ArrayOfFloat = new float[par4 * par5]; + } + + Arrays.fill(par1ArrayOfFloat, 0, par4 * par5, this.hellTemperature); + return par1ArrayOfFloat; + } + + /** + * Returns a list of rainfall values for the specified blocks. Args: listToReuse, x, z, width, length. + */ + public float[] getRainfall (float[] par1ArrayOfFloat, int par2, int par3, int par4, int par5) + { + if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5) + { + par1ArrayOfFloat = new float[par4 * par5]; + } + + Arrays.fill(par1ArrayOfFloat, 0, par4 * par5, this.rainfall); + return par1ArrayOfFloat; + } + + /** + * Returns biomes to use for the blocks and loads the other data like temperature and humidity onto the + * WorldChunkManager Args: oldBiomeList, x, z, width, depth + */ + public BiomeGenBase[] loadBlockGeneratorData (BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) + { + if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) + { + par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; + } + + Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, this.biomeGenerator); + return par1ArrayOfBiomeGenBase; + } + + /** + * Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false, + * don't check biomeCache to avoid infinite loop in BiomeCacheBlock) + */ + public BiomeGenBase[] getBiomeGenAt (BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5, boolean par6) + { + return this.loadBlockGeneratorData(par1ArrayOfBiomeGenBase, par2, par3, par4, par5); + } + + /** + * Finds a valid position within a range, that is in one of the listed biomes. Searches {par1,par2} +-par3 blocks. + * Strongly favors positive y positions. + */ + public ChunkPosition findBiomePosition (int par1, int par2, int par3, List par4List, Random par5Random) + { + return par4List.contains(this.biomeGenerator) ? new ChunkPosition(par1 - par3 + par5Random.nextInt(par3 * 2 + 1), 0, par2 - par3 + par5Random.nextInt(par3 * 2 + 1)) : null; + } + + /** + * checks given Chunk's Biomes against List of allowed ones + */ + public boolean areBiomesViable (int par1, int par2, int par3, List par4List) + { + return par4List.contains(this.biomeGenerator); + } +} diff --git a/tconstruct/dimension/TinkerChunkProvider.java b/tconstruct/dimension/TinkerChunkProvider.java new file mode 100644 index 00000000..09dfcfbd --- /dev/null +++ b/tconstruct/dimension/TinkerChunkProvider.java @@ -0,0 +1,556 @@ +package tconstruct.dimension; + +import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_BRIDGE; +import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_CAVE; + +import java.util.List; +import java.util.Random; + +import mods.natura.dimension.NetheriteChunk; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSand; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.MapGenBase; +import net.minecraft.world.gen.MapGenCavesHell; +import net.minecraft.world.gen.NoiseGeneratorOctaves; +import net.minecraft.world.gen.structure.MapGenNetherBridge; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.Event.Result; +import net.minecraftforge.event.terraingen.ChunkProviderEvent; +import net.minecraftforge.event.terraingen.TerrainGen; + +public class TinkerChunkProvider implements IChunkProvider +{ + private Random hellRNG; + + /** A NoiseGeneratorOctaves used in generating nether terrain */ + private NoiseGeneratorOctaves netherNoiseGen1; + private NoiseGeneratorOctaves netherNoiseGen2; + private NoiseGeneratorOctaves netherNoiseGen3; + + /** Determines whether slowsand or gravel can be generated at a location */ + private NoiseGeneratorOctaves slowsandGravelNoiseGen; + + /** + * Determines whether something other than nettherack can be generated at a location + */ + private NoiseGeneratorOctaves netherrackExculsivityNoiseGen; + public NoiseGeneratorOctaves netherNoiseGen4; + public NoiseGeneratorOctaves netherNoiseGen5; + + /** Is the world that the nether is getting generated. */ + private World worldObj; + private double[] noiseField; + private double[] secondNoiseField; + public MapGenNetherBridge genNetherBridge = new MapGenNetherBridge(); + + /** + * Holds the noise used to determine whether slowsand can be generated at a location + */ + private double[] slowsandNoise = new double[256]; + private double[] gravelNoise = new double[256]; + + /** + * Holds the noise used to determine whether something other than netherrack can be generated at a location + */ + private double[] netherrackExclusivityNoise = new double[256]; + private MapGenBase netherCaveGenerator = new MapGenCavesHell(); + double[] noiseData1; + double[] noiseData2; + double[] noiseData3; + double[] noiseData4; + double[] noiseData5; + + double[] secondNoiseData1; + double[] secondNoiseData2; + double[] secondNoiseData3; + double[] secondNoiseData4; + double[] secondNoiseData5; + + { + genNetherBridge = (MapGenNetherBridge) TerrainGen.getModdedMapGen(genNetherBridge, NETHER_BRIDGE); + netherCaveGenerator = TerrainGen.getModdedMapGen(netherCaveGenerator, NETHER_CAVE); + } + + public TinkerChunkProvider(World par1World, long par2) + { + this.worldObj = par1World; + this.hellRNG = new Random(par2); + this.netherNoiseGen1 = new NoiseGeneratorOctaves(this.hellRNG, 16); + this.netherNoiseGen2 = new NoiseGeneratorOctaves(this.hellRNG, 16); + this.netherNoiseGen3 = new NoiseGeneratorOctaves(this.hellRNG, 8); + this.slowsandGravelNoiseGen = new NoiseGeneratorOctaves(this.hellRNG, 4); + this.netherrackExculsivityNoiseGen = new NoiseGeneratorOctaves(this.hellRNG, 4); + this.netherNoiseGen4 = new NoiseGeneratorOctaves(this.hellRNG, 10); + this.netherNoiseGen5 = new NoiseGeneratorOctaves(this.hellRNG, 16); + + NoiseGeneratorOctaves[] noiseGens = { netherNoiseGen1, netherNoiseGen2, netherNoiseGen3, slowsandGravelNoiseGen, netherrackExculsivityNoiseGen, netherNoiseGen4, netherNoiseGen5 }; + noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.hellRNG, noiseGens); + this.netherNoiseGen1 = noiseGens[0]; + this.netherNoiseGen2 = noiseGens[1]; + this.netherNoiseGen3 = noiseGens[2]; + this.slowsandGravelNoiseGen = noiseGens[3]; + this.netherrackExculsivityNoiseGen = noiseGens[4]; + this.netherNoiseGen4 = noiseGens[5]; + this.netherNoiseGen5 = noiseGens[6]; + } + + /** + * Generates the shape of the terrain in the nether. + */ + public void generateNetherTerrain (int chunkX, int chunkZ, byte[] lowerIDs) + { + byte noiseInit = 4; + byte b1 = 32; + int k = noiseInit + 1; + byte b2 = 17; + int l = noiseInit + 1; + this.noiseField = this.initializeNoiseField(this.noiseField, chunkX * noiseInit, 0, chunkZ * noiseInit, k, b2, l); + + for (int iterX = 0; iterX < noiseInit; ++iterX) + { + for (int iterZ = 0; iterZ < noiseInit; ++iterZ) + { + for (int iterY = 0; iterY < 16; ++iterY) + { + double noiseOffset = 0.125D; + double n1 = this.noiseField[((iterX + 0) * l + iterZ + 0) * b2 + iterY + 0]; + double n2 = this.noiseField[((iterX + 0) * l + iterZ + 1) * b2 + iterY + 0]; + double n3 = this.noiseField[((iterX + 1) * l + iterZ + 0) * b2 + iterY + 0]; + double n4 = this.noiseField[((iterX + 1) * l + iterZ + 1) * b2 + iterY + 0]; + double n5 = (this.noiseField[((iterX + 0) * l + iterZ + 0) * b2 + iterY + 1] - n1) * noiseOffset; + double n6 = (this.noiseField[((iterX + 0) * l + iterZ + 1) * b2 + iterY + 1] - n2) * noiseOffset; + double n7 = (this.noiseField[((iterX + 1) * l + iterZ + 0) * b2 + iterY + 1] - n3) * noiseOffset; + double n8 = (this.noiseField[((iterX + 1) * l + iterZ + 1) * b2 + iterY + 1] - n4) * noiseOffset; + + for (int offsetY = 0; offsetY < 8; ++offsetY) + { + double d9 = 0.25D; + double d10 = n1; + double d11 = n2; + double d12 = (n3 - n1) * d9; + double d13 = (n4 - n2) * d9; + + for (int offsetX = 0; offsetX < 4; ++offsetX) + { + int layerPos = offsetX + iterX * 4 << 11 | 0 + iterZ * 4 << 7 | iterY * 8 + offsetY; + short amountPerLayer = 128; + double d14 = 0.25D; + double lValue = d10; + double lOffset = (d11 - d10) * d14; + + for (int k2 = 0; k2 < 4; ++k2) + { + int blockID = 0; + + /*if (iterY * 8 + offsetY < b1) + { + blockID = Block.lavaStill.blockID; + }*/ + + if (lValue < 0.0D) + { + blockID = Block.dirt.blockID; + } + + if (lValue < -56.0D) + { + blockID = Block.grass.blockID; + } + + lowerIDs[layerPos] = (byte) blockID; + layerPos += amountPerLayer; + lValue += lOffset; + } + + d10 += d12; + d11 += d13; + } + + n1 += n5; + n2 += n6; + n3 += n7; + n4 += n8; + } + } + } + } + } + + public void replaceBlocksForBiome (int par1, int par2, byte[] lowerIDs) + { + //Lower nether + byte seaLevel = 64; + double d0 = 0.03125D; + this.slowsandNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.slowsandNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, d0, d0, 1.0D); + this.gravelNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.gravelNoise, par1 * 16, 109, par2 * 16, 16, 1, 16, d0, 1.0D, d0); + this.netherrackExclusivityNoise = this.netherrackExculsivityNoiseGen.generateNoiseOctaves(this.netherrackExclusivityNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, d0 * 2.0D, d0 * 2.0D, d0 * 2.0D); + + for (int iterX = 0; iterX < 16; ++iterX) + { + for (int iterZ = 0; iterZ < 16; ++iterZ) + { + boolean flag = this.slowsandNoise[iterX + iterZ * 16] + this.hellRNG.nextDouble() * 0.2D > 0.0D; + boolean flag1 = this.gravelNoise[iterX + iterZ * 16] + this.hellRNG.nextDouble() * 0.2D > 0.0D; + int i1 = (int) (this.netherrackExclusivityNoise[iterX + iterZ * 16] / 3.0D + 3.0D + this.hellRNG.nextDouble() * 0.25D); + int j1 = -1; + byte b1 = (byte) Block.dirt.blockID; + byte b2 = (byte) Block.grass.blockID; + + for (int k1 = 127; k1 >= 0; --k1) + { + int l1 = (iterZ * 16 + iterX) * 128 + k1; + + if (k1 > 0 + this.hellRNG.nextInt(5)) + { + short b3 = lowerIDs[l1]; + + if (b3 == 0) + { + j1 = -1; + } + else if (b3 == Block.dirt.blockID) + { + if (j1 == -1) + { + if (i1 <= 0) + { + b1 = 0; + b2 = (byte) Block.dirt.blockID; + } + else if (k1 >= seaLevel - 4 && k1 <= seaLevel + 1) + { + b1 = (byte) Block.dirt.blockID; + b2 = (byte) Block.grass.blockID; + + if (flag1) + { + b1 = (byte) Block.gravel.blockID; + } + + if (flag1) + { + b2 = (byte) Block.dirt.blockID; + } + + if (flag) + { + b1 = (byte) Block.slowSand.blockID; + } + + if (flag) + { + b2 = (byte) Block.stone.blockID; + } + } + + /*if (k1 < seaLevel && b1 == 0) + { + b1 = (byte) Block.lavaStill.blockID; + }*/ + + j1 = i1; + + if (k1 >= seaLevel - 1) + { + lowerIDs[l1] = b1; + } + else + { + lowerIDs[l1] = b2; + } + } + else if (j1 > 0) + { + --j1; + lowerIDs[l1] = b2; + } + } + } + /*else + { + lowerIDs[l1] = (byte)Block.bedrock.blockID; + }*/ + } + } + } + } + + /** + * loads or generates the chunk at the chunk location specified + */ + public Chunk loadChunk (int par1, int par2) + { + return this.provideChunk(par1, par2); + } + + /** + * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the + * specified chunk from the map seed and chunk seed + */ + public Chunk provideChunk (int chunkX, int chunkZ) + { + this.hellRNG.setSeed((long) chunkX * 341873128712L + (long) chunkZ * 132897987541L); + byte[] lowerArray = new byte[32768]; + //byte[] upperArray = new byte[32768]; + this.generateNetherTerrain(chunkX, chunkZ, lowerArray); + this.replaceBlocksForBiome(chunkX, chunkZ, lowerArray); + this.netherCaveGenerator.generate(this, this.worldObj, chunkX, chunkZ, lowerArray); + this.genNetherBridge.generate(this, this.worldObj, chunkX, chunkZ, lowerArray); + Chunk chunk = new NetheriteChunk(this.worldObj, lowerArray, chunkX, chunkZ); + BiomeGenBase[] abiomegenbase = this.worldObj.getWorldChunkManager().loadBlockGeneratorData((BiomeGenBase[]) null, chunkX * 16, chunkZ * 16, 16, 16); + byte[] abyte1 = chunk.getBiomeArray(); + + for (int k = 0; k < abyte1.length; ++k) + { + abyte1[k] = (byte) abiomegenbase[k].biomeID; + } + + chunk.resetRelightChecks(); + return chunk; + } + + /** + * generates a subset of the level's terrain data. Takes 7 arguments: the [empty] noise array, the position, and the + * size. + */ + private double[] initializeNoiseField (double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7) + { + ChunkProviderEvent.InitNoiseField event = new ChunkProviderEvent.InitNoiseField(this, par1ArrayOfDouble, par2, par3, par4, par5, par6, par7); + MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() == Result.DENY) + return event.noisefield; + if (par1ArrayOfDouble == null) + { + par1ArrayOfDouble = new double[par5 * par6 * par7]; + } + + double d0 = 684.412D; + double d1 = 2053.236D; + this.noiseData4 = this.netherNoiseGen4.generateNoiseOctaves(this.noiseData4, par2, par3, par4, par5, 1, par7, 1.0D, 0.0D, 1.0D); + this.noiseData5 = this.netherNoiseGen5.generateNoiseOctaves(this.noiseData5, par2, par3, par4, par5, 1, par7, 100.0D, 0.0D, 100.0D); + this.noiseData1 = this.netherNoiseGen3.generateNoiseOctaves(this.noiseData1, par2, par3, par4, par5, par6, par7, d0 / 80.0D, d1 / 60.0D, d0 / 80.0D); + this.noiseData2 = this.netherNoiseGen1.generateNoiseOctaves(this.noiseData2, par2, par3, par4, par5, par6, par7, d0, d1, d0); + this.noiseData3 = this.netherNoiseGen2.generateNoiseOctaves(this.noiseData3, par2, par3, par4, par5, par6, par7, d0, d1, d0); + int k1 = 0; + int l1 = 0; + double[] adouble1 = new double[par6]; + int i2; + + for (i2 = 0; i2 < par6; ++i2) + { + adouble1[i2] = Math.cos((double) i2 * Math.PI * 6.0D / (double) par6) * 2.0D; + double d2 = (double) i2; + + if (i2 > par6 / 2) + { + d2 = (double) (par6 - 1 - i2); + } + + if (d2 < 4.0D) + { + d2 = 4.0D - d2; + adouble1[i2] -= d2 * d2 * d2 * 10.0D; + } + } + + for (i2 = 0; i2 < par5; ++i2) + { + for (int j2 = 0; j2 < par7; ++j2) + { + double d3 = (this.noiseData4[l1] + 256.0D) / 512.0D; + + if (d3 > 1.0D) + { + d3 = 1.0D; + } + + double d4 = 0.0D; + double d5 = this.noiseData5[l1] / 8000.0D; + + if (d5 < 0.0D) + { + d5 = -d5; + } + + d5 = d5 * 3.0D - 3.0D; + + if (d5 < 0.0D) + { + d5 /= 2.0D; + + if (d5 < -1.0D) + { + d5 = -1.0D; + } + + d5 /= 1.4D; + d5 /= 2.0D; + d3 = 0.0D; + } + else + { + if (d5 > 1.0D) + { + d5 = 1.0D; + } + + d5 /= 6.0D; + } + + d3 += 0.5D; + d5 = d5 * (double) par6 / 16.0D; + ++l1; + + for (int k2 = 0; k2 < par6; ++k2) + { + double d6 = 0.0D; + double d7 = adouble1[k2]; + double d8 = this.noiseData2[k1] / 512.0D; + double d9 = this.noiseData3[k1] / 512.0D; + double d10 = (this.noiseData1[k1] / 10.0D + 1.0D) / 2.0D; + + if (d10 < 0.0D) + { + d6 = d8; + } + else if (d10 > 1.0D) + { + d6 = d9; + } + else + { + d6 = d8 + (d9 - d8) * d10; + } + + d6 -= d7; + double d11; + + if (k2 > par6 - 4) + { + d11 = (double) ((float) (k2 - (par6 - 4)) / 3.0F); + d6 = d6 * (1.0D - d11) + -10.0D * d11; + } + + if ((double) k2 < d4) + { + d11 = (d4 - (double) k2) / 4.0D; + + if (d11 < 0.0D) + { + d11 = 0.0D; + } + + if (d11 > 1.0D) + { + d11 = 1.0D; + } + + d6 = d6 * (1.0D - d11) + -10.0D * d11; + } + + par1ArrayOfDouble[k1] = d6; + ++k1; + } + } + } + + return par1ArrayOfDouble; + } + + /** + * Checks to see if a chunk exists at x, y + */ + public boolean chunkExists (int par1, int par2) + { + return true; + } + + /** + * Populates chunk with ores etc etc + */ + public void populate (IChunkProvider par1IChunkProvider, int par2, int par3) + { + BlockSand.fallInstantly = true; + } + + /** + * Two modes of operation: if passed true, save all Chunks in one go. If passed false, save up to two chunks. + * Return true if all chunks have been saved. + */ + public boolean saveChunks (boolean par1, IProgressUpdate par2IProgressUpdate) + { + return true; + } + + /** + * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk. + */ + public boolean unloadQueuedChunks () + { + return false; + } + + /** + * Returns if the IChunkProvider supports saving. + */ + public boolean canSave () + { + return true; + } + + /** + * Converts the instance data to a readable string. + */ + public String makeString () + { + return "HellRandomLevelSource"; + } + + /** + * Returns a list of creatures of the specified type that can spawn at the given location. + */ + public List getPossibleCreatures (EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) + { + if (par1EnumCreatureType == EnumCreatureType.monster && this.genNetherBridge.hasStructureAt(par2, par3, par4)) + { + return this.genNetherBridge.getSpawnList(); + } + else + { + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4); + return biomegenbase == null ? null : biomegenbase.getSpawnableList(par1EnumCreatureType); + } + } + + /** + * Returns the location of the closest structure of the specified type. If not found returns null. + */ + public ChunkPosition findClosestStructure (World par1World, String par2Str, int par3, int par4, int par5) + { + return null; + } + + public int getLoadedChunkCount () + { + return 0; + } + + public void recreateStructures (int par1, int par2) + { + this.genNetherBridge.generate(this, this.worldObj, par1, par2, (byte[]) null); + } + + @Override + public void func_104112_b () + { + // TODO Auto-generated method stub + + } +} diff --git a/tconstruct/dimension/TinkerWorldProvider.java b/tconstruct/dimension/TinkerWorldProvider.java new file mode 100644 index 00000000..ebf56699 --- /dev/null +++ b/tconstruct/dimension/TinkerWorldProvider.java @@ -0,0 +1,92 @@ +package tconstruct.dimension; + +import net.minecraft.world.WorldProvider; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.IChunkProvider; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class TinkerWorldProvider extends WorldProvider +{ + /** + * creates a new world chunk manager for WorldProvider + */ + public void registerWorldChunkManager () + { + this.worldChunkMgr = new TinkerChunkManager(BiomeGenBase.iceMountains, 1.0F, 0.0F); + this.isHellWorld = true; + this.hasNoSky = true; + this.dimensionId = -7; + } + + /** + * Creates the light to brightness table + */ + protected void generateLightBrightnessTable () + { + float f = 1.0F; + + for (int i = 0; i <= 15; ++i) + { + float f1 = 1.0F; + this.lightBrightnessTable[i] = 1.0f; + } + } + + /** + * Returns a new chunk provider which generates chunks for this world + */ + public IChunkProvider createChunkGenerator () + { + return new TinkerChunkProvider(this.worldObj, this.worldObj.getSeed()); + } + + /** + * Returns 'true' if in the "main surface world", but 'false' if in the Nether or End dimensions. + */ + public boolean isSurfaceWorld () + { + return false; + } + + /** + * Will check if the x, z position specified is alright to be set as the map spawn point + */ + public boolean canCoordinateBeSpawn (int par1, int par2) + { + return false; + } + + /** + * Calculates the angle of sun and moon in the sky relative to a specified time (usually worldTime) + */ + public float calculateCelestialAngle (long par1, float par3) + { + return 0.5F; + } + + /** + * True if the player can respawn in this dimension (true = overworld, false = nether). + */ + public boolean canRespawnHere () + { + return false; + } + + @SideOnly(Side.CLIENT) + /** + * Returns true if the given X,Z coordinate should show environmental fog. + */ + public boolean doesXZShowFog (int par1, int par2) + { + return false; + } + + /** + * Returns the dimension's name, e.g. "The End", "Nether", or "Overworld". + */ + public String getDimensionName () + { + return "Skylands"; + } +} diff --git a/tconstruct/entity/Automaton.java b/tconstruct/entity/Automaton.java new file mode 100644 index 00000000..1aac42c4 --- /dev/null +++ b/tconstruct/entity/Automaton.java @@ -0,0 +1,73 @@ +package tconstruct.entity; + +import tconstruct.entity.ai.GAIAttackTarget; +import tconstruct.entity.ai.GAIFindTarget; +import tconstruct.entity.ai.GAIFollowOwner; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class Automaton extends GolemBase +{ + int state; + + /*TaskBase currentTask; + HashMap taskList = new HashMap();*/ + + public Automaton(World world) + { + super(world); + this.setSize(0.9F, 2.42F); + //this.texture = "/mods/tinker/textures/mob/crystalguardamber.png"; + this.tasks.addTask(1, new GAIAttackTarget(this)); + this.tasks.addTask(2, new GAIFindTarget(this)); + this.tasks.addTask(3, new GAIFollowOwner(this)); + + /*taskList.put("wait", new TaskWait(this)); + TaskBase task = new TaskClearcut(this); + taskList.put("clearcut", task); + currentTask = task;*/ + } + + /*@Override + public void initCreature () + { + baseAttack = 5; + maxHealth = 50; + }*/ + + /*@Override + public void updateAITick() + { + if (!currentTask.update()) + { + currentTask.finishTask(); + } + }*/ + + protected String getHurtSound () + { + return "mob.irongolem.hit"; + } + + /** + * Returns the sound this mob makes on death. + */ + protected String getDeathSound () + { + return "mob.irongolem.death"; + } + + /** + * Plays step sound at given x, y, z for the entity + */ + protected void playStepSound (int par1, int par2, int par3, int par4) + { + this.playSound("mob.irongolem.walk", 1.0F, 1.0F); + } + + public boolean interact (EntityPlayer par1EntityPlayer) + { + this.setCurrentItemOrArmor(0, par1EntityPlayer.getCurrentEquippedItem().copy()); + return true; + } +} diff --git a/tconstruct/entity/BlueSlime.java b/tconstruct/entity/BlueSlime.java new file mode 100644 index 00000000..af8acdc9 --- /dev/null +++ b/tconstruct/entity/BlueSlime.java @@ -0,0 +1,624 @@ +package tconstruct.entity; + +import tconstruct.TConstruct; +import tconstruct.common.TContent; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.tools.ToolCore; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.SpiderEffectsGroupData; +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; + +public class BlueSlime extends EntityLiving implements IMob, IBossDisplayData +{ + private static final float[] field_100000_e = new float[] { 1.0F, 0.75F, 0.5F, 0.25F, 0.0F, 0.25F, 0.5F, 0.75F }; + public float sizeOffset; + public float sizeFactor; + public float sizeHeight; + + /** the time between each jump of the slime */ + protected int slimeJumpDelay = 0; + + public BlueSlime(World world) + { + super(world); + //this.texture = "/mods/tinker/textures/mob/slimeedible.png"; + int offset = this.rand.nextInt(299); + if (offset < 149) + offset = 1; + else if (offset < 298) + offset = 2; + else + offset = 3; + int size = 1 << offset; + this.yOffset = 0.0F; + this.slimeJumpDelay = this.rand.nextInt(120) + 40; + this.setSlimeSize(size); + this.jumpMovementFactor = 0.004F * size + 0.01F; + } + + protected void damageEntity (DamageSource damageSource, int damage) + { + //Minecraft.getMinecraft().getLogAgent().logInfo("Damage: "+damage); + if (damageSource.damageType.equals("arrow")) + damage = damage / 2; + super.damageEntity(damageSource, damage); + } + + public String getEntityName () + { + String s = EntityList.getEntityString(this); + + if (s == null) + { + s = "generic"; + } + + if (getSlimeSize() >= 8) + s = "TConstruct.KingSlime"; + + return StatCollector.translateToLocal("entity." + s + ".name"); + } + + /*@Override + public void initCreature () + { + if (getSlimeSize() == 2 && rand.nextInt(8) == 0) + { + EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj); + entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + //entityskeleton.initCreature(); + this.worldObj.spawnEntityInWorld(entityskeleton); + entityskeleton.mountEntity(this); + } + if (getSlimeSize() == 4 && rand.nextInt(12) == 0) + { + EntityCreeper creeper = new EntityCreeper(this.worldObj); + creeper.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + //creeper.initCreature(); + this.worldObj.spawnEntityInWorld(creeper); + creeper.mountEntity(this); + } + if (getSlimeSize() == 8) + { + for (int i = 0; i < 5; i++) + { + BlueSlime slime = new BlueSlime(this.worldObj); + slime.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + //slime.initCreature(); + this.worldObj.spawnEntityInWorld(slime); + } + + BlueSlime slime = new BlueSlime(this.worldObj); + slime.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + slime.setSlimeSize(2); + this.worldObj.spawnEntityInWorld(slime); + + EntitySkeleton skelton = new EntitySkeleton(this.worldObj); + skelton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + //skelton.initCreature(); + this.worldObj.spawnEntityInWorld(skelton); + skelton.mountEntity(slime); + } + }*/ + + public EntityLivingData func_110161_a(EntityLivingData par1EntityLivingData) + { + Object par1EntityLivingData1 = super.func_110161_a(par1EntityLivingData); + + if (getSlimeSize() == 2 && rand.nextInt(8) == 0) + { + EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj); + entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + entityskeleton.func_110161_a(par1EntityLivingData); + this.worldObj.spawnEntityInWorld(entityskeleton); + entityskeleton.mountEntity(this); + } + if (getSlimeSize() == 4 && rand.nextInt(12) == 0) + { + EntityCreeper creeper = new EntityCreeper(this.worldObj); + creeper.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + creeper.func_110161_a(par1EntityLivingData); + this.worldObj.spawnEntityInWorld(creeper); + creeper.mountEntity(this); + } + if (getSlimeSize() == 8) + { + for (int i = 0; i < 5; i++) + { + BlueSlime slime = new BlueSlime(this.worldObj); + slime.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + slime.func_110161_a(par1EntityLivingData); + this.worldObj.spawnEntityInWorld(slime); + } + + BlueSlime slime = new BlueSlime(this.worldObj); + slime.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + slime.setSlimeSize(2); + this.worldObj.spawnEntityInWorld(slime); + + EntitySkeleton skelton = new EntitySkeleton(this.worldObj); + skelton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + skelton.func_110161_a(par1EntityLivingData); + this.worldObj.spawnEntityInWorld(skelton); + skelton.mountEntity(slime); + } + + return (EntityLivingData)par1EntityLivingData1; + } + + @Override + public double getMountedYOffset () + { + return this.height * 0.3; + } + + protected void jump () + { + this.motionY = 0.05 * getSlimeSize() + 0.37; + + if (this.isPotionActive(Potion.jump)) + { + this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); + } + + if (this.isSprinting()) + { + float f = this.rotationYaw * 0.017453292F; + this.motionX -= (double) (MathHelper.sin(f) * 0.2F); + this.motionZ += (double) (MathHelper.cos(f) * 0.2F); + } + + if (this.getBrightness(1.0F) > 0.9F && rand.nextInt(5) == 0 + && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))) + { + int size = this.getSlimeSize() - 1; + if (size < 7) + { + if (size <= 0) + this.kill(); + else + this.setSlimeSize(size); + } + } + + this.isAirBorne = true; + ForgeHooks.onLivingJump(this); + } + + protected void fall (float par1) + { + } + + protected String getSlimeParticle () + { + return "blueslime"; + } + + @Override + public boolean getCanSpawnHere () + { + return isValidLightLevel() && this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() + && !this.worldObj.isAnyLiquid(this.boundingBox); + } + + protected boolean isValidLightLevel () + { + int x = MathHelper.floor_double(this.posX); + int y = MathHelper.floor_double(this.boundingBox.minY); + int z = MathHelper.floor_double(this.posZ); + + if (y < 60 && rand.nextInt(5) != 0) + { + return false; + } + + if (this.worldObj.getSavedLightValue(EnumSkyBlock.Sky, x, y, z) > this.rand.nextInt(32)) + { + return false; + } + else + { + int light = this.worldObj.getBlockLightValue(x, y, z); + + if (this.worldObj.isThundering()) + { + int i1 = this.worldObj.skylightSubtracted; + this.worldObj.skylightSubtracted = 10; + light = this.worldObj.getBlockLightValue(x, y, z); + this.worldObj.skylightSubtracted = i1; + } + + return light <= this.rand.nextInt(8); + } + } + + protected void entityInit () + { + super.entityInit(); + this.dataWatcher.addObject(16, new Byte((byte) 1)); + //this.dataWatcher.addObject(17, new Integer(100)); + } + + /*public void setSlimeSize (int size) + { + this.dataWatcher.updateObject(16, new Byte((byte) size)); + this.setSize(0.6F * size, 0.6F * size); + this.setPosition(this.posX, this.posY, this.posZ); + this.setEntityHealth(this.getMaxHealth()); + this.experienceValue = size + 2; + if (size >= 8) + this.experienceValue = 500; + }*/ + + public void setSlimeSize(int size) + { + this.dataWatcher.updateObject(16, new Byte((byte)size)); + this.setSize(0.6F * (float)size, 0.6F * (float)size); + this.setPosition(this.posX, this.posY, this.posZ); + this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(this.getMaxHealth()); + this.setEntityHealth(this.func_110138_aP()); + + this.experienceValue = size + 2^(size); + if (size >= 8) + this.experienceValue = 500; + } + + public int getMaxHealth () + { + int i = this.getSlimeSize(); + if (i == 1) + return 4; + if (i == 8) + return 100; + return (int) Math.min(i * i + 8, 49); + } + + /** + * Returns the size of the slime. + */ + public int getSlimeSize () + { + return this.dataWatcher.getWatchableObjectByte(16); + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("Size", this.getSlimeSize() - 1); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setSlimeSize(par1NBTTagCompound.getInteger("Size") + 1); + //this.dataWatcher.updateObject(17, Integer.valueOf(this.health)); + } + + /** + * Returns the name of the sound played when the slime jumps. + */ + protected String getJumpSound () + { + return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small"); + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate () + { + if (!this.worldObj.isRemote && this.worldObj.difficultySetting == 0 && this.getSlimeSize() > 0) + { + this.isDead = true; + } + + /*if (!this.worldObj.isRemote) + { + this.dataWatcher.updateObject(17, Integer.valueOf(this.health)); + }*/ + + this.sizeFactor += (this.sizeOffset - this.sizeFactor) * 0.5F; + this.sizeHeight = this.sizeFactor; + boolean flag = this.onGround; + super.onUpdate(); + int i; + + if (this.onGround && !flag) + { + i = this.getSlimeSize(); + + for (int j = 0; j < i * 8; ++j) + { + float f = this.rand.nextFloat() * (float) Math.PI * 2.0F; + float offset = this.rand.nextFloat() * 0.5F + 0.5F; + float xPos = MathHelper.sin(f) * (float) i * 0.5F * offset; + float zPos = MathHelper.cos(f) * (float) i * 0.5F * offset; + TConstruct.proxy.spawnParticle(this.getSlimeParticle(), this.posX + (double) xPos, this.boundingBox.minY, this.posZ + (double) zPos, 0.0D, 0.0D, 0.0D); + } + + if (this.makesSoundOnLand()) + { + this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F); + } + + this.sizeOffset = -0.5F; + } + else if (!this.onGround && flag) + { + this.sizeOffset = 1.0F; + } + + this.func_70808_l(); + + if (this.worldObj.isRemote) + { + i = this.getSlimeSize(); + this.setSize(0.6F * (float) i, 0.6F * (float) i); + } + } + + protected void updateEntityActionState () + { + //Minecraft.getMinecraft().getLogAgent().logInfo("Collided with "+entity.getEntityName()); + this.despawnEntity(); + EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D); + + if (entityplayer != null) + { + this.faceEntity(entityplayer, 10.0F, 20.0F); + } + else if (this.onGround && this.slimeJumpDelay == 1) + { + this.rotationYaw = this.rotationYaw + rand.nextFloat() * 180 - 90; + if (rotationYaw > 360) + rotationYaw -= 360; + if (rotationYaw < 0) + rotationYaw += 360; + } + + if (this.onGround && this.slimeJumpDelay-- <= 0) + { + this.slimeJumpDelay = this.getJumpDelay(); + + if (entityplayer != null) + { + this.slimeJumpDelay /= 12; + } + + this.isJumping = true; + + if (this.makesSoundOnJump()) + { + this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F); + } + + this.moveStrafing = 1.0F - this.rand.nextFloat() * 2.0F; + this.moveForward = (float) (1 * this.getSlimeSize()); + } + else + { + this.isJumping = false; + + if (this.onGround) + { + this.moveStrafing = this.moveForward = 0.0F; + } + } + } + + public boolean handleWaterMovement () + { + return false; + } + + protected void func_70808_l () + { + this.sizeOffset *= 0.6F; + } + + /** + * Gets the amount of time the slime needs to wait between jumps. + */ + protected int getJumpDelay () + { + return this.rand.nextInt(120) + 40; + } + + protected BlueSlime createInstance () + { + return new BlueSlime(this.worldObj); + } + + /** + * Will get destroyed next tick. + */ + public void setDead () + { + int size = this.getSlimeSize(); + + if (!this.worldObj.isRemote && size > 1 && this.func_110143_aJ() <= 0 && size < 8) + { + float f = (-0.5F) * (float) size / 4.0F; + float f1 = (-0.5F) * (float) size / 4.0F; + BlueSlime entityslime = this.createInstance(); + entityslime.setSlimeSize(size / 2); + entityslime.setLocationAndAngles(this.posX + (double) f, this.posY + 0.5D, this.posZ + (double) f1, this.rand.nextFloat() * 360.0F, 0.0F); + this.worldObj.spawnEntityInWorld(entityslime); + } + + super.setDead(); + } + + protected void dropFewItems (boolean par1, int par2) + { + int size = this.getSlimeSize(); + int j = this.getDropItemId(); + + if (j > 0 && (rand.nextInt(2) == 0) || size >= 8) + { + int k = rand.nextInt(3) + rand.nextInt(this.getSlimeSize()); + + if (par2 > 0) + { + k += this.rand.nextInt(par2 + 1); + } + + for (int l = 0; l < k; ++l) + { + this.dropItem(j, 1); + } + } + + if (size == 8) + { + ToolCore tool = getValidTool(); + + Item accessory = tool.getAccessoryItem(); + ItemStack accessoryStack = accessory != null ? new ItemStack(tool.getAccessoryItem(), 1, 17) : null; + ItemStack toolStack = ToolBuilder.instance.buildTool(new ItemStack(tool.getHeadItem(), 1, 17), new ItemStack(tool.getHandleItem(), 1, 17), accessoryStack, + "King Slime " + tool.getToolName()); + + NBTTagCompound tags = toolStack.getTagCompound().getCompoundTag("InfiTool"); + tags.setInteger("Attack", 3 + tool.getDamageVsEntity(null)); + tags.setInteger("TotalDurability", 1500); + tags.setInteger("BaseDurability", 1500); + tags.setInteger("MiningSpeed", 800); + + this.entityDropItem(toolStack, 0f); + if (rand.nextInt(5) == 0) + { + ItemStack dropStack = new ItemStack(TContent.heartCanister, 1, 1); + this.entityDropItem(dropStack, 0f); + } + } + } + + ToolCore getValidTool () + { + ToolCore tool = TConstructRegistry.tools.get(rand.nextInt(TConstructRegistry.tools.size())); + if (tool.getAccessoryItem() != null) + tool = getValidTool(); + return tool; + } + + /** + * Called by a player entity when they collide with an entity + */ + public void onCollideWithPlayer (EntityPlayer par1EntityPlayer) + { + if (this.canDamagePlayer()) + { + int i = this.getSlimeSize(); + + if (this.canEntityBeSeen(par1EntityPlayer) && this.getDistanceSqToEntity(par1EntityPlayer) < 0.6D * (double) i * 0.6D * (double) i + && par1EntityPlayer.attackEntityFrom(DamageSource.causeMobDamage(this), this.getAttackStrength())) + { + this.playSound("mob.attack", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + } + } + } + + /** + * Indicates weather the slime is able to damage the player (based upon the slime's size) + */ + protected boolean canDamagePlayer () + { + return this.getSlimeSize() > 1; + } + + /** + * Gets the amount of damage dealt to the player when "attacked" by the slime. + */ + protected int getAttackStrength () + { + return this.getSlimeSize(); + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + protected String getHurtSound () + { + return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small"); + } + + /** + * Returns the sound this mob makes on death. + */ + protected String getDeathSound () + { + return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small"); + } + + /** + * Returns the item ID for the item the mob drops on death. + */ + protected int getDropItemId () + { + return TContent.strangeFood.itemID; + } + + /** + * Returns the volume for the sounds this mob makes. + */ + protected float getSoundVolume () + { + return Math.min(0.05F * (float) this.getSlimeSize(), 0.3f); + } + + /** + * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently + * use in wolves. + */ + public int getVerticalFaceSpeed () + { + return 0; + } + + /** + * Returns true if the slime makes a sound when it jumps (based upon the slime's size) + */ + protected boolean makesSoundOnJump () + { + return this.getSlimeSize() > 0; + } + + /** + * Returns true if the slime makes a sound when it lands after a jump (based upon the slime's size) + */ + protected boolean makesSoundOnLand () + { + return this.getSlimeSize() > 2; + } + + /*@Override + public int getBossHealth () + { + return this.dataWatcher.getWatchableObjectInt(17); + }*/ +} diff --git a/tconstruct/entity/CartEntity.java b/tconstruct/entity/CartEntity.java new file mode 100644 index 00000000..871edca2 --- /dev/null +++ b/tconstruct/entity/CartEntity.java @@ -0,0 +1,1456 @@ +package tconstruct.entity; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.BlockRail; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; + +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CartEntity extends Entity implements IInventory, IEntityAdditionalSpawnData +{ + /** Array of item stacks stored in minecart (for storage minecarts). */ + protected ItemStack[] cargoItems; + protected int fuel; + protected boolean field_70499_f; + + /** The type of minecart, 2 for powered, 1 for storage. */ + private int pullcartType; + public double pushX; + public double pushZ; + protected boolean field_82345_h; + + /** Minecart rotational logic matrix */ + protected static final int[][][] matrix = new int[][][] { { { 0, 0, -1 }, { 0, 0, 1 } }, { { -1, 0, 0 }, { 1, 0, 0 } }, { { -1, -1, 0 }, { 1, 0, 0 } }, { { -1, 0, 0 }, { 1, -1, 0 } }, + { { 0, 0, -1 }, { 0, -1, 1 } }, { { 0, -1, -1 }, { 0, 0, 1 } }, { { 0, 0, 1 }, { 1, 0, 0 } }, { { 0, 0, 1 }, { -1, 0, 0 } }, { { 0, 0, -1 }, { -1, 0, 0 } }, { { 0, 0, -1 }, { 1, 0, 0 } } }; + + /** appears to be the progress of the turn */ + protected int turnProgress; + protected double minecartX; + protected double minecartY; + protected double minecartZ; + protected double minecartYaw; + protected double minecartPitch; + @SideOnly(Side.CLIENT) + protected double velocityX; + @SideOnly(Side.CLIENT) + protected double velocityY; + @SideOnly(Side.CLIENT) + protected double velocityZ; + + /* Forge: Minecart Compatibility Layer Integration. */ + public static float defaultMaxSpeedRail = 0.4f; + public static float defaultMaxSpeedGround = 0.4f; + public static float defaultMaxSpeedAirLateral = 0.4f; + public static float defaultMaxSpeedAirVertical = -1f; + public static double defaultDragRidden = 0.996999979019165D; + public static double defaultDragEmpty = 0.9599999785423279D; + public static double defaultDragAir = 0.94999998807907104D; + protected boolean canUseRail = true; + protected boolean canBePushed = true; + + /* Instance versions of the above physics properties */ + protected float maxSpeedRail; + protected float maxSpeedGround; + protected float maxSpeedAirLateral; + protected float maxSpeedAirVertical; + protected double dragAir; + + Entity entityFollowing; + + public CartEntity(World par1World) + { + super(par1World); + this.cargoItems = new ItemStack[36]; + this.fuel = 0; + this.field_70499_f = false; + this.field_82345_h = true; + this.preventEntitySpawning = true; + this.setSize(0.98F, 0.7F); + this.yOffset = this.height / 2.0F; + this.stepHeight = 1.0f; + + maxSpeedRail = defaultMaxSpeedRail; + maxSpeedGround = defaultMaxSpeedGround; + maxSpeedAirLateral = defaultMaxSpeedAirLateral; + maxSpeedAirVertical = defaultMaxSpeedAirVertical; + dragAir = defaultDragAir; + } + + public CartEntity(World world, int type) + { + this(world); + pullcartType = type; + } + + public CartEntity(World world, double x, double y, double z, int type) + { + this(world); + this.setPosition(x, y + (double) this.yOffset, z); + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.prevPosX = x; + this.prevPosY = y; + this.prevPosZ = z; + this.pullcartType = type; + this.stepHeight = 1.0f; + } + + /** + * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to + * prevent them from trampling crops + */ + protected boolean canTriggerWalking () + { + return false; + } + + protected void entityInit () + { + this.dataWatcher.addObject(16, new Byte((byte) 0)); + this.dataWatcher.addObject(17, new Integer(0)); + this.dataWatcher.addObject(18, new Integer(1)); + this.dataWatcher.addObject(19, new Integer(0)); + } + + /** + * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be + * pushable on contact, like boats or minecarts. + */ + public AxisAlignedBB getCollisionBox (Entity par1Entity) + { + return par1Entity.boundingBox; + } + + /** + * returns the bounding box for this entity + */ + public AxisAlignedBB getBoundingBox () + { + return this.boundingBox; + } + + /** + * Returns true if this entity should push and be pushed by other entities when colliding. + */ + public boolean canBePushed () + { + return canBePushed; + } + + /** + * Returns the Y offset from the entity's position for any entity riding this one. + */ + public double getMountedYOffset () + { + return (double) this.height * 0.0D - 0.30000001192092896D; + } + + /** + * Called when the entity is attacked. + */ + public boolean attackEntityFrom (DamageSource par1DamageSource, int par2) + { + if (!this.worldObj.isRemote && !this.isDead) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + this.func_70494_i(-this.func_70493_k()); + this.func_70497_h(10); + this.setBeenAttacked(); + this.setDamage(this.getDamage() + par2 * 10); + + if (par1DamageSource.getEntity() instanceof EntityPlayer && ((EntityPlayer) par1DamageSource.getEntity()).capabilities.isCreativeMode) + { + this.setDamage(100); + } + + if (this.getDamage() > 40) + { + if (this.riddenByEntity != null) + { + this.riddenByEntity.mountEntity(this); + } + + this.setDead(); + dropCartAsItem(); + } + + return true; + } + } + else + { + return true; + } + } + + @SideOnly(Side.CLIENT) + /** + * Setups the entity to do the hurt animation. Only used by packets in multiplayer. + */ + public void performHurtAnimation () + { + this.func_70494_i(-this.func_70493_k()); + this.func_70497_h(10); + this.setDamage(this.getDamage() + this.getDamage() * 10); + } + + /** + * Returns true if other Entities should be prevented from moving through this Entity. + */ + public boolean canBeCollidedWith () + { + return !this.isDead; + } + + /** + * Will get destroyed next tick. + */ + public void setDead () + { + if (this.field_82345_h) + { + for (int var1 = 0; var1 < this.getSizeInventory(); ++var1) + { + ItemStack var2 = this.getStackInSlot(var1); + + if (var2 != null) + { + float var3 = this.rand.nextFloat() * 0.8F + 0.1F; + float var4 = this.rand.nextFloat() * 0.8F + 0.1F; + float var5 = this.rand.nextFloat() * 0.8F + 0.1F; + + while (var2.stackSize > 0) + { + int var6 = this.rand.nextInt(21) + 10; + + if (var6 > var2.stackSize) + { + var6 = var2.stackSize; + } + + var2.stackSize -= var6; + EntityItem entityitem = new EntityItem(this.worldObj, this.posX + (double) var3, this.posY + (double) var4, this.posZ + (double) var5, new ItemStack(var2.itemID, var6, + var2.getItemDamage())); + + if (var2.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound) var2.getTagCompound().copy()); + } + + float var8 = 0.05F; + entityitem.motionX = (double) ((float) this.rand.nextGaussian() * var8); + entityitem.motionY = (double) ((float) this.rand.nextGaussian() * var8 + 0.2F); + entityitem.motionZ = (double) ((float) this.rand.nextGaussian() * var8); + this.worldObj.spawnEntityInWorld(entityitem); + } + } + } + } + + super.setDead(); + } + + /** + * Teleports the entity to another dimension. Params: Dimension number to teleport to + */ + public void travelToDimension (int par1) + { + this.field_82345_h = false; + super.travelToDimension(par1); + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate () + { + if (this.func_70496_j() > 0) + { + this.func_70497_h(this.func_70496_j() - 1); + } + + if (this.getDamage() > 0) + { + this.setDamage(this.getDamage() - 1); + } + + if (this.posY < -64.0D) + { + this.kill(); + } + + if (this.isMinecartPowered() && this.rand.nextInt(4) == 0 && pullcartType == 2 && getClass() == CartEntity.class) + { + this.worldObj.spawnParticle("largesmoke", this.posX, this.posY + 0.8D, this.posZ, 0.0D, 0.0D, 0.0D); + } + + int var2; + + if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer) + { + this.worldObj.theProfiler.startSection("portal"); + MinecraftServer var1 = ((WorldServer) this.worldObj).getMinecraftServer(); + var2 = this.getMaxInPortalTime(); + + if (this.inPortal) + { + if (var1.getAllowNether()) + { + /* + if (this.ridingEntity == null && this.timeInPortal++ >= var2) + { + this.timeInPortal = var2; + this.timeUntilPortal = this.getPortalCooldown(); + byte var3; + + if (this.worldObj.provider.dimensionId == -1) + { + var3 = 0; + } + else + { + var3 = -1; + } + + this.travelToDimension(var3); + } + + this.inPortal = false;*/ + } + } + else + { + /*if (this.timeInPortal > 0) + { + this.timeInPortal -= 4; + } + + if (this.timeInPortal < 0) + { + this.timeInPortal = 0; + }*/ + } + + if (this.timeUntilPortal > 0) + { + --this.timeUntilPortal; + } + + this.worldObj.theProfiler.endSection(); + } + + if (this.worldObj.isRemote) + { + if (this.turnProgress > 0) + { + double var46 = this.posX + (this.minecartX - this.posX) / (double) this.turnProgress; + double var48 = this.posY + (this.minecartY - this.posY) / (double) this.turnProgress; + double var5 = this.posZ + (this.minecartZ - this.posZ) / (double) this.turnProgress; + double var7 = MathHelper.wrapAngleTo180_double(this.minecartYaw - (double) this.rotationYaw); + this.rotationYaw = (float) ((double) this.rotationYaw + var7 / (double) this.turnProgress); + this.rotationPitch = (float) ((double) this.rotationPitch + (this.minecartPitch - (double) this.rotationPitch) / (double) this.turnProgress); + --this.turnProgress; + this.setPosition(var46, var48, var5); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + else + { + this.setPosition(this.posX, this.posY, this.posZ); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + } + else + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.03999999910593033D; + int var45 = MathHelper.floor_double(this.posX); + var2 = MathHelper.floor_double(this.posY); + int var47 = MathHelper.floor_double(this.posZ); + + if (BlockRail.isRailBlockAt(this.worldObj, var45, var2 - 1, var47)) + { + --var2; + } + + double var4 = 0.4D; + double var6 = 0.0078125D; + int var8 = this.worldObj.getBlockId(var45, var2, var47); + + moveMinecartOffRail(var45, var2, var47); + if (entityFollowing != null) + moveTowardsEntity(entityFollowing); + + this.doBlockCollisions(); + this.rotationPitch = 0.0F; + double var49 = this.prevPosX - this.posX; + double var50 = this.prevPosZ - this.posZ; + + if (var49 * var49 + var50 * var50 > 0.001D) + { + this.rotationYaw = (float) (Math.atan2(var50, var49) * 180.0D / Math.PI); + + if (this.field_70499_f) + { + this.rotationYaw += 180.0F; + } + } + + double var51 = (double) MathHelper.wrapAngleTo180_float(this.rotationYaw - this.prevRotationYaw); + + if (var51 < -170.0D || var51 >= 170.0D) + { + this.rotationYaw += 180.0F; + this.field_70499_f = !this.field_70499_f; + } + + this.setRotation(this.rotationYaw, this.rotationPitch); + + AxisAlignedBB box = boundingBox.expand(0.2D, 0.0D, 0.2D); + + List var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box); + + if (var15 != null && !var15.isEmpty()) + { + for (int var52 = 0; var52 < var15.size(); ++var52) + { + Entity var17 = (Entity) var15.get(var52); + + if (var17 != this.riddenByEntity && var17.canBePushed() && var17 instanceof CartEntity) + { + var17.applyEntityCollision(this); + } + } + } + + if (this.riddenByEntity != null && this.riddenByEntity.isDead) + { + if (this.riddenByEntity.ridingEntity == this) + { + this.riddenByEntity.ridingEntity = null; + } + + this.riddenByEntity = null; + } + + updateFuel(); + } + } + + void moveTowardsEntity (Entity entity) + { + //System.out.println("Moving towards entity"); + /*double distX = this.posX - entity.posX; + double distZ = this.posZ - entity.posZ; + //posY = posY + 0.1; + + if (entity.posY > this.posY) + motionY += 0.1; + if (distX > 0.5 && distZ > 0.5) + { + motionX = -distX; + motionZ = -distZ; + }*/ + + double var15 = entity.posX; + double var19 = entity.posZ; + + if (this.calculateDistance(this.prevPosX, var15) > 1.5D || this.calculateDistance(this.prevPosZ, var19) > 1.5D) + { + double var28 = this.prevPosX; + double var30 = this.prevPosZ; + double var36 = this.calculateDistance(var28, var15); + double var38 = this.calculateDistance(var30, var19); + double var40 = 1.0D; + double var42 = 1.0D; + double var46; + double var44; + + if (var36 > var38) + { + var46 = 1.0D; + var44 = var38 / var36; + var42 = var44 / 3.0D; + var40 = var46 / 3.0D; + } + else if (var38 > var36) + { + var44 = 1.0D; + var46 = var36 / var38; + var40 = var46 / 3.0D; + var42 = var44 / 3.0D; + } + + if (var15 > var28) + { + this.motionX = var40;// * var26; + } + else + { + this.motionX = -var40;// * var26; + } + + if (var19 > var30) + { + this.motionZ = var42;// * var26; + } + else + { + this.motionZ = -var42;// * var26; + } + } + + /*if (entity.posY > this.posY) + motionY += 0.1;*/ + } + + public double calculateDistance (double pos1, double pos2) + { + double distance = Math.abs(pos1 - pos2); //0.0D; + /*double absPos1 = Math.abs(pos1); + double absPos2 = Math.abs(pos2); + + if ((pos1 <= 0.0D || pos2 <= 0.0D) && (pos1 >= 0.0D || pos2 >= 0.0D)) + { + distance = absPos1 + absPos2; + } + else if (absPos1 > absPos2) + { + distance = absPos1 - absPos2; + } + else if (absPos2 > absPos1) + { + distance = absPos2 - absPos1; + }*/ + + return distance; + } + + @SideOnly(Side.CLIENT) + public Vec3 func_70495_a (double par1, double par3, double par5, double par7) + { + int var9 = MathHelper.floor_double(par1); + int var10 = MathHelper.floor_double(par3); + int var11 = MathHelper.floor_double(par5); + + if (BlockRail.isRailBlockAt(this.worldObj, var9, var10 - 1, var11)) + { + --var10; + } + + int var12 = this.worldObj.getBlockId(var9, var10, var11); + + return null; + } + + public Vec3 func_70489_a (double par1, double par3, double par5) + { + int var7 = MathHelper.floor_double(par1); + int var8 = MathHelper.floor_double(par3); + int var9 = MathHelper.floor_double(par5); + + if (BlockRail.isRailBlockAt(this.worldObj, var7, var8 - 1, var9)) + { + --var8; + } + + int var10 = this.worldObj.getBlockId(var7, var8, var9); + + if (BlockRail.isRailBlock(var10)) + { + int var11 = 0; + par3 = (double) var8; + + if (var11 >= 2 && var11 <= 5) + { + par3 = (double) (var8 + 1); + } + + int[][] var12 = matrix[var11]; + double var13 = 0.0D; + double var15 = (double) var7 + 0.5D + (double) var12[0][0] * 0.5D; + double var17 = (double) var8 + 0.5D + (double) var12[0][1] * 0.5D; + double var19 = (double) var9 + 0.5D + (double) var12[0][2] * 0.5D; + double var21 = (double) var7 + 0.5D + (double) var12[1][0] * 0.5D; + double var23 = (double) var8 + 0.5D + (double) var12[1][1] * 0.5D; + double var25 = (double) var9 + 0.5D + (double) var12[1][2] * 0.5D; + double var27 = var21 - var15; + double var29 = (var23 - var17) * 2.0D; + double var31 = var25 - var19; + + if (var27 == 0.0D) + { + par1 = (double) var7 + 0.5D; + var13 = par5 - (double) var9; + } + else if (var31 == 0.0D) + { + par5 = (double) var9 + 0.5D; + var13 = par1 - (double) var7; + } + else + { + double var33 = par1 - var15; + double var35 = par5 - var19; + var13 = (var33 * var27 + var35 * var31) * 2.0D; + } + + par1 = var15 + var27 * var13; + par3 = var17 + var29 * var13; + par5 = var19 + var31 * var13; + + if (var29 < 0.0D) + { + ++par3; + } + + if (var29 > 0.0D) + { + par3 += 0.5D; + } + + return this.worldObj.getWorldVec3Pool().getVecFromPool(par1, par3, par5); + } + else + { + return null; + } + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + protected void writeEntityToNBT (NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setInteger("Type", pullcartType); + + if (isPoweredCart()) + { + par1NBTTagCompound.setDouble("PushX", this.pushX); + par1NBTTagCompound.setDouble("PushZ", this.pushZ); + par1NBTTagCompound.setInteger("Fuel", this.fuel); + } + + if (getSizeInventory() > 0) + { + NBTTagList var2 = new NBTTagList(); + + for (int var3 = 0; var3 < this.cargoItems.length; ++var3) + { + if (this.cargoItems[var3] != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte) var3); + this.cargoItems[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + + par1NBTTagCompound.setTag("Items", var2); + } + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + protected void readEntityFromNBT (NBTTagCompound par1NBTTagCompound) + { + pullcartType = par1NBTTagCompound.getInteger("Type"); + + if (isPoweredCart()) + { + this.pushX = par1NBTTagCompound.getDouble("PushX"); + this.pushZ = par1NBTTagCompound.getDouble("PushZ"); + try + { + this.fuel = par1NBTTagCompound.getInteger("Fuel"); + } + catch (ClassCastException e) + { + this.fuel = par1NBTTagCompound.getShort("Fuel"); + } + } + + if (getSizeInventory() > 0) + { + NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); + this.cargoItems = new ItemStack[this.getSizeInventory()]; + + for (int var3 = 0; var3 < var2.tagCount(); ++var3) + { + NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3); + int var5 = var4.getByte("Slot") & 255; + + if (var5 >= 0 && var5 < this.cargoItems.length) + { + this.cargoItems[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + } + } + + @SideOnly(Side.CLIENT) + public float getShadowSize () + { + return 0.5F; + } + + /** + * Applies a velocity to each of the entities pushing them away from each other. Args: entity + */ + public void applyEntityCollision (Entity par1Entity) + { + if (!this.worldObj.isRemote) + { + if (par1Entity != this.riddenByEntity) + { + if (par1Entity instanceof EntityLiving && !(par1Entity instanceof EntityPlayer) && !(par1Entity instanceof EntityIronGolem) && canBeRidden() + && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && this.riddenByEntity == null && par1Entity.ridingEntity == null) + { + par1Entity.mountEntity(this); + } + + double var2 = par1Entity.posX - this.posX; + double var4 = par1Entity.posZ - this.posZ; + double var6 = var2 * var2 + var4 * var4; + + if (var6 >= 9.999999747378752E-5D) + { + var6 = (double) MathHelper.sqrt_double(var6); + var2 /= var6; + var4 /= var6; + double var8 = 1.0D / var6; + + if (var8 > 1.0D) + { + var8 = 1.0D; + } + + var2 *= var8; + var4 *= var8; + var2 *= 0.10000000149011612D; + var4 *= 0.10000000149011612D; + var2 *= (double) (1.0F - this.entityCollisionReduction); + var4 *= (double) (1.0F - this.entityCollisionReduction); + var2 *= 0.5D; + var4 *= 0.5D; + + if (par1Entity instanceof CartEntity) + { + double var10 = par1Entity.posX - this.posX; + double var12 = par1Entity.posZ - this.posZ; + Vec3 var14 = this.worldObj.getWorldVec3Pool().getVecFromPool(var10, 0.0D, var12).normalize(); + Vec3 var15 = this.worldObj.getWorldVec3Pool() + .getVecFromPool((double) MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F), 0.0D, (double) MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F)) + .normalize(); + double var16 = Math.abs(var14.dotProduct(var15)); + + if (var16 < 0.8D) + { + return; + } + + double var18 = par1Entity.motionX + this.motionX; + double var20 = par1Entity.motionZ + this.motionZ; + + if (((CartEntity) par1Entity).isPoweredCart() && !isPoweredCart()) + { + this.motionX *= 0.20000000298023224D; + this.motionZ *= 0.20000000298023224D; + this.addVelocity(par1Entity.motionX - var2, 0.0D, par1Entity.motionZ - var4); + par1Entity.motionX *= 0.949999988079071D; + par1Entity.motionZ *= 0.949999988079071D; + } + else if (!((CartEntity) par1Entity).isPoweredCart() && isPoweredCart()) + { + par1Entity.motionX *= 0.20000000298023224D; + par1Entity.motionZ *= 0.20000000298023224D; + par1Entity.addVelocity(this.motionX + var2, 0.0D, this.motionZ + var4); + this.motionX *= 0.949999988079071D; + this.motionZ *= 0.949999988079071D; + } + else + { + var18 /= 2.0D; + var20 /= 2.0D; + this.motionX *= 0.20000000298023224D; + this.motionZ *= 0.20000000298023224D; + this.addVelocity(var18 - var2, 0.0D, var20 - var4); + par1Entity.motionX *= 0.20000000298023224D; + par1Entity.motionZ *= 0.20000000298023224D; + par1Entity.addVelocity(var18 + var2, 0.0D, var20 + var4); + } + } + else + { + this.addVelocity(-var2, 0.0D, -var4); + par1Entity.addVelocity(var2 / 4.0D, 0.0D, var4 / 4.0D); + } + } + } + } + } + + /** + * Returns the number of slots in the inventory. + */ + public int getSizeInventory () + { + return (pullcartType == 1 && getClass() == CartEntity.class ? 27 : 0); + } + + /** + * Returns the stack in slot i + */ + public ItemStack getStackInSlot (int par1) + { + return this.cargoItems[par1]; + } + + /** + * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a + * new stack. + */ + public ItemStack decrStackSize (int par1, int par2) + { + if (this.cargoItems[par1] != null) + { + ItemStack var3; + + if (this.cargoItems[par1].stackSize <= par2) + { + var3 = this.cargoItems[par1]; + this.cargoItems[par1] = null; + return var3; + } + else + { + var3 = this.cargoItems[par1].splitStack(par2); + + if (this.cargoItems[par1].stackSize == 0) + { + this.cargoItems[par1] = null; + } + + return var3; + } + } + else + { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing (int par1) + { + if (this.cargoItems[par1] != null) + { + ItemStack var2 = this.cargoItems[par1]; + this.cargoItems[par1] = null; + return var2; + } + else + { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents (int par1, ItemStack par2ItemStack) + { + this.cargoItems[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + /** + * Returns the name of the inventory. + */ + public String getInvName () + { + return "container.minecart"; + } + + /** + * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't + * this more of a set than a get?* + */ + public int getInventoryStackLimit () + { + return 64; + } + + /** + * Called when an the contents of an Inventory change, usually + */ + public void onInventoryChanged () + { + } + + /** + * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. + */ + public boolean interact (EntityPlayer player) + { + if (player.isSneaking()) + { + if (entityFollowing == null) + { + entityFollowing = player; + //if (!worldObj.isRemote) + //player.addChatMessage("The cart is following you"); + } + else + { + entityFollowing = null; + //if (!worldObj.isRemote) + //player.addChatMessage("The cart has stopped following you"); + } + return true; + } + if (canBeRidden()) + { + if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != player) + { + return true; + } + + if (!this.worldObj.isRemote) + { + player.mountEntity(this); + } + } + else if (getSizeInventory() > 0) + { + if (!this.worldObj.isRemote) + { + player.displayGUIChest(this); + } + } + else if (this.pullcartType == 2 && getClass() == CartEntity.class) + { + ItemStack var2 = player.inventory.getCurrentItem(); + + if (var2 != null && var2.itemID == Item.coal.itemID) + { + if (--var2.stackSize == 0) + { + player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack) null); + } + + this.fuel += 3600; + } + + this.pushX = this.posX - player.posX; + this.pushZ = this.posZ - player.posZ; + } + + return true; + } + + @SideOnly(Side.CLIENT) + /** + * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, + * posY, posZ, yaw, pitch + */ + public void setPositionAndRotation2 (double par1, double par3, double par5, float par7, float par8, int par9) + { + this.minecartX = par1; + this.minecartY = par3; + this.minecartZ = par5; + this.minecartYaw = (double) par7; + this.minecartPitch = (double) par8; + this.turnProgress = par9 + 2; + this.motionX = this.velocityX; + this.motionY = this.velocityY; + this.motionZ = this.velocityZ; + } + + @SideOnly(Side.CLIENT) + /** + * Sets the velocity to the args. Args: x, y, z + */ + public void setVelocity (double par1, double par3, double par5) + { + this.velocityX = this.motionX = par1; + this.velocityY = this.motionY = par3; + this.velocityZ = this.motionZ = par5; + } + + /** + * Do not make give this method the name canInteractWith because it clashes with Container + */ + public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer) + { + return this.isDead ? false : par1EntityPlayer.getDistanceSqToEntity(this) <= 64.0D; + } + + /** + * Is this minecart powered (Fuel > 0) + */ + public boolean isMinecartPowered () + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + /** + * Set if this minecart is powered (Fuel > 0) + */ + protected void setMinecartPowered (boolean par1) + { + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) (this.dataWatcher.getWatchableObjectByte(16) | 1))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) (this.dataWatcher.getWatchableObjectByte(16) & -2))); + } + } + + public void openChest () + { + } + + public void closeChest () + { + } + + /** + * Sets the current amount of damage the minecart has taken. Decreases over time. The cart breaks when this is over + * 40. + */ + public void setDamage (int par1) + { + this.dataWatcher.updateObject(19, Integer.valueOf(par1)); + } + + /** + * Gets the current amount of damage the minecart has taken. Decreases over time. The cart breaks when this is over + * 40. + */ + public int getDamage () + { + return this.dataWatcher.getWatchableObjectInt(19); + } + + public void func_70497_h (int par1) + { + this.dataWatcher.updateObject(17, Integer.valueOf(par1)); + } + + public int func_70496_j () + { + return this.dataWatcher.getWatchableObjectInt(17); + } + + public void func_70494_i (int par1) + { + this.dataWatcher.updateObject(18, Integer.valueOf(par1)); + } + + public int func_70493_k () + { + return this.dataWatcher.getWatchableObjectInt(18); + } + + /** + * Drops the cart as a item. The exact item dropped is defined by getItemDropped(). + */ + public void dropCartAsItem () + { + for (ItemStack item : getItemsDropped()) + { + entityDropItem(item, 0); + } + } + + /** + * Override this to define which items your cart drops when broken. + * This does not include items contained in the inventory, + * that is handled elsewhere. + * @return A list of items dropped. + */ + public List getItemsDropped () + { + /*List items = new ArrayList(); + items.add(new ItemStack(Item.minecartEmpty)); + + switch(cartType) + { + case 1: + items.add(new ItemStack(Block.chest)); + break; + case 2: + items.add(new ItemStack(Block.stoneOvenIdle)); + break; + } + return items;*/ + return new ArrayList(); + } + + /** + * This function returns an ItemStack that represents this cart. + * This should be an ItemStack that can be used by the player to place the cart. + * This is the item that was registered with the cart via the registerMinecart function, + * but is not necessary the item the cart drops when destroyed. + * @return An ItemStack that can be used to place the cart. + */ + public ItemStack getCartItem () + { + return null; + //return MinecartRegistry.getItemForCart(this); + } + + /** + * Returns true if this cart is self propelled. + * @return True if powered. + */ + public boolean isPoweredCart () + { + return pullcartType == 2 && getClass() == CartEntity.class; + } + + /** + * Returns true if this cart is a storage cart + * Some carts may have inventories but not be storage carts + * and some carts without inventories may be storage carts. + * @return True if this cart should be classified as a storage cart. + */ + public boolean isStorageCart () + { + return pullcartType == 1 && getClass() == CartEntity.class; + } + + /** + * Returns true if this cart can be ridden by an Entity. + * @return True if this cart can be ridden. + */ + public boolean canBeRidden () + { + if (pullcartType == 0 && getClass() == CartEntity.class) + { + return true; + } + return false; + } + + /** + * Returns true if this cart can currently use rails. + * This function is mainly used to gracefully detach a minecart from a rail. + * @return True if the minecart can use rails. + */ + public boolean canUseRail () + { + return false; + } + + /** + * Set whether the minecart can use rails. + * This function is mainly used to gracefully detach a minecart from a rail. + * @param use Whether the minecart can currently use rails. + */ + public void setCanUseRail (boolean use) + { + canUseRail = use; + } + + /** + * Return false if this cart should not call IRail.onMinecartPass() and should ignore Powered Rails. + * @return True if this cart should call IRail.onMinecartPass(). + */ + public boolean shouldDoRailFunctions () + { + return true; + } + + /** + * Simply returns the minecartType variable. + * @return minecartType + */ + public int getCartType () + { + return pullcartType; + } + + /** + * Carts should return their drag factor here + * @return The drag rate. + */ + protected double getDrag () + { + return riddenByEntity != null ? defaultDragRidden : defaultDragEmpty; + } + + /** + * Moved to allow overrides. + * This code applies drag and updates push forces. + */ + protected void applyDragAndPushForces () + { + if (isPoweredCart()) + { + double d27 = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); + if (d27 > 0.01D) + { + pushX /= d27; + pushZ /= d27; + double d29 = 0.04; + motionX *= 0.8D; + motionY *= 0.0D; + motionZ *= 0.8D; + motionX += pushX * d29; + motionZ += pushZ * d29; + } + else + { + motionX *= 0.9D; + motionY *= 0.0D; + motionZ *= 0.9D; + } + } + motionX *= getDrag(); + motionY *= 0.0D; + motionZ *= getDrag(); + } + + /** + * Moved to allow overrides. + * This code updates push forces. + */ + protected void updatePushForces () + { + if (isPoweredCart()) + { + double push = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); + if (push > 0.01D && motionX * motionX + motionZ * motionZ > 0.001D) + { + pushX /= push; + pushZ /= push; + if (pushX * motionX + pushZ * motionZ < 0.0D) + { + pushX = 0.0D; + pushZ = 0.0D; + } + else + { + pushX = motionX; + pushZ = motionZ; + } + } + } + } + + /** + * Moved to allow overrides. + * This code handles minecart movement and speed capping when not on a rail. + */ + protected void moveMinecartOffRail (int i, int j, int k) + { + double d2 = getMaxSpeedGround(); + if (!onGround) + { + d2 = getMaxSpeedAirLateral(); + } + if (motionX < -d2) + motionX = -d2; + if (motionX > d2) + motionX = d2; + if (motionZ < -d2) + motionZ = -d2; + if (motionZ > d2) + motionZ = d2; + double moveY = motionY; + if (getMaxSpeedAirVertical() > 0 && motionY > getMaxSpeedAirVertical()) + { + moveY = getMaxSpeedAirVertical(); + if (Math.abs(motionX) < 0.3f && Math.abs(motionZ) < 0.3f) + { + moveY = 0.15f; + motionY = moveY; + } + } + if (onGround) + { + motionX *= 0.5D; + motionY *= 0.5D; + motionZ *= 0.5D; + } + moveEntity(motionX, moveY, motionZ); + if (!onGround) + { + motionX *= getDragAir(); + motionY *= getDragAir(); + motionZ *= getDragAir(); + } + } + + /** + * Moved to allow overrides. + * This code applies fuel consumption. + */ + protected void updateFuel () + { + if (fuel > 0) + fuel--; + if (fuel <= 0) + pushX = pushZ = 0.0D; + setMinecartPowered(fuel > 0); + } + + /** + * Moved to allow overrides, This code handle slopes affecting velocity. + * @param metadata The blocks position metadata + */ + protected void adjustSlopeVelocities (int metadata) + { + double acceleration = 0.0078125D; + if (metadata == 2) + { + motionX -= acceleration; + } + else if (metadata == 3) + { + motionX += acceleration; + } + else if (metadata == 4) + { + motionZ += acceleration; + } + else if (metadata == 5) + { + motionZ -= acceleration; + } + } + + /** + * Getters/setters for physics variables + */ + + /** + * Returns the carts max speed. + * Carts going faster than 1.1 cause issues with chunk loading. + * Carts cant traverse slopes or corners at greater than 0.5 - 0.6. + * This value is compared with the rails max speed to determine + * the carts current max speed. A normal rails max speed is 0.4. + * @return Carts max speed. + */ + public float getMaxSpeedRail () + { + return maxSpeedRail; + } + + public void setMaxSpeedRail (float value) + { + maxSpeedRail = value; + } + + public float getMaxSpeedGround () + { + return maxSpeedGround; + } + + public void setMaxSpeedGround (float value) + { + maxSpeedGround = value; + } + + public float getMaxSpeedAirLateral () + { + return maxSpeedAirLateral; + } + + public void setMaxSpeedAirLateral (float value) + { + maxSpeedAirLateral = value; + } + + public float getMaxSpeedAirVertical () + { + return maxSpeedAirVertical; + } + + public void setMaxSpeedAirVertical (float value) + { + maxSpeedAirVertical = value; + } + + public double getDragAir () + { + return dragAir; + } + + public void setDragAir (double value) + { + dragAir = value; + } + + @Override + public void writeSpawnData (ByteArrayDataOutput data) + { + data.writeInt(pullcartType); + + } + + @Override + public void readSpawnData (ByteArrayDataInput data) + { + pullcartType = data.readInt(); + + } + + @Override + public boolean isInvNameLocalized () + { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isItemValidForSlot (int i, ItemStack itemstack) + { + // TODO Auto-generated method stub + return false; + } +} diff --git a/tconstruct/entity/Crystal.java b/tconstruct/entity/Crystal.java new file mode 100644 index 00000000..fabd5c15 --- /dev/null +++ b/tconstruct/entity/Crystal.java @@ -0,0 +1,15 @@ +package tconstruct.entity; + +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.world.World; + +public class Crystal extends EntityCreeper +{ + + public Crystal(World par1World) + { + super(par1World); + //texture = "/mods/tinker/textures/mob/crystalwater.png"; + } + +} diff --git a/tconstruct/entity/CrystalGuardian.java b/tconstruct/entity/CrystalGuardian.java new file mode 100644 index 00000000..63eb9337 --- /dev/null +++ b/tconstruct/entity/CrystalGuardian.java @@ -0,0 +1,21 @@ +package tconstruct.entity; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.world.World; + +public class CrystalGuardian extends EntityLiving +{ + + public CrystalGuardian(World par1World) + { + super(par1World); + //this.texture = "/mods/tinker/textures/mob/crystalguardamber.png"; + } + + /*@Override + public int getMaxHealth () + { + return 100; + }*/ + +} diff --git a/tconstruct/entity/FakeBlockEntity.java b/tconstruct/entity/FakeBlockEntity.java new file mode 100644 index 00000000..054290ee --- /dev/null +++ b/tconstruct/entity/FakeBlockEntity.java @@ -0,0 +1,51 @@ +package tconstruct.entity; + +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; + +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; + +public class FakeBlockEntity extends Entity implements IEntityAdditionalSpawnData +{ + + public FakeBlockEntity(World world) + { + super(world); + preventEntitySpawning = true; + } + + @Override + protected void entityInit () + { + + } + + @Override + public void writeSpawnData (ByteArrayDataOutput data) + { + + } + + @Override + public void readSpawnData (ByteArrayDataInput data) + { + + } + + @Override + protected void readEntityFromNBT (NBTTagCompound var1) + { + + } + + @Override + protected void writeEntityToNBT (NBTTagCompound var1) + { + + } + +} diff --git a/tconstruct/entity/FancyEntityItem.java b/tconstruct/entity/FancyEntityItem.java new file mode 100644 index 00000000..b4568775 --- /dev/null +++ b/tconstruct/entity/FancyEntityItem.java @@ -0,0 +1,25 @@ +package tconstruct.entity; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class FancyEntityItem extends EntityItem +{ + public FancyEntityItem(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + public FancyEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) + { + this(par1World, par2, par4, par6); + this.setEntityItemStack(par8ItemStack); + this.lifespan = (par8ItemStack.getItem() == null ? 6000 : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World)); + } + + public FancyEntityItem(World par1World) + { + super(par1World); + } +} diff --git a/tconstruct/entity/GolemBase.java b/tconstruct/entity/GolemBase.java new file mode 100644 index 00000000..720457c1 --- /dev/null +++ b/tconstruct/entity/GolemBase.java @@ -0,0 +1,443 @@ +package tconstruct.entity; + +import java.lang.ref.WeakReference; +import java.util.Random; + +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.ToolCore; + + +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.EnchantmentThorns; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityMultiPart; +import net.minecraft.entity.boss.EntityDragonPart; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.potion.Potion; +import net.minecraft.util.DamageSource; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class GolemBase extends EntityCreature implements IInventory +{ + public WeakReference leader; //Monster + public String ownerName = ""; //Player + public int maxHealth = 20; + public int baseAttack; + public boolean paused; + int useTime; + protected static Random rand = new Random(); + //public static CoordTuple target; + public int targetX; + public int targetY; + public int targetZ; + public boolean targetLock; + + public ItemStack[] inventory; + + public GolemBase(World world) + { + super(world); + setupInventory(); + } + + public void setupInventory () + { + inventory = new ItemStack[0]; + } + + /*@Override + public int getMaxHealth () + { + //Workaround for dying on spawn + if (maxHealth == 0) + return 20; + + return maxHealth; + } + + @Override + public void initCreature () + { + baseAttack = 3; + paused = false; + }*/ + + public EntityLivingBase getOwner () + { + if (leader == null || leader.get() == null) + return this.worldObj.getPlayerEntityByName(ownerName); + return leader.get(); + } + + public void setOwner (EntityLivingBase living) + { + if (living instanceof EntityPlayer) + ownerName = ((EntityPlayer) living).username; + else + leader = new WeakReference(living); + } + + public boolean isOwner (Entity entity) + { + if (entity == null) + { + return false; + } + if (entity instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer) entity; + return entityplayer.username.equalsIgnoreCase(ownerName); + } + return false; + } + + public float getSpeed () + { + return 0.25f; + } + + /* AI */ + + @Override + protected boolean isAIEnabled () + { + return true; + } + + protected void updateWanderPath () + { + if (!paused) + super.updateWanderPath(); + } + + public boolean standby() + { + return false; + } + + public boolean following () + { + return false; + } + + public boolean patrolling () + { + return true; + } + + public void attackEntityAsGolem (Entity target) + { + /*ItemStack stack = getHeldItem(); + if (stack == null) + target.attackEntityFrom(DamageSource.causeMobDamage(this), baseAttack); + + else if (stack.getItem() instanceof ToolCore) + { + if (stack.hasTagCompound()) + { + AbilityHelper.onLeftClickEntity(stack, this, target, (ToolCore) stack.getItem(), baseAttack); + } + else + target.attackEntityFrom(DamageSource.causeMobDamage(this), baseAttack); + } + else + { + if (target.canAttackWithItem()) + { + if (!target.func_85031_j(this)) + { + int i = stack.getDamageVsEntity(target) + baseAttack; + + if (this.isPotionActive(Potion.damageBoost)) + { + i += 3 << this.getActivePotionEffect(Potion.damageBoost).getAmplifier(); + } + + if (this.isPotionActive(Potion.weakness)) + { + i -= 2 << this.getActivePotionEffect(Potion.weakness).getAmplifier(); + } + + int j = 0; + int k = 0; + + if (target instanceof EntityLivingBase) + { + k = EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLivingBase) target); + j += EnchantmentHelper.getKnockbackModifier(this, (EntityLivingBase) target); + } + + if (this.isSprinting()) + { + ++j; + } + + if (i > 0 || k > 0) + { + boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Potion.blindness) && this.ridingEntity == null + && target instanceof EntityLivingBase; + + if (flag && i > 0) + { + i += this.rand.nextInt(i / 2 + 2); + } + + i += k; + boolean flag1 = false; + int l = EnchantmentHelper.getFireAspectModifier(this); + + if (target instanceof EntityLivingBase && l > 0 && !target.isBurning()) + { + flag1 = true; + target.setFire(1); + } + + boolean flag2 = target.attackEntityFrom(DamageSource.causeMobDamage(this), i); + + if (flag2) + { + if (j > 0) + { + target.addVelocity((double) (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F), 0.1D, + (double) (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F)); + this.motionX *= 0.6D; + this.motionZ *= 0.6D; + this.setSprinting(false); + } + this.setLastAttackingEntity(target); + + if (target instanceof EntityLivingBase) + { + EnchantmentThorns.func_92096_a(this, (EntityLivingBase) target, this.rand); + } + } + + //ItemStack stack = this.getCurrentEquippedItem(); + Object object = target; + + if (target instanceof EntityDragonPart) + { + IEntityMultiPart ientitymultipart = ((EntityDragonPart) target).entityDragonObj; + + if (ientitymultipart != null && ientitymultipart instanceof EntityLivingBase) + { + object = (EntityLivingBase) ientitymultipart; + } + } + + if (stack != null && object instanceof EntityLivingBase) + { + //stack.hitEntity((EntityLiving)object, this); + Item.itemsList[stack.itemID].hitEntity(stack, (EntityLivingBase) object, this); + + if (stack.stackSize <= 0) + { + this.destroyCurrentEquippedItem(); + } + } + + if (target instanceof EntityLivingBase) + { + + if (l > 0 && flag2) + { + target.setFire(l * 4); + } + else if (flag1) + { + target.extinguish(); + } + } + + //this.addExhaustion(0.3F); + } + } + } + }*/ + } + + public void teleport (double x, double y, double z) + { + this.setPosition(x, y, z); + worldObj.playSoundAtEntity(this, "mob.endermen.portal", 0.5F, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); + } + + /* Other */ + protected boolean canDespawn () + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getItemIcon (ItemStack par1ItemStack, int par2) + { + Icon icon = super.getItemIcon(par1ItemStack, par2); + if (par1ItemStack.getItem().requiresMultipleRenderPasses()) + { + return par1ItemStack.getItem().getIcon(par1ItemStack, par2); + } + + return icon; + } + + /* Inventory */ + @Override + public ItemStack getStackInSlot (int slot) + { + if (slot < 0 || slot >= inventory.length) + return null; + return inventory[slot]; + } + + public boolean isStackInSlot (int slot) + { + if (slot < 0 || slot >= inventory.length) + return false; + return inventory[slot] != null; + } + + @Override + public int getSizeInventory () + { + return inventory.length; + } + + @Override + public int getInventoryStackLimit () + { + return 64; + } + + @Override + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + inventory[slot] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); + } + } + + @Override + public ItemStack decrStackSize (int slot, int quantity) + { + if (inventory[slot] != null) + { + if (inventory[slot].stackSize <= quantity) + { + ItemStack stack = inventory[slot]; + inventory[slot] = null; + return stack; + } + ItemStack split = inventory[slot].splitStack(quantity); + if (inventory[slot].stackSize == 0) + { + inventory[slot] = null; + } + return split; + } + else + { + return null; + } + } + + @Override + public String getInvName () + { + return "golem.none"; + } + + @Override + public boolean isInvNameLocalized () + { + return false; + } + + @Override + public void onInventoryChanged () + { + + } + + public ItemStack getStackInSlotOnClosing (int slot) + { + return null; + } + + public void openChest () + { + } + + public void closeChest () + { + } + + @Override + public boolean isItemValidForSlot (int i, ItemStack itemstack) + { + return true; + } + + @Override + public boolean isUseableByPlayer (EntityPlayer entityplayer) + { + return true; + } + + public void destroyCurrentEquippedItem () + { + worldObj.playSoundAtEntity(this, "random.break", 0.5F, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); + this.setCurrentItemOrArmor(0, null); + } + + /* Saving */ + public void writeEntityToNBT (NBTTagCompound tags) + { + super.writeEntityToNBT(tags); + tags.setString("OwnerName", ownerName); + NBTTagList nbttaglist = new NBTTagList(); + for (int iter = 0; iter < inventory.length; iter++) + { + if (inventory[iter] != null) + { + NBTTagCompound tagList = new NBTTagCompound(); + tagList.setByte("Slot", (byte) iter); + inventory[iter].writeToNBT(tagList); + nbttaglist.appendTag(tagList); + } + } + + tags.setTag("Items", nbttaglist); + + } + + public void readEntityFromNBT (NBTTagCompound tags) + { + super.readEntityFromNBT(tags); + ownerName = tags.getString("OwnerName"); + NBTTagList nbttaglist = tags.getTagList("Items"); + inventory = new ItemStack[getSizeInventory()]; + for (int iter = 0; iter < nbttaglist.tagCount(); iter++) + { + NBTTagCompound tagList = (NBTTagCompound) nbttaglist.tagAt(iter); + byte slotID = tagList.getByte("Slot"); + if (slotID >= 0 && slotID < inventory.length) + { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList); + } + } + } +} diff --git a/tconstruct/entity/MetalSlime.java b/tconstruct/entity/MetalSlime.java new file mode 100644 index 00000000..90ad99f8 --- /dev/null +++ b/tconstruct/entity/MetalSlime.java @@ -0,0 +1,108 @@ +package tconstruct.entity; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +public class MetalSlime extends BlueSlime +{ + + public MetalSlime(World world) + { + super(world); + //this.texture = "/mods/tinker/textures/mob/slimemetal.png"; + } + + public boolean attackEntityFrom (DamageSource damageSource, int damage) + { + if (!damageSource.isExplosion() && damageSource.isProjectile()) + return false; + return super.attackEntityFrom(damageSource, damage); + } + + public int getMaxHealth () + { + int i = this.getSlimeSize(); + if (i == 1) + return 4; + return (int) Math.min(i * i + 20, 100); + } + + public int getTotalArmorValue () + { + return super.getTotalArmorValue() + 12; + } + + public void setDead () + { + this.isDead = true; + } + + /*protected void dropFewItems (boolean par1, int par2) + { + int j = this.getDropItemId(); + + if (j > 0) + { + int k = rand.nextInt(3) + rand.nextInt(this.getSlimeSize()); + + if (par2 > 0) + { + k += this.rand.nextInt(par2 + 1); + } + + for (int l = 0; l < k; ++l) + { + this.dropItem(j, 1); + } + } + }*/ + + protected void updateEntityActionState () + { + this.despawnEntity(); + EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D); + + if (entityplayer != null) + { + this.faceEntity(entityplayer, 10.0F, 20.0F); + } + else if (this.onGround && this.slimeJumpDelay == 1) + { + this.rotationYaw = this.rotationYaw + rand.nextFloat() * 180 - 90; + if (rotationYaw > 360) + rotationYaw -= 360; + if (rotationYaw < 0) + rotationYaw += 360; + } + + if (this.onGround && this.slimeJumpDelay-- <= 0) + { + this.slimeJumpDelay = this.getJumpDelay(); + + if (entityplayer != null) + { + this.slimeJumpDelay /= 3; + } + + this.isJumping = true; + + if (this.makesSoundOnJump()) + { + this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F); + } + + this.moveStrafing = 1.0F - this.rand.nextFloat() * 2.0F; + this.moveForward = (float) (1 * this.getSlimeSize()); + } + else + { + this.isJumping = false; + + if (this.onGround) + { + this.moveStrafing = this.moveForward = 0.0F; + } + } + } +} diff --git a/tconstruct/entity/MiniGardy.java b/tconstruct/entity/MiniGardy.java new file mode 100644 index 00000000..7181b0b0 --- /dev/null +++ b/tconstruct/entity/MiniGardy.java @@ -0,0 +1,71 @@ +package tconstruct.entity; + +import tconstruct.TConstruct; +import tconstruct.common.TProxyCommon; +import tconstruct.entity.ai.GAIFellTree; +import tconstruct.entity.ai.GAIFollowOwner; +import tconstruct.entity.ai.GAISwim; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MiniGardy extends GolemBase +{ + public MiniGardy(World world) + { + super(world); + //this.texture = "/mods/tinker/textures/mob/googirl.png"; + this.setSize(0.375F, 0.875F); + this.tasks.addTask(1, new GAISwim(this)); + this.tasks.addTask(8, new GAIFellTree(this)); + this.tasks.addTask(10, new GAIFollowOwner(this)); + } + + @Override + public void setupInventory () + { + inventory = new ItemStack[14]; + } + + @SideOnly(Side.CLIENT) + public float getShadowSize () //Opacity, not size + { + return 1.0F; + } + + public boolean interact (EntityPlayer player) + { + if (player.isSneaking()) + { + if (!worldObj.isRemote) + player.openGui(TConstruct.instance, TProxyCommon.miniGardyGui, this.worldObj, this.entityId, 0, 0); + return true; + //return false; + } + else + { + ItemStack stack = this.getHeldItem(); + if (stack == null) + { + ItemStack playerStack = player.getCurrentEquippedItem(); + if (playerStack != null) + { + this.setCurrentItemOrArmor(0, playerStack.copy()); + player.destroyCurrentEquippedItem(); + } + } + else + { + if (player.inventory.addItemStackToInventory(stack.copy())) + { + //this.worldObj.playSoundAtEntity(this, par1Str, par2, par3); + this.worldObj.playSoundAtEntity(player, "random.pop", 0.3F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + this.setCurrentItemOrArmor(0, null); + } + } + return true; + } + } +} diff --git a/tconstruct/entity/Skyla.java b/tconstruct/entity/Skyla.java new file mode 100644 index 00000000..ef201dad --- /dev/null +++ b/tconstruct/entity/Skyla.java @@ -0,0 +1,31 @@ +package tconstruct.entity; + +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.world.World; + +public class Skyla extends EntityCreeper +{ + + public Skyla(World par1World) + { + super(par1World); + //username = "Skyla"; + //texture = "/mods/tinker/textures/mob/skyla.png"; + } + + /*@Override + public void sendChatToPlayer (String var1) {} + + @Override + public boolean canCommandSenderUseCommand (int var1, String var2) + { + return false; + } + + @Override + public ChunkCoordinates getPlayerCoordinates () + { + return null; + }*/ + +} diff --git a/tconstruct/entity/SlimeClone.java b/tconstruct/entity/SlimeClone.java new file mode 100644 index 00000000..4ffe0b72 --- /dev/null +++ b/tconstruct/entity/SlimeClone.java @@ -0,0 +1,175 @@ +package tconstruct.entity; + +import tconstruct.TConstruct; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; + +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; + +public class SlimeClone extends GolemBase implements IEntityAdditionalSpawnData +{ + public float sizeOffset; + public float sizeFactor; + public float sizeHeight; + public String username = ""; + public String skinUrl = ""; + + public SlimeClone(World world) + { + super(world); + //this.texture = "/mob/char.png"; + } + + public SlimeClone(World world, String username) + { + this(world); + this.username = username; + } + + /*@Override + public void initCreature () + { + maxHealth = 100; + //health = 100; + baseAttack = 3; + paused = false; + }*/ + + public void onUpdate () + { + if (!this.worldObj.isRemote && this.worldObj.difficultySetting == 0 && this.getSlimeSize() > 0) + { + this.isDead = true; + } + + this.sizeFactor += (this.sizeOffset - this.sizeFactor) * 0.5F; + this.sizeHeight = this.sizeFactor; + boolean flag = this.onGround; + super.onUpdate(); + float i; + + if (this.onGround && !flag) + { + i = this.getSlimeSize(); + + for (int j = 0; j < i * 8; ++j) + { + float f = this.rand.nextFloat() * (float) Math.PI * 2.0F; + float offset = this.rand.nextFloat() * 0.5F + 0.5F; + float xPos = MathHelper.sin(f) * (float) i * 0.5F * offset; + float zPos = MathHelper.cos(f) * (float) i * 0.5F * offset; + TConstruct.proxy.spawnParticle(this.getSlimeParticle(), this.posX + (double) xPos, this.boundingBox.minY, this.posZ + (double) zPos, 0.0D, 0.0D, 0.0D); + } + + if (this.makesSoundOnLand()) + { + this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F); + } + + this.sizeOffset = -0.5F; + } + else if (!this.onGround && flag) + { + this.sizeOffset = 1.0F; + } + + this.func_70808_l(); + + if (this.worldObj.isRemote) + { + i = this.getSlimeSize(); + this.setSize(0.6F * (float) i, 0.6F * (float) i); + } + } + + protected void func_70808_l () + { + this.sizeOffset *= 0.6F; + } + + protected String getJumpSound () + { + return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small"); + } + + protected void jump () + { + this.motionY = 0.05 * getSlimeSize() + 0.37; + + if (this.isPotionActive(Potion.jump)) + { + this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); + } + + if (this.isSprinting()) + { + float f = this.rotationYaw * 0.017453292F; + this.motionX -= (double) (MathHelper.sin(f) * 0.2F); + this.motionZ += (double) (MathHelper.cos(f) * 0.2F); + } + + this.isAirBorne = true; + ForgeHooks.onLivingJump(this); + } + + protected void fall (float par1) + { + } + + protected String getSlimeParticle () + { + return "blueslime"; + } + + public float getSlimeSize () + { + return 1.5f; + } + + /** + * Returns true if the slime makes a sound when it jumps (based upon the slime's size) + */ + protected boolean makesSoundOnJump () + { + return this.getSlimeSize() > 0; + } + + /** + * Returns true if the slime makes a sound when it lands after a jump (based upon the slime's size) + */ + protected boolean makesSoundOnLand () + { + return this.getSlimeSize() > 2; + } + + public void writeEntityToNBT (NBTTagCompound tags) + { + super.writeEntityToNBT(tags); + tags.setString("Username", username); + } + + public void readEntityFromNBT (NBTTagCompound tags) + { + super.readEntityFromNBT(tags); + username = tags.getString("Username"); + } + + @Override + public void writeSpawnData (ByteArrayDataOutput data) + { + data.writeUTF(username); + } + + @Override + public void readSpawnData (ByteArrayDataInput data) + { + username = data.readUTF(); + skinUrl = "http://skins.minecraft.net/MinecraftSkins/" + username + ".png"; + } +} diff --git a/tconstruct/entity/ai/GAIAttackTarget.java b/tconstruct/entity/ai/GAIAttackTarget.java new file mode 100644 index 00000000..91cf7c1a --- /dev/null +++ b/tconstruct/entity/ai/GAIAttackTarget.java @@ -0,0 +1,138 @@ +package tconstruct.entity.ai; + +import tconstruct.entity.GolemBase; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.pathfinding.PathNavigate; + +public class GAIAttackTarget extends GolemAIBase +{ + private PathNavigate pathfinder; + private EntityLivingBase theTarget; + private float speed; + private int counter; + private boolean avoidsWater = true; + + //public static String targetEntityRegex; + + public GAIAttackTarget(GolemBase doll) + { + super(doll); + this.speed = doll.getSpeed(); + this.pathfinder = doll.getNavigator(); + this.setMutexBits(3); + } + + @Override + public boolean shouldExecute () + { + if (golem.paused) + { + return false; + } + /*if (golem.isStandbyMode() || golem.isRideonMode()) + { + return false; + } + if (golem.getDollID() != DollRegistry.getDollID("Shanghai")) + { + return false; + }*/ + theTarget = golem.getAttackTarget(); + if (theTarget == null) + { + return false; + } + + String name = EntityList.getEntityString(theTarget); + if (name == null) + { + return false; + } + + /*Pattern targetPattern = Pattern.compile(targetEntityRegex); + Matcher targetMatcher = targetPattern.matcher(name); + + if (!targetMatcher.find()) + { + return false; + }*/ + + return true; + } + + @Override + public void startExecuting () + { + counter = 0; + this.avoidsWater = this.golem.getNavigator().getAvoidsWater(); + this.golem.getNavigator().setAvoidsWater(true); + } + + @Override + public boolean continueExecuting () + { + /* if (!golem.isEnable()) + { + return false; + } + if (golem.isStandbyMode() || golem.isRideonMode()) + { + return false; + }*/ + if (this.pathfinder.noPath()) + { + return false; + } + if (this.theTarget == null) + { + return false; + } + if (!this.theTarget.isEntityAlive()) + { + return false; + } + return true; + } + + @Override + public void resetTask () + { + this.theTarget = null; + this.pathfinder.clearPathEntity(); + this.golem.getNavigator().setAvoidsWater(this.avoidsWater); + } + + @Override + public void updateTask () + { + if (!this.pathfinder.noPath()) + { + this.golem.getLookHelper().setLookPositionWithEntity(this.theTarget, 10.0F, (float) this.golem.getVerticalFaceSpeed()); + } + + if (--this.counter <= 0) + { + this.counter = 20; + + this.pathfinder.tryMoveToEntityLiving(this.theTarget, this.speed); + if (this.golem.getDistanceSqToEntity(this.theTarget) < 9f && this.golem.getEntitySenses().canSee(this.theTarget)) + { + if (this.golem.getHeldItem() != null) + { + this.golem.swingItem(); + } + //theTarget.attackEntityFrom(DamageSource.causeMobDamage(golem), attackStrength); + golem.attackEntityAsGolem(theTarget); + + /*if (golem.getOwner() != null) + { + theTarget.attackEntityFrom(DamageSource.causePlayerDamage(golem.getOwner()), attackStrength); + } + else + {*/ + //} + } + } + } +} diff --git a/tconstruct/entity/ai/GAIFellTree.java b/tconstruct/entity/ai/GAIFellTree.java new file mode 100644 index 00000000..ebad4b85 --- /dev/null +++ b/tconstruct/entity/ai/GAIFellTree.java @@ -0,0 +1,233 @@ +package tconstruct.entity.ai; + +import tconstruct.entity.GolemBase; +import net.minecraft.block.Block; +import net.minecraft.block.StepSound; +import net.minecraft.util.MathHelper; + +public class GAIFellTree extends GolemAIBase +{ + private int counter; + private int logID; + private int blockStrength; + private int cutX, cutY, cutZ; + + public static int cutRange = 4; + public static double cutSpeed = 2.5; + + public GAIFellTree(GolemBase doll) + { + super(doll); + this.setMutexBits(3); + } + + @Override + public boolean shouldExecute () + { + if (golem.paused) + { + return false; + } + + int golemX = MathHelper.floor_double(golem.posX); + int golemY = MathHelper.floor_double(golem.posY + (double) golem.getEyeHeight()); + int golemZ = MathHelper.floor_double(golem.posZ); + int logCount = 0; + int leavesCount = 0; + int targetX = cutRange; + int targetY = 0; + int targetZ = cutRange; + boolean isTarget = false; + + for (int iterX = -cutRange; iterX <= cutRange; ++iterX) + { + for (int iterZ = -cutRange; iterZ <= cutRange; ++iterZ) + { + int dy = 0; + int distanceToBlock = Math.abs(iterX) + Math.abs(iterZ); + if (distanceToBlock > cutRange) + { + continue; + } + int bid = world.getBlockId(golemX + iterX, golemY + dy, golemZ + iterZ); + Block log = Block.blocksList[bid]; + if (log == null) + { + continue; + } + + if (log.isWood(world, golemX + iterX, golemY + dy, golemZ + iterZ)) + { + if (Math.abs(targetX) + Math.abs(targetZ) > distanceToBlock) + { + + while (golemY + dy > 0) + { + int cbid = world.getBlockId(golemX + iterX, golemY + dy - 1, golemZ + iterZ); + if (cbid != bid) + { + break; + } + --dy; + } + int lCount = 0; + int blockCount = 0; + while (golemY + dy < world.getHeight()) + { + int cbid = world.getBlockId(golemX + iterX, golemY + dy, golemZ + iterZ); + if (cbid != bid) + { + break; + } + + int[][] coords = new int[][] { { golemX + iterX + 1, golemY + dy, golemZ + iterZ }, { golemX + iterX - 1, golemY + dy, golemZ + iterZ }, + { golemX + iterX, golemY + dy, golemZ + iterZ + 1 }, { golemX + iterX, golemY + dy, golemZ + iterZ - 1 } }; + for (int i = 0; i < 4; ++i) + { + Block leaves = Block.blocksList[world.getBlockId(coords[i][0], coords[i][1], coords[i][2])]; + if (leaves != null && leaves.isLeaves(world, coords[i][0], coords[i][1], coords[i][2])) + { + blockCount++; + } + } + ++lCount; + ++dy; + } + + if (blockCount >= 4) + { + targetX = iterX; + targetY = dy - 1; + targetZ = iterZ; + isTarget = true; + logCount = blockCount; + leavesCount = lCount; + logID = bid; + } + } + } + } + } + golem.targetX = golemX + targetX; + golem.targetY = golemY + targetY; + golem.targetZ = golemZ + targetZ; + golem.targetLock = isTarget; + + if (!isTarget) + { + return false; + } + + golem.teleport((double) (golem.targetX) + 0.5D, (double) (golem.targetY + 1), (double) (golem.targetZ) + 0.5D); + golem.getNavigator().clearPathEntity(); + + return true; + } + + public void startExecuting () + { + counter = 0; + } + + public boolean continueExecuting () + { + if (golem.paused) + { + return false; + } + if (Math.abs(MathHelper.floor_double(golem.posX - golem.targetX)) + Math.abs(MathHelper.floor_double(golem.posY - golem.targetY)) + + Math.abs(MathHelper.floor_double(golem.posZ - golem.targetZ)) > cutRange) + { + System.out.println("Too far away"); + return false; + } + if (!golem.targetLock) + { + System.out.println("Target lost"); + return false; + } + return true; + } + + @Override + public void resetTask () + { + golem.targetLock = false; + } + + @Override + public void updateTask () + { + if (counter == 0) + { + boolean isCutting = false; + for (int dx = -cutRange; dx <= cutRange; ++dx) + { + for (int dz = -cutRange; dz <= cutRange; ++dz) + { + if (Math.abs(dx) + Math.abs(dz) > cutRange) + { + continue; + } + if (world.getBlockId(golem.targetX + dx, golem.targetY, golem.targetZ + dz) == logID) + { + cutX = golem.targetX + dx; + cutY = golem.targetY; + cutZ = golem.targetZ + dz; + isCutting = true; + } + if (isCutting) + { + break; + } + } + if (isCutting) + { + break; + } + } + if (!isCutting) + { + cutX = golem.targetX; + cutY = golem.targetY; + cutZ = golem.targetZ; + golem.targetY--; + if (world.getBlockId(golem.targetX, golem.targetY, golem.targetZ) == logID) + { + isCutting = true; + } + else + { + golem.targetLock = isCutting = false; + return; + } + } + + Block b = Block.blocksList[world.getBlockId(cutX, cutY, cutZ)]; + blockStrength = b == null ? 0 : MathHelper.floor_double(1.0 + 30.0 * b.getBlockHardness(world, cutX, cutY, cutZ) / cutSpeed); + blockStrength = blockStrength < 0 ? 0 : blockStrength; + } + + if (counter >= blockStrength) + { + Block b = Block.blocksList[world.getBlockId(cutX, cutY, cutZ)]; + if (b != null) + { + world.destroyBlock(cutX, cutY, cutZ, true); + } + counter = 0; + return; + } + if (counter % 4 == 0) + { + Block b = Block.blocksList[world.getBlockId(golem.targetX, golem.targetY, golem.targetZ)]; + if (b != null) + { + StepSound stepsound = b.stepSound; + world.playSoundEffect(golem.targetX + 0.5f, golem.targetY + 0.5f, golem.targetZ + 0.5f, stepsound.getBreakSound(), (stepsound.getVolume() + 1.0f) / 8f, stepsound.getPitch() * 0.5f); + } + } + this.golem.getLookHelper().setLookPosition((double) (cutX) + 0.5D, (double) (cutY) + 0.5D, (double) (cutZ) + 0.5D, 20.0F, (float) this.golem.getVerticalFaceSpeed()); + counter++; + } +} diff --git a/tconstruct/entity/ai/GAIFindTarget.java b/tconstruct/entity/ai/GAIFindTarget.java new file mode 100644 index 00000000..673413fd --- /dev/null +++ b/tconstruct/entity/ai/GAIFindTarget.java @@ -0,0 +1,167 @@ +package tconstruct.entity.ai; + +import java.util.List; + +import tconstruct.entity.GolemBase; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntitySheep; + +public class GAIFindTarget extends GolemAIBase +{ + private int counter; + public static double searchRange = 16; + public static double searchHeight = 4; + + public GAIFindTarget(GolemBase golem) + { + super(golem); + this.setMutexBits(8); + } + + public boolean shouldExecute () + { + if (golem.paused) + { + return false; + } + return true; + } + + public void startExecuting () + { + counter = 0; + } + + public boolean continueExecuting () + { + return !golem.paused; + } + + public void updateTask () + { + if (counter == 0) + { + List targetList = (List) (world.getEntitiesWithinAABB(EntityLiving.class, golem.boundingBox.expand(searchRange, searchHeight, searchRange))); + EntityLiving theTarget = null; + EntityLiving stealTarget = null; + + theTarget = null; + for (EntityLiving e : targetList) + { + if (golem.patrolling()) + { + if (e instanceof IMob) + { + if (theTarget == null) + { + theTarget = e; + } + else + { + if (golem.getDistanceSqToEntity(theTarget) > golem.getDistanceSqToEntity(e)) + { + theTarget = e; + } + } + } + } + + if (golem.following()) + { + Entity tt = null; + if (e instanceof EntityCreature) + { + tt = ((EntityCreature) e).getEntityToAttack(); + } + else + { + tt = e.getAttackTarget(); + } + if (golem.isOwner(tt)) + { + if (theTarget == null) + { + theTarget = e; + } + else + { + if (golem.getDistanceSqToEntity(theTarget) > golem.getDistanceSqToEntity(e)) + { + theTarget = e; + } + } + } + } + + if (golem.patrolling()) + { + if (e instanceof EntitySheep) + { + EntitySheep sheep = (EntitySheep) e; + + if (!sheep.getSheared() && !sheep.isChild()) + { + if (stealTarget == null) + { + stealTarget = e; + } + else + { + if (golem.getDistanceSqToEntity(stealTarget) > golem.getDistanceSqToEntity(e)) + { + stealTarget = e; + } + } + } + } + else if (e instanceof EntityChicken || e instanceof EntityMooshroom || e instanceof EntityIronGolem) + { + if (stealTarget == null) + { + stealTarget = e; + } + else + { + if (golem.getDistanceSqToEntity(stealTarget) > golem.getDistanceSqToEntity(e)) + { + stealTarget = e; + } + } + } + } + } + + /*StringBuffer msg = new StringBuffer(golem.getDollName() + " : "); + + if (entityCount.isEmpty()) + { + msg.append("No target"); + golem.chatMessage(msg.toString(), 2); + } + else + { + Iterator it = entityCount.keySet().iterator(); + while (it.hasNext()) + { + String s = (String) it.next(); + int v = entityCount.get(s).intValue(); + msg.append(s); + msg.append("["); + msg.append(v); + msg.append("] "); + } + golem.chatMessage(msg.toString(), 1); + }*/ + + golem.setAttackTarget(theTarget == null ? stealTarget : theTarget); + } + counter = (counter + 1) % 20; + } +} diff --git a/tconstruct/entity/ai/GAIFollowOwner.java b/tconstruct/entity/ai/GAIFollowOwner.java new file mode 100644 index 00000000..cb64969a --- /dev/null +++ b/tconstruct/entity/ai/GAIFollowOwner.java @@ -0,0 +1,106 @@ +package tconstruct.entity.ai; + +import tconstruct.entity.GolemBase; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.pathfinding.PathNavigate; +import net.minecraft.util.MathHelper; + +public class GAIFollowOwner extends GolemAIBase +{ + private EntityLivingBase leader; + private float speed; + private float maxDist; + private float minDist; + private PathNavigate pathfinder; + private boolean avoidsWater; + private int counter; + + public GAIFollowOwner(GolemBase golem) + { + super(golem); + this.speed = golem.getSpeed(); + this.minDist = 4.0f; + this.maxDist = 2.5f; + this.pathfinder = golem.getNavigator(); + this.setMutexBits(3); + } + + public boolean shouldExecute () + { + EntityLivingBase owner = this.golem.getOwner(); + + if (owner == null) + { + return false; + } + if (this.golem.getDistanceSqToEntity(owner) < (double) (this.minDist * this.minDist)) + { + return false; + } + + this.leader = owner; + return true; + } + + public boolean continueExecuting () + { + if (this.pathfinder.noPath()) + { + return false; + } + if (this.golem.getDistanceSqToEntity(this.leader) < (double) (this.maxDist * this.maxDist)) + { + return false; + } + return true; + } + + public void startExecuting () + { + this.counter = 0; + this.avoidsWater = this.golem.getNavigator().getAvoidsWater(); + this.golem.getNavigator().setAvoidsWater(false); + } + + public void resetTask () + { + this.leader = null; + this.pathfinder.clearPathEntity(); + this.golem.getNavigator().setAvoidsWater(this.avoidsWater); + } + + public void updateTask () + { + this.golem.getLookHelper().setLookPositionWithEntity(this.leader, 10.0F, (float) this.golem.getVerticalFaceSpeed()); + + if (--this.counter <= 0) + { + this.counter = 10; + + if (!this.pathfinder.tryMoveToEntityLiving(this.leader, this.speed)) + { + if (this.golem.getDistanceSqToEntity(this.leader) >= 144.0D) + { + int var1 = MathHelper.floor_double(this.leader.posX) - 2; + int var2 = MathHelper.floor_double(this.leader.posZ) - 2; + int var3 = MathHelper.floor_double(this.leader.boundingBox.minY); + + for (int var4 = 0; var4 <= 4; ++var4) + { + for (int var5 = 0; var5 <= 4; ++var5) + { + if ((var4 < 1 || var5 < 1 || var4 > 3 || var5 > 3) && this.world.doesBlockHaveSolidTopSurface(var1 + var4, var3 - 1, var2 + var5) + && !this.world.isBlockNormalCube(var1 + var4, var3, var2 + var5) && !this.world.isBlockNormalCube(var1 + var4, var3 + 1, var2 + var5)) + { + this.golem.setLocationAndAngles((double) ((float) (var1 + var4) + 0.5F), (double) var3, (double) ((float) (var2 + var5) + 0.5F), this.golem.rotationYaw, + this.golem.rotationPitch); + this.pathfinder.clearPathEntity(); + return; + } + } + } + } + } + } + } +} diff --git a/tconstruct/entity/ai/GAISwim.java b/tconstruct/entity/ai/GAISwim.java new file mode 100644 index 00000000..c01750fc --- /dev/null +++ b/tconstruct/entity/ai/GAISwim.java @@ -0,0 +1,38 @@ +package tconstruct.entity.ai; + +import tconstruct.entity.GolemBase; + +public class GAISwim extends GolemAIBase +{ + public GAISwim(GolemBase golem) + { + super(golem); + this.setMutexBits(4); + golem.getNavigator().setCanSwim(true); + } + + public boolean shouldExecute() + { + if(golem.isInWater() || this.golem.handleLavaMovement()) + { + return true; + } + return false; + } + + /*public void startExecuting() + { + if(golem.standby()) + { + golem.setPatrolMode(); + } + }*/ + + public void updateTask() + { + if (this.golem.getRNG().nextFloat() < 0.8F) + { + this.golem.getJumpHelper().setJumping(); + } + } +} diff --git a/tconstruct/entity/ai/GolemAIBase.java b/tconstruct/entity/ai/GolemAIBase.java new file mode 100644 index 00000000..429d2608 --- /dev/null +++ b/tconstruct/entity/ai/GolemAIBase.java @@ -0,0 +1,23 @@ +package tconstruct.entity.ai; + +import tconstruct.entity.GolemBase; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.world.World; + +public class GolemAIBase extends EntityAIBase +{ + protected GolemBase golem; + protected World world; + + public GolemAIBase(GolemBase entity) + { + golem = entity; + world = entity.worldObj; + } + + @Override + public boolean shouldExecute () + { + return false; + } +} diff --git a/tconstruct/entity/projectile/ArrowEntity.java b/tconstruct/entity/projectile/ArrowEntity.java new file mode 100644 index 00000000..fbf9c98f --- /dev/null +++ b/tconstruct/entity/projectile/ArrowEntity.java @@ -0,0 +1,638 @@ +package tconstruct.entity.projectile; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.enchantment.EnchantmentThorns; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.packet.Packet70GameEvent; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ReportedException; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; + +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; + +public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnData +{ + public ItemStack returnStack; + public float mass; + public int baseDamage; + private float knockbackStrengthMod; + + public ArrowEntity(World par1World) + { + super(par1World); + } + + public ArrowEntity(World world, EntityLivingBase living, float baseSpeed, ItemStack stack) + { + super(world, living, baseSpeed); + this.returnStack = stack; + NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool"); + this.mass = toolTag.getFloat("Mass"); + this.baseDamage = toolTag.getInteger("Attack"); + } + + @Override + public void onCollideWithPlayer (EntityPlayer par1EntityPlayer) + { + if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) + { + boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode; + + if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(returnStack)) + { + flag = false; + } + + if (flag) + { + this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + par1EntityPlayer.onItemPickup(this, 1); + this.setDead(); + } + } + } + + @Override + public void onUpdate () + { + this.onEntityUpdate(); + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI); + } + + int i = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + + if (i > 0) + { + Block.blocksList[i].setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile); + AxisAlignedBB axisalignedbb = Block.blocksList[i].getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile); + + if (axisalignedbb != null && axisalignedbb.isVecInside(this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ))) + { + this.inGround = true; + } + } + + if (this.arrowShake > 0) + { + --this.arrowShake; + } + + if (this.inGround) + { + int j = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); + + if (j == this.inTile && k == this.inData) + { + ++this.ticksInGround; + + if (this.ticksInGround == 120000) + { + this.setDead(); + } + } + else + { + this.inGround = false; + this.motionX *= (double) (this.rand.nextFloat() * 0.2F); + this.motionY *= (double) (this.rand.nextFloat() * 0.2F); + this.motionZ *= (double) (this.rand.nextFloat() * 0.2F); + this.ticksInGround = 0; + this.ticksInAir = 0; + } + } + else + { + ++this.ticksInAir; + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks_do_do(vec3, vec31, false, true); + vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (movingobjectposition != null) + { + vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + + Entity entity = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + int l; + float ySpeed; + + for (l = 0; l < list.size(); ++l) + { + Entity entity1 = (Entity) list.get(l); + + if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) + { + ySpeed = 0.3F; + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) ySpeed, (double) ySpeed, (double) ySpeed); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) + { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) + { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) + { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; + + if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).func_96122_a(entityplayer)) + { + movingobjectposition = null; + } + } + + float speed; + float f3; + + if (movingobjectposition != null) + { + if (movingobjectposition.entityHit != null) + { + speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + double damageSpeed = (double) speed * this.damage; + damageSpeed *= baseDamage; + damageSpeed /= 5D; + int damageInflicted = MathHelper.ceiling_double_int(damageSpeed); + + if (this.getIsCritical()) + { + damageInflicted += this.rand.nextInt(damageInflicted / 2 + 2); + } + + if (!worldObj.isRemote) + { + System.out.println("Speed: " + damageSpeed); + System.out.println("Damage: " + damageInflicted); + } + DamageSource damagesource = null; + + if (this.shootingEntity == null) + { + damagesource = DamageSource.causeArrowDamage(this, this); + } + else + { + damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity); + } + + if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) + { + movingobjectposition.entityHit.setFire(5); + } + + if (movingobjectposition.entityHit.attackEntityFrom(damagesource, damageInflicted)) + { + if (movingobjectposition.entityHit instanceof EntityLivingBase) + { + EntityLivingBase entityliving = (EntityLivingBase) movingobjectposition.entityHit; + + if (!this.worldObj.isRemote) + { + entityliving.setArrowCountInEntity(entityliving.getArrowCountInEntity() + 1); + } + + if (this.knockbackStrength > 0 || this.knockbackStrengthMod > 0) + { + f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (f3 > 0.0F) + { + float knockback = knockbackStrength + knockbackStrengthMod; + movingobjectposition.entityHit.addVelocity(this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f3, 0.1D, this.motionZ + * (double) knockback * 0.6000000238418579D / (double) f3); + } + } + + if (this.shootingEntity != null) + { + EnchantmentThorns.func_92096_a(this.shootingEntity, entityliving, this.rand); + } + + if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer + && this.shootingEntity instanceof EntityPlayerMP) + { + ((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0)); + } + } + + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + + if (!(movingobjectposition.entityHit instanceof EntityEnderman)) + { + this.motionX = 0; + this.motionZ = 0; + if (movingobjectposition.entityHit instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) movingobjectposition.entityHit; + if (player.inventory.addItemStackToInventory(returnStack)) + this.setDead(); + } + else if (movingobjectposition.entityHit instanceof EntityLivingBase) + { + EntityLivingBase living = (EntityLivingBase) movingobjectposition.entityHit; + if (addItemStackToInventory(returnStack, living)) + this.setDead(); + } + } + } + else + { + this.motionX *= -0.10000000149011612D; + this.motionY *= -0.10000000149011612D; + this.motionZ *= -0.10000000149011612D; + this.rotationYaw += 180.0F; + this.prevRotationYaw += 180.0F; + this.ticksInAir = 0; + } + } + else + { + this.xTile = movingobjectposition.blockX; + this.yTile = movingobjectposition.blockY; + this.zTile = movingobjectposition.blockZ; + this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); + this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX)); + this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY)); + this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); + speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.posX -= this.motionX / (double) speed * 0.05000000074505806D; + this.posY -= this.motionY / (double) speed * 0.05000000074505806D; + this.posZ -= this.motionZ / (double) speed * 0.05000000074505806D; + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + this.arrowShake = 7; + this.setIsCritical(false); + + if (this.inTile != 0) + { + Block.blocksList[this.inTile].onEntityCollidedWithBlock(this.worldObj, this.xTile, this.yTile, this.zTile, this); + } + } + } + + if (this.getIsCritical()) + { + for (l = 0; l < 4; ++l) + { + this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double) l / 4.0D, this.posY + this.motionY * (double) l / 4.0D, this.posZ + this.motionZ * (double) l / 4.0D, + -this.motionX, -this.motionY + 0.2D, -this.motionZ); + } + } + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) speed) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float dropSpeed = 0.99F; + float speedMod = 1.05f + (mass / 1.26F) / 6F; + ySpeed = 0.05F * speedMod; + + if (this.isInWater()) + { + for (int j1 = 0; j1 < 4; ++j1) + { + f3 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f3, this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX, + this.motionY, this.motionZ); + } + + dropSpeed = 0.8F; + } + + this.motionX *= (double) dropSpeed; + this.motionY *= (double) dropSpeed; + this.motionZ *= (double) dropSpeed; + this.motionY -= (double) ySpeed; + this.setPosition(this.posX, this.posY, this.posZ); + this.doBlockCollisions(); + } + } + + public boolean addItemStackToInventory (ItemStack par1ItemStack, EntityLivingBase living) + { + if (par1ItemStack == null) + { + return false; + } + else + { + try + { + int stackSize; + + /*if (par1ItemStack.isItemDamaged()) + { + slotID = this.getFirstEmptyStack(living); + + if (slotID >= 0) + { + living.setCurrentItemOrArmor(slotID, par1ItemStack); + living.func_96120_a(slotID, 2.0f); + par1ItemStack.stackSize = 0; + return true; + } + else + { + return false; + } + } + else*/ + { + do + { + stackSize = par1ItemStack.stackSize; + par1ItemStack.stackSize = this.storePartialItemStack(par1ItemStack, living); + } while (par1ItemStack.stackSize > 0 && par1ItemStack.stackSize < stackSize); + + return par1ItemStack.stackSize < stackSize; + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding item to inventory"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added"); + crashreportcategory.addCrashSection("Item ID", Integer.valueOf(par1ItemStack.itemID)); + crashreportcategory.addCrashSection("Item data", Integer.valueOf(par1ItemStack.getItemDamage())); + //crashreportcategory.addCrashSectionCallable("Item name", new CallableItemName(this, par1ItemStack)); + throw new ReportedException(crashreport); + } + } + } + + public int getFirstEmptyStack (EntityLivingBase living) + { + for (int i = 0; i < 5; ++i) + { + if (living.getCurrentItemOrArmor(i) == null) + { + return i; + } + } + + return -1; + } + + private int storePartialItemStack (ItemStack par1ItemStack, EntityLivingBase living) + { + int i = par1ItemStack.itemID; + int j = par1ItemStack.stackSize; + int slotID; + + if (par1ItemStack.getMaxStackSize() == 1) + { + slotID = this.getFirstEmptyStack(living); + + if (slotID < 0) + { + return j; + } + else + { + /*if (this.mainInventory[k] == null) + { + this.mainInventory[k] = par1ItemStack; + }*/ + if (living.getCurrentItemOrArmor(slotID) == null) + { + living.setCurrentItemOrArmor(slotID, par1ItemStack); + if (living instanceof EntityLiving) + ((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f); + } + + return 0; + } + } + else + { + slotID = this.storeItemStack(par1ItemStack, living); + + if (slotID < 0) + { + slotID = this.getFirstEmptyStack(living); + } + + if (slotID < 0) + { + return j; + } + else + { + ItemStack stack = living.getCurrentItemOrArmor(slotID); + if (stack == null) + { + living.setCurrentItemOrArmor(slotID, par1ItemStack); + if (living instanceof EntityLiving) + ((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f); + return par1ItemStack.stackSize; + } + else + { + + int l = j; + + if (j > stack.getMaxStackSize() - stack.stackSize) + { + l = stack.getMaxStackSize() - stack.stackSize; + } + + if (l > 64 - stack.stackSize) + { + l = 64 - stack.stackSize; + } + + if (l == 0) + { + return j; + } + else + { + j -= l; + stack.stackSize++; + living.setCurrentItemOrArmor(slotID, stack); + if (living instanceof EntityLiving) + ((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f); + return j; + } + } + } + } + } + + private int storeItemStack (ItemStack par1ItemStack, EntityLivingBase living) + { + for (int slotID = 0; slotID < 5; ++slotID) + { + ItemStack stack = living.getCurrentItemOrArmor(slotID); + if (stack != null && stack.itemID == par1ItemStack.itemID && stack.isStackable() && stack.stackSize < stack.getMaxStackSize() && stack.stackSize < 64 + && (!stack.getHasSubtypes() || stack.getItemDamage() == par1ItemStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack, par1ItemStack)) + { + return slotID; + } + } + + return -1; + } + + public void setKnockbackModStrength (float par1) + { + this.knockbackStrengthMod = par1; + } + + public void writeEntityToNBT (NBTTagCompound tags) + { + super.writeEntityToNBT(tags); + tags.setCompoundTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound())); + } + + public void readEntityFromNBT (NBTTagCompound tags) + { + super.readEntityFromNBT(tags); + this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable")); + } + + @Override + public void writeSpawnData (ByteArrayDataOutput data) + { + if (!returnStack.hasTagCompound()) + this.kill(); + NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool"); + data.writeShort(returnStack.itemID); + data.writeFloat(rotationYaw); + data.writeFloat(mass); + data.writeInt(tags.getInteger("RenderHandle")); + data.writeInt(tags.getInteger("RenderHead")); + data.writeInt(tags.getInteger("RenderAccessory")); + + int effects = 0; + if (tags.hasKey("Effect1")) + effects++; + if (tags.hasKey("Effect2")) + effects++; + if (tags.hasKey("Effect3")) + effects++; + if (tags.hasKey("Effect4")) + effects++; + if (tags.hasKey("Effect5")) + effects++; + if (tags.hasKey("Effect6")) + effects++; + data.writeInt(effects); + + switch (effects) + { + case 6: + data.writeInt(tags.getInteger("Effect6")); + case 5: + data.writeInt(tags.getInteger("Effect5")); + case 4: + data.writeInt(tags.getInteger("Effect4")); + case 3: + data.writeInt(tags.getInteger("Effect3")); + case 2: + data.writeInt(tags.getInteger("Effect2")); + case 1: + data.writeInt(tags.getInteger("Effect1")); + } + } + + @Override + public void readSpawnData (ByteArrayDataInput data) + { + returnStack = new ItemStack(data.readShort(), 1, 0); + rotationYaw = data.readFloat(); + mass = data.readFloat(); + NBTTagCompound compound = new NBTTagCompound(); + NBTTagCompound toolTag = new NBTTagCompound(); + toolTag.setInteger("RenderHandle", data.readInt()); + toolTag.setInteger("RenderHead", data.readInt()); + toolTag.setInteger("RenderAccessory", data.readInt()); + switch (data.readInt()) + { + case 6: + toolTag.setInteger("Effect6", data.readInt()); + case 5: + toolTag.setInteger("Effect5", data.readInt()); + case 4: + toolTag.setInteger("Effect4", data.readInt()); + case 3: + toolTag.setInteger("Effect3", data.readInt()); + case 2: + toolTag.setInteger("Effect2", data.readInt()); + case 1: + toolTag.setInteger("Effect1", data.readInt()); + } + compound.setCompoundTag("InfiTool", toolTag); + returnStack.setTagCompound(compound); + } + + public ItemStack getEntityItem () + { + return returnStack; + } +} diff --git a/tconstruct/entity/projectile/DaggerEntity.java b/tconstruct/entity/projectile/DaggerEntity.java new file mode 100644 index 00000000..439a8dcc --- /dev/null +++ b/tconstruct/entity/projectile/DaggerEntity.java @@ -0,0 +1,94 @@ +package tconstruct.entity.projectile; + +import tconstruct.items.tools.Dagger; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.ToolCore; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class DaggerEntity extends RotatingBase +{ + + public DaggerEntity(World world) + { + super(world); + } + + public DaggerEntity(ItemStack itemstack, World world, EntityPlayer entityplayer) + { + super(world, entityplayer, 0.75F, 0.8F); + //System.out.println("Stack: "+itemstack); + returnStackSlot = entityplayer.inventory.currentItem; + returnStack = itemstack; + } + + public DaggerEntity(World world, EntityPlayer entityplayer, float f, float g) + { + super(world, entityplayer, f, g); + } + + /*public void entityInit () + { + super.entityInit(); + }*/ + + @Override + public void onHit (MovingObjectPosition movingobjectposition) + { + if (movingobjectposition.entityHit != null) + { + if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeMobDamage(owner), damageDealt)) + { + worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F)); + motionX *= -0.1D; + motionY *= -0.1D; + motionZ *= -0.1D; + rotationYaw += 180F; + prevRotationYaw += 180F; + ticksInAir = 0; + if (movingobjectposition.entityHit instanceof EntityLiving) + { + Dagger dagger = (Dagger) returnStack.getItem(); + this.hitEntity(returnStack, (EntityLiving) movingobjectposition.entityHit, owner, dagger); + } + } + } + else + { + onGround = true; + xTile = movingobjectposition.blockX; + yTile = movingobjectposition.blockY; + zTile = movingobjectposition.blockZ; + inTile = worldObj.getBlockId(xTile, yTile, zTile); + motionX = (float) (movingobjectposition.hitVec.xCoord - posX); + motionY = (float) (movingobjectposition.hitVec.yCoord - posY); + motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ); + float f = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ); + posX -= (motionX / (double) f) * 0.05D; + posY -= (motionY / (double) f) * 0.05D; + posZ -= (motionZ / (double) f) * 0.05D; + worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F)); + arrowShake = 7; + if (!worldObj.isRemote) + AbilityHelper.damageTool(returnStack, 1, owner, false); + } + } + + public boolean hitEntity (ItemStack stack, EntityLiving mob, EntityPlayer player, ToolCore weapon) + { + if (!worldObj.isRemote && player.canAttackWithItem()) + { + AbilityHelper.onLeftClickEntity(stack, player, mob, weapon); + } + return true; + } + + protected void dealFireDamage (int i) + { + } +} diff --git a/tconstruct/entity/projectile/LaunchedPotion.java b/tconstruct/entity/projectile/LaunchedPotion.java new file mode 100644 index 00000000..fb0dea85 --- /dev/null +++ b/tconstruct/entity/projectile/LaunchedPotion.java @@ -0,0 +1,192 @@ +package tconstruct.entity.projectile; + +import java.util.Iterator; +import java.util.List; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class LaunchedPotion extends EntityThrowable +{ + /** + * The damage value of the thrown potion that this EntityPotion represents. + */ + private ItemStack potionDamage; + + public LaunchedPotion(World par1World) + { + super(par1World); + } + + public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, int par3) + { + this(par1World, par2EntityLiving, new ItemStack(Item.potion, 1, par3)); + } + + public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, ItemStack par3ItemStack) + { + super(par1World, par2EntityLiving); + this.potionDamage = par3ItemStack; + } + + @SideOnly(Side.CLIENT) + public LaunchedPotion(World par1World, double par2, double par4, double par6, int par8) + { + this(par1World, par2, par4, par6, new ItemStack(Item.potion, 1, par8)); + } + + public LaunchedPotion(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) + { + super(par1World, par2, par4, par6); + this.potionDamage = par8ItemStack; + } + + /** + * Gets the amount of gravity to apply to the thrown entity with each tick. + */ + protected float getGravityVelocity () + { + return 0.05F; + } + + protected float func_70182_d () + { + return 1.0F; + } + + protected float func_70183_g () + { + return -10.0F; + } + + public void setPotionDamage (int par1) + { + if (this.potionDamage == null) + { + this.potionDamage = new ItemStack(Item.potion, 1, 0); + } + + this.potionDamage.setItemDamage(par1); + } + + /** + * Returns the damage value of the thrown potion that this EntityPotion represents. + */ + public int getPotionDamage () + { + if (this.potionDamage == null) + { + this.potionDamage = new ItemStack(Item.potion, 1, 0); + } + + return this.potionDamage.getItemDamage(); + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + protected void onImpact (MovingObjectPosition par1MovingObjectPosition) + { + if (!this.worldObj.isRemote) + { + List list = Item.potion.getEffects(this.potionDamage); + + if (list != null && !list.isEmpty()) + { + AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D); + List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + + if (list1 != null && !list1.isEmpty()) + { + Iterator iterator = list1.iterator(); + + while (iterator.hasNext()) + { + EntityLivingBase entityliving = (EntityLivingBase) iterator.next(); + double d0 = this.getDistanceSqToEntity(entityliving); + + if (d0 < 16.0D) + { + double d1 = 1.0D - Math.sqrt(d0) / 4.0D; + + if (entityliving == par1MovingObjectPosition.entityHit) + { + d1 = 1.0D; + } + + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) + { + PotionEffect potioneffect = (PotionEffect) iterator1.next(); + int i = potioneffect.getPotionID(); + + if (Potion.potionTypes[i].isInstant()) + { + Potion.potionTypes[i].affectEntity(this.getThrower(), entityliving, potioneffect.getAmplifier(), d1); + } + else + { + int j = (int) (d1 * (double) potioneffect.getDuration() + 0.5D); + + if (j > 20) + { + entityliving.addPotionEffect(new PotionEffect(i, j, potioneffect.getAmplifier())); + } + } + } + } + } + } + } + + this.worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), this.getPotionDamage()); + this.setDead(); + } + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.hasKey("Potion")) + { + this.potionDamage = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Potion")); + } + else + { + this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue")); + } + + if (this.potionDamage == null) + { + this.setDead(); + } + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + + if (this.potionDamage != null) + { + par1NBTTagCompound.setCompoundTag("Potion", this.potionDamage.writeToNBT(new NBTTagCompound())); + } + } +} diff --git a/tconstruct/entity/projectile/RotatingBase.java b/tconstruct/entity/projectile/RotatingBase.java new file mode 100644 index 00000000..deeac382 --- /dev/null +++ b/tconstruct/entity/projectile/RotatingBase.java @@ -0,0 +1,486 @@ +package tconstruct.entity.projectile; + +import java.util.List; + +import tconstruct.library.tools.AbilityHelper; + + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; + +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; + +public class RotatingBase extends Entity implements IEntityAdditionalSpawnData +{ + + public RotatingBase(World world) + { + super(world); + texID = 0; + tex2ID = 16 * 3; + returnStackSlot = -1; + hasHitGround = false; + hasHitMob = false; + damageDealt = 4; + maxGroundTicks = 2400; + xTile = -1; + yTile = -1; + zTile = -1; + inTile = 0; + onGround = false; + arrowShake = 0; + ticksInAir = 0; + setSize(0.5F, 0.5F); + } + + public RotatingBase(World world, double d, double d1, double d2) + { + this(world); + setPosition(d, d1, d2); + yOffset = 0.0F; + } + + public RotatingBase(World world, EntityPlayer entityliving, float f, float f1) + { + this(world); + owner = entityliving; + setLocationAndAngles(entityliving.posX, entityliving.posY + (double) entityliving.getEyeHeight(), entityliving.posZ, entityliving.rotationYaw, entityliving.rotationPitch); + posX -= MathHelper.cos((rotationYaw / 180F) * 3.141593F) * 0.16F; + posY -= 0.10000000149011612D; + posZ -= MathHelper.sin((rotationYaw / 180F) * 3.141593F) * 0.16F; + setPosition(posX, posY, posZ); + yOffset = 0.0F; + motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F); + motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F); + motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F - 0.2f); + setArrowHeading(motionX, motionY, motionZ, f, f1); + } + + /*public void setOnGround(boolean flag) + { + onGround = flag; + this.dataWatcher.updateObject(6, Byte.valueOf((byte) (flag == true ? 1 : 0))); + } + + public boolean getOnGround() + { + return this.dataWatcher.getWatchableObjectByte(0) == 1 ? true : false; + }*/ + + @Override + protected void entityInit () + { + } + + public void damageItem (int i, boolean flag) + { + if (!flag) + { + return; + } + if (returnStack.stackSize < 1) + { + for (int j = 0; j < 8; j++) + { + worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D); + } + + //kill(); + } + } + + /* + public void returnToPlayer() + { + damageDagger(0, true); + if(returnStack.stackSize < 1) + { + return; + } + if(returnStackSlot > 0) + { + mod_Infi2x2.forceAddToInv((EntityPlayer)returnsTo, returnStack, returnStackSlot, true); + } else + { + mod_Infi2x2.addToInv((EntityPlayer)returnsTo, returnStack, true); + } + } + */ + + public void determineRotation () + { + rotationPitch = -57.29578F * (float) Math.atan2(motionY, motionX); + double d = Math.sqrt((double) (rotationYaw * rotationYaw) + motionY * motionY); + prevRotationYaw = -57.29578F * (float) Math.atan2(motionZ, d); + } + + public void onHit (MovingObjectPosition movingobjectposition) + { + } + + public void setArrowHeading (double d, double d1, double d2, float f, float f1) + { + float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2); + d /= f2; + d1 /= f2; + d2 /= f2; + d += rand.nextGaussian() * 0.0074999998323619366D * (double) f1; + d1 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1; + d2 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1; + d *= f; + d1 *= f; + d2 *= f; + motionX = d; + motionY = d1; + motionZ = d2; + float f3 = MathHelper.sqrt_double(d * d + d2 * d2); + prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D); + prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f3) * 180D) / 3.1415927410125732D); + ticksInGround = 0; + } + + @Override + public void setVelocity (double d, double d1, double d2) + { + motionX = d; + motionY = d1; + motionZ = d2; + if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(d * d + d2 * d2); + prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D); + prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f) * 180D) / 3.1415927410125732D); + } + } + + @Override + public void onUpdate () + { + super.onUpdate(); + if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI); + prevRotationPitch = rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI); + } + if (arrowShake > 0) + { + arrowShake--; + } + if (onGround) + { + int i = worldObj.getBlockId(xTile, yTile, zTile); + if (i != inTile) + { + onGround = false; + motionX *= rand.nextFloat() * 0.2F; + motionY *= rand.nextFloat() * 0.2F; + motionZ *= rand.nextFloat() * 0.2F; + ticksInGround = 0; + ticksInAir = 0; + } + else + { + /*this.motionX = 0; + this.motionY = 0; + this.motionZ = 0;*/ + /*ticksInGround++; + if (ticksInGround == 1200) + { + setDead(); + } + if (ticksInGround == maxGroundTicks) + { + setDead(); + }*/ + if (!hasHitGround) + { + hasHitGround = true; + damageItem(1, true); + } + return; + } + return; + } + else + { + ticksInAir++; + } + Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ); + Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + MovingObjectPosition movingobjectposition = worldObj.clip(vec3d, vec3d1); + vec3d = Vec3.createVectorHelper(posX, posY, posZ); + vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + if (movingobjectposition != null) + { + vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + Entity entity = null; + List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); + double d = 0.0D; + for (int j = 0; j < list.size(); j++) + { + Entity entity1 = (Entity) list.get(j); + if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5) + { + continue; + } + float f3 = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f3, f3, f3); + MovingObjectPosition movingobjectposition2 = axisalignedbb.calculateIntercept(vec3d, vec3d1); + if (movingobjectposition2 == null) + { + continue; + } + double d1 = vec3d.distanceTo(movingobjectposition2.hitVec); + if (d1 < d || d == 0.0D) + { + entity = entity1; + d = d1; + } + } + + if (entity != null) + { + MovingObjectPosition movingobjectposition1 = new MovingObjectPosition(entity); + onHit(movingobjectposition1); + } + if (movingobjectposition != null) + { + onHit(movingobjectposition); + } + posX += motionX; + posY += motionY; + posZ += motionZ; + float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D); + for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) + { + } + for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) + { + } + for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) + { + } + for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) + { + } + rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; + rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; + float f2 = 0.99F; + float f4 = 0.03F; + if (isInWater()) + { + for (int k = 0; k < 4; k++) + { + float f5 = 0.25F; + worldObj.spawnParticle("bubble", posX - motionX * (double) f5, posY - motionY * (double) f5, posZ - motionZ * (double) f5, motionX, motionY, motionZ); + } + + f2 = 0.8F; + } + motionX *= f2; + motionY *= f2; + motionZ *= f2; + motionY -= f4; + setPosition(posX, posY, posZ); + if (!onGround) + { + prevBoomerangRotation = boomerangRotation; + for (boomerangRotation += 36F; boomerangRotation > 360F; boomerangRotation -= 360F) + { + } + } + } + + /*public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.hasKey("Potion")) + { + this.potionDamage = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Potion")); + } + else + { + this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue")); + } + + if (this.potionDamage == null) + { + this.setDead(); + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + + if (this.potionDamage != null) + { + + } + }*/ + + public void writeEntityToNBT (NBTTagCompound tags) + { + tags.setCompoundTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound())); + tags.setShort("xTile", (short) xTile); + tags.setShort("yTile", (short) yTile); + tags.setShort("zTile", (short) zTile); + tags.setByte("inTile", (byte) inTile); + tags.setByte("shake", (byte) arrowShake); + tags.setByte("onGround", (byte) (onGround ? 1 : 0)); + } + + public void readEntityFromNBT (NBTTagCompound tags) + { + //super.readEntityFromNBT(tags); + + this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable")); + xTile = tags.getShort("xTile"); + yTile = tags.getShort("yTile"); + zTile = tags.getShort("zTile"); + inTile = tags.getByte("inTile") & 0xff; + arrowShake = tags.getByte("shake") & 0xff; + onGround = tags.getByte("onGround") == 1; + } + + public void onCollideWithPlayer (EntityPlayer entityplayer) + { + onCollideWithPlayer(entityplayer, true); + } + + public void onCollideWithPlayer (EntityPlayer entityplayer, boolean flag) + { + if (returnStack == null || returnStack.stackSize == 0 || worldObj.isRemote) + { + return; + } + if (!flag || onGround && arrowShake <= 0) + { + if (!flag || returnsTo != null && !returnsTo.isDead && returnsTo != entityplayer) + { + return; + } + AbilityHelper.addToInv(entityplayer, returnStack, true); + worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + entityplayer.onItemPickup(this, 1); + kill(); + } + } + + public float getShadowSize () + { + return 0.0F; + } + + public ItemStack getEntityItem () + { + return returnStack; + } + + public int age = 0; + public int hoverStart = 0; + public int texID; + public int tex2ID; + public ItemStack returnStack; + public int returnStackSlot; + public boolean hasHitGround; + public boolean hasHitMob; + public float prevBoomerangRotation; + public float boomerangRotation; + public Entity returnsTo; + public int damageDealt; + public int maxGroundTicks; + protected int xTile; + protected int yTile; + protected int zTile; + protected int inTile; + public int arrowShake; + public EntityPlayer owner; + protected int ticksInGround; + protected int ticksInAir; + + @Override + public void writeSpawnData (ByteArrayDataOutput data) + { + NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool"); + data.writeShort(returnStack.itemID); + data.writeFloat(rotationYaw); + data.writeInt(tags.getInteger("RenderHandle")); + data.writeInt(tags.getInteger("RenderHead")); + data.writeInt(tags.getInteger("RenderAccessory")); + + int effects = 0; + if (tags.hasKey("Effect1")) + effects++; + if (tags.hasKey("Effect2")) + effects++; + if (tags.hasKey("Effect3")) + effects++; + if (tags.hasKey("Effect4")) + effects++; + if (tags.hasKey("Effect5")) + effects++; + if (tags.hasKey("Effect6")) + effects++; + data.writeInt(effects); + + switch (effects) + { + case 6: + data.writeInt(tags.getInteger("Effect6")); + case 5: + data.writeInt(tags.getInteger("Effect5")); + case 4: + data.writeInt(tags.getInteger("Effect4")); + case 3: + data.writeInt(tags.getInteger("Effect3")); + case 2: + data.writeInt(tags.getInteger("Effect2")); + case 1: + data.writeInt(tags.getInteger("Effect1")); + } + } + + @Override + public void readSpawnData (ByteArrayDataInput data) + { + returnStack = new ItemStack(data.readShort(), 1, 0); + rotationYaw = data.readFloat(); + NBTTagCompound compound = new NBTTagCompound(); + NBTTagCompound toolTag = new NBTTagCompound(); + toolTag.setInteger("RenderHandle", data.readInt()); + toolTag.setInteger("RenderHead", data.readInt()); + toolTag.setInteger("RenderAccessory", data.readInt()); + switch (data.readInt()) + { + case 6: + toolTag.setInteger("Effect6", data.readInt()); + case 5: + toolTag.setInteger("Effect5", data.readInt()); + case 4: + toolTag.setInteger("Effect4", data.readInt()); + case 3: + toolTag.setInteger("Effect3", data.readInt()); + case 2: + toolTag.setInteger("Effect2", data.readInt()); + case 1: + toolTag.setInteger("Effect1", data.readInt()); + } + compound.setCompoundTag("InfiTool", toolTag); + returnStack.setTagCompound(compound); + } +} diff --git a/tconstruct/inventory/ActiveContainer.java b/tconstruct/inventory/ActiveContainer.java new file mode 100644 index 00000000..a32e8b41 --- /dev/null +++ b/tconstruct/inventory/ActiveContainer.java @@ -0,0 +1,27 @@ +package tconstruct.inventory; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; + +public class ActiveContainer extends Container +{ + public List activeInventorySlots = new ArrayList(); + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return false; + } + + protected ActiveSlot addDualSlotToContainer (ActiveSlot slot) + { + slot.activeSlotNumber = this.activeInventorySlots.size(); + this.activeInventorySlots.add(slot); + this.addSlotToContainer(slot); + return slot; + } + +} diff --git a/tconstruct/inventory/ActiveSlot.java b/tconstruct/inventory/ActiveSlot.java new file mode 100644 index 00000000..2a67e3cb --- /dev/null +++ b/tconstruct/inventory/ActiveSlot.java @@ -0,0 +1,26 @@ +package tconstruct.inventory; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; + +public class ActiveSlot extends Slot +{ + protected boolean active; + public int activeSlotNumber; + + public ActiveSlot(IInventory iinventory, int par2, int par3, int par4, boolean flag) + { + super(iinventory, par2, par3, par4); + active = flag; + } + + public void setActive (boolean flag) + { + active = flag; + } + + public boolean getActive () + { + return active; + } +} diff --git a/tconstruct/inventory/AggregatorContainer.java b/tconstruct/inventory/AggregatorContainer.java new file mode 100644 index 00000000..77d92739 --- /dev/null +++ b/tconstruct/inventory/AggregatorContainer.java @@ -0,0 +1,81 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.GlowstoneAggregator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class AggregatorContainer extends Container +{ + public GlowstoneAggregator logic; + public int progress = 0; + public int fuel = 0; + public int fuelGague = 0; + + public AggregatorContainer(InventoryPlayer inventoryplayer, GlowstoneAggregator logic) + { + this.logic = logic; + + this.addSlotToContainer(new Slot(logic, 0, 45, 36)); + this.addSlotToContainer(new Slot(logic, 1, 80, 36)); + this.addSlotToContainer(new Slot(logic, 2, 123, 36)); + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + } + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return logic.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < logic.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } +} diff --git a/tconstruct/inventory/ArmorExtendedContainer.java b/tconstruct/inventory/ArmorExtendedContainer.java new file mode 100644 index 00000000..b9901a74 --- /dev/null +++ b/tconstruct/inventory/ArmorExtendedContainer.java @@ -0,0 +1,59 @@ +package tconstruct.inventory; + +import tconstruct.util.player.ArmorExtended; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ArmorExtendedContainer extends ActiveContainer +{ + public InventoryPlayer invPlayer; + public ArmorExtended armor; + + public ArmorExtendedContainer(InventoryPlayer inventoryplayer, ArmorExtended armor) + { + invPlayer = inventoryplayer; + this.armor = armor; + + this.addSlotToContainer(new Slot(armor, 0, 80, 17)); + this.addSlotToContainer(new Slot(armor, 1, 80, 35)); + this.addSlotToContainer(new Slot(armor, 2, 116, 17)); + this.addSlotToContainer(new Slot(armor, 3, 116, 35)); + this.addSlotToContainer(new Slot(armor, 4, 152, 17)); + this.addSlotToContainer(new Slot(armor, 5, 152, 35)); + this.addSlotToContainer(new Slot(armor, 6, 152, 53)); + + /* Player inventory */ + for (int playerArmor = 0; playerArmor < 4; ++playerArmor) + { + this.addSlotToContainer(new SlotArmorCopy(this, inventoryplayer, inventoryplayer.getSizeInventory() - 1 - playerArmor, 98, 8 + playerArmor * 18, playerArmor)); + } + + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + + } + + @Override + public boolean canInteractWith (EntityPlayer var1) + { + return true; + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + return null; + } +} diff --git a/tconstruct/inventory/DrawbridgeContainer.java b/tconstruct/inventory/DrawbridgeContainer.java new file mode 100644 index 00000000..5a93181d --- /dev/null +++ b/tconstruct/inventory/DrawbridgeContainer.java @@ -0,0 +1,80 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.DrawbridgeLogic; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class DrawbridgeContainer extends Container +{ + public DrawbridgeLogic logic; + public int progress = 0; + public int fuel = 0; + public int fuelGague = 0; + + public DrawbridgeContainer(InventoryPlayer inventoryplayer, DrawbridgeLogic logic) + { + this.logic = logic; + + this.addSlotToContainer(new DrawbridgeSlot(logic, 0, 80, 36, logic)); + this.addSlotToContainer(new Slot(logic, 1, 35, 36)); + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + } + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return logic.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < logic.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } +} diff --git a/tconstruct/inventory/DrawbridgeSlot.java b/tconstruct/inventory/DrawbridgeSlot.java new file mode 100644 index 00000000..fbe897cf --- /dev/null +++ b/tconstruct/inventory/DrawbridgeSlot.java @@ -0,0 +1,28 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.DrawbridgeLogic; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class DrawbridgeSlot extends Slot +{ + DrawbridgeLogic logic; + public DrawbridgeSlot(IInventory iinventory, int par2, int par3, int par4, DrawbridgeLogic logic) + { + super(iinventory, par2, par3, par4); + this.logic = logic; + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return !logic.hasExtended(); + } + + + public boolean canTakeStack(EntityPlayer par1EntityPlayer) + { + return !logic.hasExtended(); + } +} diff --git a/tconstruct/inventory/FrypanContainer.java b/tconstruct/inventory/FrypanContainer.java new file mode 100644 index 00000000..09f9f4eb --- /dev/null +++ b/tconstruct/inventory/FrypanContainer.java @@ -0,0 +1,123 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.FrypanLogic; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class FrypanContainer extends Container +{ + public FrypanLogic logic; + public int progress = 0; + public int fuel = 0; + public int fuelGague = 0; + + public FrypanContainer(InventoryPlayer inventoryplayer, FrypanLogic frypan) + { + logic = frypan; + this.addSlotToContainer(new Slot(frypan, 1, 26, 45)); + for (int y = 0; y < 2; y++) + for (int x = 0; x < 4; x++) + this.addSlotToContainer(new Slot(frypan, 2 + x + y * 4, 70 + x * 18, 27 + y * 18)); + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + } + + @Override + public void detectAndSendChanges () + { + super.detectAndSendChanges(); + for (int i = 0; i < crafters.size(); i++) + { + ICrafting icrafting = (ICrafting) crafters.get(i); + if (progress != logic.progress) + { + icrafting.sendProgressBarUpdate(this, 0, logic.progress); + } + if (fuel != logic.fuel) + { + icrafting.sendProgressBarUpdate(this, 1, logic.fuel); + } + if (fuelGague != logic.fuelGague) + { + icrafting.sendProgressBarUpdate(this, 2, logic.fuelGague); + } + } + + progress = logic.progress; + fuel = logic.fuel; + fuelGague = logic.fuelGague; + } + + public void updateProgressBar (int i, int j) + { + if (i == 0) + { + logic.progress = j; + } + if (i == 1) + { + logic.fuel = j; + } + if (i == 2) + { + logic.fuelGague = j; + } + } + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return logic.isUseableByPlayer(entityplayer); + } + + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < logic.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } +} diff --git a/tconstruct/inventory/KnapsackContainer.java b/tconstruct/inventory/KnapsackContainer.java new file mode 100644 index 00000000..8990d9e2 --- /dev/null +++ b/tconstruct/inventory/KnapsackContainer.java @@ -0,0 +1,84 @@ +package tconstruct.inventory; + +import tconstruct.util.player.KnapsackInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class KnapsackContainer extends Container +{ + public KnapsackInventory backpack; + public int progress = 0; + public int fuel = 0; + public int fuelGague = 0; + + public KnapsackContainer(InventoryPlayer inventoryplayer, KnapsackInventory knapsack) + { + backpack = knapsack; + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(knapsack, row + column * 9, 8 + row * 18, 17 + column * 18)); + } + } + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + } + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return backpack.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < backpack.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, backpack.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, backpack.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } +} diff --git a/tconstruct/inventory/MiniGardyContainer.java b/tconstruct/inventory/MiniGardyContainer.java new file mode 100644 index 00000000..a77e9b6b --- /dev/null +++ b/tconstruct/inventory/MiniGardyContainer.java @@ -0,0 +1,81 @@ +package tconstruct.inventory; + +import tconstruct.entity.MiniGardy; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class MiniGardyContainer extends Container +{ + public MiniGardy gardy; + + public MiniGardyContainer(InventoryPlayer inventoryplayer, MiniGardy entity) + { + gardy = entity; + for (int column = 0; column < 2; column++) + { + for (int row = 0; row < 7; row++) + { + this.addSlotToContainer(new Slot(entity, row + column * 7, 44 + row * 18, 36 + column * 18)); + } + } + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 86 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 144)); + } + } + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return gardy.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < gardy.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, gardy.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, gardy.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } +} diff --git a/tconstruct/inventory/PartCrafterChestContainer.java b/tconstruct/inventory/PartCrafterChestContainer.java new file mode 100644 index 00000000..5506d217 --- /dev/null +++ b/tconstruct/inventory/PartCrafterChestContainer.java @@ -0,0 +1,101 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.PartCrafterLogic; +import tconstruct.blocks.logic.PatternChestLogic; +import tconstruct.library.util.IPattern; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class PartCrafterChestContainer extends ActiveContainer +{ + protected PatternChestLogic patternLogic; + protected InventoryPlayer invPlayer; + protected PartCrafterLogic logic; + protected Slot[] input; + protected Slot[] inventory; + public boolean largeInventory; + + public PartCrafterChestContainer(InventoryPlayer inventoryplayer, PartCrafterLogic partLogic, PatternChestLogic pLogic) + { + logic = partLogic; + patternLogic = pLogic; + largeInventory = true; + + inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new SlotPattern(partLogic, 1, 40, 45), new Slot(partLogic, 2, 58, 27), new Slot(partLogic, 3, 58, 45), + new SlotOnlyTake(partLogic, 4, 102, 27), new SlotOnlyTake(partLogic, 5, 120, 27), new SlotOnlyTake(partLogic, 6, 102, 45), new SlotOnlyTake(partLogic, 7, 120, 45) }; + for (int iter = 0; iter < inventory.length; iter++) + this.addSlotToContainer(inventory[iter]); + + /* Holder inventory */ + for (int column = 0; column < 5; column++) + { + for (int row = 0; row < 6; row++) + { + this.addSlotToContainer(new SlotPattern(pLogic, row + column * 6, -108 + row * 18, 30 + column * 18)); + } + } + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + + } + + @Override + public boolean canInteractWith (EntityPlayer var1) + { + return true; + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < logic.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, logic.getSizeInventory() + patternLogic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else + { + if (slotStack.getItem() instanceof IPattern) + { + if (!this.mergeItemStack(slotStack, 0, 2, false) && !this.mergeItemStack(slotStack, 8, 38, false)) + return null; + } + else if (!this.mergeItemStack(slotStack, 2, 4, false)) + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + logic.tryBuildPart(slotID); + } + slot.onSlotChanged(); + } + + return stack; + } +} diff --git a/tconstruct/inventory/PartCrafterContainer.java b/tconstruct/inventory/PartCrafterContainer.java new file mode 100644 index 00000000..4f9449a1 --- /dev/null +++ b/tconstruct/inventory/PartCrafterContainer.java @@ -0,0 +1,89 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.PartCrafterLogic; +import tconstruct.library.util.IPattern; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class PartCrafterContainer extends ActiveContainer +{ + protected InventoryPlayer invPlayer; + protected PartCrafterLogic logic; + protected Slot[] input; + protected Slot[] inventory; + public boolean largeInventory; + + public PartCrafterContainer(InventoryPlayer inventoryplayer, PartCrafterLogic partLogic) + { + invPlayer = inventoryplayer; + logic = partLogic; + largeInventory = false; + + inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new SlotPattern(partLogic, 1, 40, 45), new Slot(partLogic, 2, 58, 27), new Slot(partLogic, 3, 58, 45), + new SlotOnlyTake(partLogic, 4, 102, 27), new SlotOnlyTake(partLogic, 5, 120, 27), new SlotOnlyTake(partLogic, 6, 102, 45), new SlotOnlyTake(partLogic, 7, 120, 45) }; + for (int iter = 0; iter < inventory.length; iter++) + this.addSlotToContainer(inventory[iter]); + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + + } + + @Override + public boolean canInteractWith (EntityPlayer var1) + { + return true; + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < logic.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else + { + if (slotStack.getItem() instanceof IPattern) + { + if (!this.mergeItemStack(slotStack, 0, 2, false)) + return null; + } + else if (!this.mergeItemStack(slotStack, 2, 4, false)) + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + logic.tryBuildPart(slotID); + } + slot.onSlotChanged(); + } + return stack; + } +} diff --git a/tconstruct/inventory/PatternChestContainer.java b/tconstruct/inventory/PatternChestContainer.java new file mode 100644 index 00000000..9e1562e4 --- /dev/null +++ b/tconstruct/inventory/PatternChestContainer.java @@ -0,0 +1,94 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.PatternChestLogic; +import tconstruct.library.util.IPattern; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class PatternChestContainer extends Container +{ + public PatternChestLogic logic; + public int progress = 0; + public int fuel = 0; + public int fuelGague = 0; + + public PatternChestContainer(InventoryPlayer inventoryplayer, PatternChestLogic chest) + { + logic = chest; + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 10; row++) + { + this.addSlotToContainer(new SlotPattern(chest, row + column * 10, 8 + row * 18, 18 + column * 18)); + } + } + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 17 + row * 18, 86 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 17 + column * 18, 144)); + } + } + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return logic.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < logic.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } + + @Override + protected boolean mergeItemStack (ItemStack stack, int inventorySize, int slotSize, boolean par4) + { + if (!(stack.getItem() instanceof IPattern)) + return false; + + return super.mergeItemStack(stack, inventorySize, slotSize, par4); + } +} diff --git a/tconstruct/inventory/PatternShaperContainer.java b/tconstruct/inventory/PatternShaperContainer.java new file mode 100644 index 00000000..0c358542 --- /dev/null +++ b/tconstruct/inventory/PatternShaperContainer.java @@ -0,0 +1,105 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.StencilTableLogic; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class PatternShaperContainer extends Container +{ + public StencilTableLogic logic; + + public PatternShaperContainer(InventoryPlayer inventoryplayer, StencilTableLogic shaper) + { + logic = shaper; + this.addSlotToContainer(new Slot(shaper, 0, 48, 35)); + this.addSlotToContainer(new SlotOnlyTake(shaper, 1, 106, 35)); + /*for (int i = 0; i < 3; i++) + { + for (int l = 0; l < 3; l++) + { + this.addSlotToContainer(new Slot(craftMatrix, l + i * 3, 30 + l * 18, 17 + i * 18)); + } + }*/ + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + } + + /*public void onCraftMatrixChanged(IInventory iinventory) + { + craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj)); + }*/ + + /*@Override + public void onContainerClosed(EntityPlayer entityplayer) + { + super.onContainerClosed(entityplayer); + if (logic.worldObj.isRemote) + { + return; + } + ItemStack itemstack = logic.getStackInSlot(0); + if (itemstack != null) + { + entityplayer.dropPlayerItem(itemstack); + } + }*/ + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return true; + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + return null; + /*ItemStack stack = null; + Slot slot = (Slot)this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < logic.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory()-1, false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack;*/ + } + +} diff --git a/tconstruct/inventory/SlotArmorCopy.java b/tconstruct/inventory/SlotArmorCopy.java new file mode 100644 index 00000000..90a52ef6 --- /dev/null +++ b/tconstruct/inventory/SlotArmorCopy.java @@ -0,0 +1,58 @@ +package tconstruct.inventory; + +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SlotArmorCopy extends Slot +{ + /** + * The armor type that can be placed on that slot, it uses the same values of armorType field on ItemArmor. + */ + final int armorType; + + /** + * The parent class of this clot, ContainerPlayer, SlotArmor is a Anon inner class. + */ + final Container parent; + + public SlotArmorCopy(Container container, IInventory par2IInventory, int par3, int par4, int par5, int par6) + { + super(par2IInventory, par3, par4, par5); + this.parent = container; + this.armorType = par6; + } + + /** + * Returns the maximum stack size for a given slot (usually the same as getInventoryStackLimit(), but 1 in the case + * of armor slots) + */ + public int getSlotStackLimit () + { + return 1; + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. + */ + public boolean isItemValid (ItemStack par1ItemStack) + { + Item item = (par1ItemStack == null ? null : par1ItemStack.getItem()); + return item != null;// && item.isValidArmor(par1ItemStack, armorType, parent.thePlayer); + } + + @SideOnly(Side.CLIENT) + /** + * Returns the icon index on items.png that is used as background image of the slot. + */ + public Icon getBackgroundIconIndex () + { + return ItemArmor.func_94602_b(this.armorType); + } +} diff --git a/tconstruct/inventory/SlotOnlyTake.java b/tconstruct/inventory/SlotOnlyTake.java new file mode 100644 index 00000000..3744558b --- /dev/null +++ b/tconstruct/inventory/SlotOnlyTake.java @@ -0,0 +1,22 @@ +package tconstruct.inventory; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotOnlyTake extends Slot +{ + + public SlotOnlyTake(IInventory builder, int par3, int par4, int par5) + { + super(builder, par3, par4, par5); + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. + */ + public boolean isItemValid (ItemStack stack) + { + return false; + } +} diff --git a/tconstruct/inventory/SlotPartBuilder.java b/tconstruct/inventory/SlotPartBuilder.java new file mode 100644 index 00000000..daaf8357 --- /dev/null +++ b/tconstruct/inventory/SlotPartBuilder.java @@ -0,0 +1,19 @@ +package tconstruct.inventory; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotPartBuilder extends Slot +{ + + public SlotPartBuilder(IInventory inv, int index, int posX, int posY) + { + super(inv, index, posX, posY); + } + + protected void onCrafting (ItemStack par1ItemStack, int par2) + { + + } +} diff --git a/tconstruct/inventory/SlotPattern.java b/tconstruct/inventory/SlotPattern.java new file mode 100644 index 00000000..cab1c6a2 --- /dev/null +++ b/tconstruct/inventory/SlotPattern.java @@ -0,0 +1,22 @@ +package tconstruct.inventory; + +import tconstruct.library.util.IPattern; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotPattern extends Slot +{ + public SlotPattern(IInventory builder, int par3, int par4, int par5) + { + super(builder, par3, par4, par5); + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. + */ + public boolean isItemValid (ItemStack stack) + { + return stack.getItem() instanceof IPattern; + } +} diff --git a/tconstruct/inventory/SlotTool.java b/tconstruct/inventory/SlotTool.java new file mode 100644 index 00000000..14b32038 --- /dev/null +++ b/tconstruct/inventory/SlotTool.java @@ -0,0 +1,71 @@ +package tconstruct.inventory; + +import java.util.Random; + +import tconstruct.library.tools.ToolCore; + + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class SlotTool extends Slot +{ + /** The player that is using the GUI where this slot resides. */ + public EntityPlayer player; + Random random = new Random(); + + public SlotTool(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5) + { + super(builder, par3, par4, par5); + this.player = entityplayer; + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. + */ + public boolean isItemValid (ItemStack stack) + { + return false; + //return stack.getItem() instanceof ToolCore; + } + + public void onPickupFromSlot (EntityPlayer par1EntityPlayer, ItemStack stack) + { + this.onCrafting(stack); + //stack.setUnlocalizedName("\u00A7f" + toolName); + super.onPickupFromSlot(par1EntityPlayer, stack); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an + * internal count then calls onCrafting(item). + */ + protected void onCrafting (ItemStack stack, int par2) + { + //this.field_75228_b += par2; + this.onCrafting(stack); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. + */ + protected void onCrafting (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.getCompoundTag("InfiTool").hasKey("Built")) + { + tags.getCompoundTag("InfiTool").setBoolean("Built", true); + Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null); + for (int i = 2; i <= 3; i++) + inventory.decrStackSize(i, 1); + int amount = inventory.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1; + inventory.decrStackSize(1, amount); + if (!player.worldObj.isRemote && full) + player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "sounds.little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F); + //player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0); + } + } +} diff --git a/tconstruct/inventory/SlotToolForge.java b/tconstruct/inventory/SlotToolForge.java new file mode 100644 index 00000000..aa33be19 --- /dev/null +++ b/tconstruct/inventory/SlotToolForge.java @@ -0,0 +1,38 @@ +package tconstruct.inventory; + +import java.util.Random; + +import tconstruct.library.tools.ToolCore; + + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class SlotToolForge extends SlotTool +{ + /** The player that is using the GUI where this slot resides. */ + Random random = new Random(); + + public SlotToolForge(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5) + { + super(entityplayer, builder, par3, par4, par5); + } + + protected void onCrafting (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.getCompoundTag("InfiTool").hasKey("Built")) + { + tags.getCompoundTag("InfiTool").setBoolean("Built", true); + Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null); + for (int i = 2; i <= 4; i++) + inventory.decrStackSize(i, 1); + int amount = inventory.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1; + inventory.decrStackSize(1, amount); + if (!player.worldObj.isRemote && full) + player.worldObj.playAuxSFX(1021, (int) player.posX, (int) player.posY, (int) player.posZ, 0); + } + } +} diff --git a/tconstruct/inventory/SmelteryContainer.java b/tconstruct/inventory/SmelteryContainer.java new file mode 100644 index 00000000..d220e2b0 --- /dev/null +++ b/tconstruct/inventory/SmelteryContainer.java @@ -0,0 +1,297 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.SmelteryLogic; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SmelteryContainer extends ActiveContainer +{ + public SmelteryLogic logic; + public InventoryPlayer playerInv; + public int fuel = 0; + int slotRow; + + public SmelteryContainer(InventoryPlayer inventoryplayer, SmelteryLogic smeltery) + { + logic = smeltery; + playerInv = inventoryplayer; + slotRow = 0; + + /* Smeltery inventory */ + + for (int y = 0; y < smeltery.layers * 3; y++) + { + for (int x = 0; x < 3; x++) + { + this.addDualSlotToContainer(new ActiveSlot(smeltery, x + y * 3, 2 + x * 22, 8 + y * 18, y < 8)); + } + } + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 90 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 90 + column * 18, 142)); + } + } + + public int updateRows (int invRow) + { + if (invRow != slotRow) + { + slotRow = invRow; + //System.out.println(invRow); + int basePos = invRow * 3; + for (int iter = 0; iter < activeInventorySlots.size(); iter++) + { + ActiveSlot slot = (ActiveSlot) activeInventorySlots.get(iter); + if (slot.activeSlotNumber >= basePos && slot.activeSlotNumber < basePos + 24) + { + slot.setActive(true); + } + else + { + slot.setActive(false); + } + int xPos = (iter - basePos) % 3; + int yPos = (iter - basePos) / 3; + slot.xDisplayPosition = 2 + 22 * xPos; + slot.yDisplayPosition = 8 + 18 * yPos; + } + return slotRow; + } + return -1; + } + + public int scrollTo (float scrollPos) + { + float total = (logic.getSizeInventory() - 24) / 3; + int rowPos = (int) (total * scrollPos); + return updateRows(rowPos); + } + + @Override + public void detectAndSendChanges () //TODO: Sync with this + { + super.detectAndSendChanges(); + /*for (int i = 0; i < crafters.size(); i++) + { + ICrafting icrafting = (ICrafting)crafters.get(i); + if (progress != logic.progress) + { + icrafting.sendProgressBarUpdate(this, 0, logic.progress); + } + if (fuel != logic.fuel) + { + icrafting.sendProgressBarUpdate(this, 1, logic.fuel); + } + if (fuelGague != logic.fuelGague) + { + icrafting.sendProgressBarUpdate(this, 2, logic.fuelGague); + } + } + + progress = logic.progress; + fuel = logic.fuel; + fuelGague = logic.fuelGague;*/ + } + + public void updateProgressBar (int id, int value) + { + if (id == 0) + { + logic.fuelGague = value; + } + /* if (id == 1) + { + logic.fuel = value; + }*/ + /*if (id == 2) + { + logic.fuelGague = value; + }*/ + } + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return logic.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < logic.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } + + @Override + protected boolean mergeItemStack (ItemStack inputStack, int startSlot, int endSlot, boolean flag) + { + //System.out.println("Merge"); + boolean merged = false; + int slotPos = startSlot; + + if (flag) + { + slotPos = endSlot - 1; + } + + Slot slot; + ItemStack slotStack; + + /*if (inputStack.isStackable() && startSlot >= logic.getSizeInventory()) + { + System.out.println("Rawr!"); + while (inputStack.stackSize > 0 && (!flag && slotPos < endSlot || flag && slotPos >= startSlot)) + { + slot = (Slot) this.inventorySlots.get(slotPos); + slotStack = slot.getStack(); + + if (slotStack != null && ItemStack.areItemStacksEqual(inputStack, slotStack) && !inputStack.getHasSubtypes()) + { + int totalSize = slotStack.stackSize + inputStack.stackSize; + + if (totalSize <= inputStack.getMaxStackSize()) + { + inputStack.stackSize = 0; + slotStack.stackSize = totalSize; + slot.onSlotChanged(); + merged = true; + } + else if (slotStack.stackSize < inputStack.getMaxStackSize()) + { + inputStack.stackSize -= inputStack.getMaxStackSize() - slotStack.stackSize; + slotStack.stackSize = inputStack.getMaxStackSize(); + slot.onSlotChanged(); + merged = true; + } + } + + if (flag) + { + --slotPos; + } + else + { + ++slotPos; + } + } + }*/ + + if (inputStack.isStackable() && startSlot >= logic.getSizeInventory()) + { + while (inputStack.stackSize > 0 && (!flag && slotPos < endSlot || flag && slotPos >= startSlot)) + { + slot = (Slot) this.inventorySlots.get(slotPos); + slotStack = slot.getStack(); + + if (slotStack != null && slotStack.itemID == inputStack.itemID && (!inputStack.getHasSubtypes() || inputStack.getItemDamage() == slotStack.getItemDamage()) + && ItemStack.areItemStackTagsEqual(inputStack, slotStack)) + { + int l = slotStack.stackSize + inputStack.stackSize; + + if (l <= inputStack.getMaxStackSize()) + { + inputStack.stackSize = 0; + slotStack.stackSize = l; + slot.onSlotChanged(); + merged = true; + } + else if (slotStack.stackSize < inputStack.getMaxStackSize()) + { + inputStack.stackSize -= inputStack.getMaxStackSize() - slotStack.stackSize; + slotStack.stackSize = inputStack.getMaxStackSize(); + slot.onSlotChanged(); + merged = true; + } + } + + if (flag) + { + --slotPos; + } + else + { + ++slotPos; + } + } + } + + if (inputStack.stackSize > 0) + { + if (flag) + { + slotPos = endSlot - 1; + } + else + { + slotPos = startSlot; + } + + while (!flag && slotPos < endSlot || flag && slotPos >= startSlot) + { + slot = (Slot) this.inventorySlots.get(slotPos); + slotStack = slot.getStack(); + + if (slotStack == null) + { + slot.putStack(inputStack.copy()); + slot.onSlotChanged(); + inputStack.stackSize -= 1; + merged = true; + break; + } + + if (flag) + { + --slotPos; + } + else + { + ++slotPos; + } + } + } + + return merged; + } +} diff --git a/tconstruct/inventory/ToolForgeContainer.java b/tconstruct/inventory/ToolForgeContainer.java new file mode 100644 index 00000000..db9ffd92 --- /dev/null +++ b/tconstruct/inventory/ToolForgeContainer.java @@ -0,0 +1,84 @@ +package tconstruct.inventory; + +import tconstruct.blocks.logic.ToolForgeLogic; +import tconstruct.blocks.logic.ToolStationLogic; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ToolForgeContainer extends ToolStationContainer +{ + + public ToolForgeContainer(InventoryPlayer inventoryplayer, ToolForgeLogic logic) + { + super(inventoryplayer, logic); + } + + public void initializeContainer (InventoryPlayer inventoryplayer, ToolStationLogic builderlogic) + { + invPlayer = inventoryplayer; + this.logic = builderlogic; + + toolSlot = new SlotToolForge(inventoryplayer.player, logic, 0, 115, 38); + this.addSlotToContainer(toolSlot); + slots = new Slot[] { new Slot(logic, 1, 57, 29), new Slot(logic, 2, 39, 29), new Slot(logic, 3, 57, 47), new Slot(logic, 4, 39, 47) }; + + for (int iter = 0; iter < 4; iter++) + this.addSlotToContainer(slots[iter]); + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + } + + //posX and posY must be the same length + public void resetSlots (int[] posX, int[] posY) + { + inventorySlots.clear(); + inventoryItemStacks.clear(); + this.addSlotToContainer(toolSlot); + for (int iter = 0; iter < 4; iter++) + { + slots[iter].xDisplayPosition = posX[iter] + 1; + slots[iter].yDisplayPosition = posY[iter] + 1; + addSlotToContainer(slots[iter]); + } + + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(invPlayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(invPlayer, column, 8 + column * 18, 142)); + } + } + + protected void craftTool (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.getCompoundTag("InfiTool").hasKey("Built")) + { + tags.getCompoundTag("InfiTool").setBoolean("Built", true); + for (int i = 1; i <= 4; i++) + logic.decrStackSize(i, 1); + if (!logic.worldObj.isRemote) + logic.worldObj.playAuxSFX(1021, (int) logic.xCoord, (int) logic.yCoord, (int) logic.zCoord, 0); + } + } +} diff --git a/tconstruct/inventory/ToolStationContainer.java b/tconstruct/inventory/ToolStationContainer.java new file mode 100644 index 00000000..2e04f749 --- /dev/null +++ b/tconstruct/inventory/ToolStationContainer.java @@ -0,0 +1,242 @@ +package tconstruct.inventory; + +import java.util.Random; + +import tconstruct.blocks.logic.ToolStationLogic; +import tconstruct.library.tools.ToolCore; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ToolStationContainer extends ActiveContainer +{ + public InventoryPlayer invPlayer; + public ToolStationLogic logic; + public Slot[] slots; + public SlotTool toolSlot; + public Random random = new Random(); + + public ToolStationContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic) + { + initializeContainer(inventoryplayer, builderlogic); + } + + public void initializeContainer (InventoryPlayer inventoryplayer, ToolStationLogic builderlogic) + { + invPlayer = inventoryplayer; + logic = builderlogic; + + toolSlot = new SlotTool(inventoryplayer.player, builderlogic, 0, 115, 38); + this.addSlotToContainer(toolSlot); + slots = new Slot[] { new Slot(builderlogic, 1, 57, 29), new Slot(builderlogic, 2, 39, 38), new Slot(builderlogic, 3, 57, 47) }; + + for (int iter = 0; iter < 3; iter++) + this.addSlotToContainer(slots[iter]); + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + } + + //posX and posY must be the same length + public void resetSlots (int[] posX, int[] posY) + { + /* Station inventory */ + inventorySlots.clear(); + inventoryItemStacks.clear(); + this.addSlotToContainer(toolSlot); + for (int iter = 0; iter < 3; iter++) + { + slots[iter].xDisplayPosition = posX[iter] + 1; + slots[iter].yDisplayPosition = posY[iter] + 1; + addSlotToContainer(slots[iter]); + } + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(invPlayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(invPlayer, column, 8 + column * 18, 142)); + } + } + + @Override + public boolean canInteractWith (EntityPlayer var1) + { + return true; + } + + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + if (slotID < logic.getSizeInventory()) + { + if (slotID == 0) + { + if (!this.mergeCraftedStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true, player)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 1, logic.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } + + protected void craftTool (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.getCompoundTag("InfiTool").hasKey("Built")) + { + tags.getCompoundTag("InfiTool").setBoolean("Built", true); + for (int i = 2; i <= 3; i++) + logic.decrStackSize(i, 1); + int amount = logic.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1; + logic.decrStackSize(1, amount); + + logic.worldObj.playSoundEffect(logic.xCoord, logic.yCoord, logic.zCoord, "sounds.little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F); + /*if (!player.worldObj.isRemote) + player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0);*/ + } + } + + protected boolean mergeCraftedStack (ItemStack stack, int slotsStart, int slotsTotal, boolean playerInventory, EntityPlayer player) + { + boolean failedToMerge = false; + int slotIndex = slotsStart; + + if (playerInventory) + { + slotIndex = slotsTotal - 1; + } + + Slot otherInventorySlot; + ItemStack copyStack = null; + + /*if (stack.isStackable()) + { + while (stack.stackSize > 0 && (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart)) + { + otherInventorySlot = (Slot)this.inventorySlots.get(slotIndex); + copyStack = otherInventorySlot.getStack(); + + if (copyStack != null && copyStack.itemID == stack.itemID && (!stack.getHasSubtypes() || stack.getItemDamage() == copyStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack, copyStack)) + { + int totalSize = copyStack.stackSize + stack.stackSize; + + if (totalSize <= stack.getMaxStackSize()) + { + stack.stackSize = 0; + copyStack.stackSize = totalSize; + otherInventorySlot.onSlotChanged(); + failedToMerge = true; + } + else if (copyStack.stackSize < stack.getMaxStackSize()) + { + stack.stackSize -= stack.getMaxStackSize() - copyStack.stackSize; + copyStack.stackSize = stack.getMaxStackSize(); + otherInventorySlot.onSlotChanged(); + failedToMerge = true; + } + } + + if (playerInventory) + { + --slotIndex; + } + else + { + ++slotIndex; + } + } + }*/ + + if (stack.stackSize > 0) + { + if (playerInventory) + { + slotIndex = slotsTotal - 1; + } + else + { + slotIndex = slotsStart; + } + + while (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart) + { + otherInventorySlot = (Slot) this.inventorySlots.get(slotIndex); + copyStack = otherInventorySlot.getStack(); + + if (copyStack == null) + { + craftTool(stack); + otherInventorySlot.putStack(stack.copy()); + otherInventorySlot.onSlotChanged(); + stack.stackSize = 0; + failedToMerge = true; + break; + } + + if (playerInventory) + { + --slotIndex; + } + else + { + ++slotIndex; + } + } + } + + /*boolean emptySlots = ( ((Slot) inventorySlots.get(2)).getStack() == null && ((Slot) inventorySlots.get(3)).getStack() == null ); + System.out.println("Empty slots"); + if (!failedToMerge && emptySlots) + player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0);*/ + + return failedToMerge; + } +} diff --git a/tconstruct/items/Bowstring.java b/tconstruct/items/Bowstring.java new file mode 100644 index 00000000..d43e1ec6 --- /dev/null +++ b/tconstruct/items/Bowstring.java @@ -0,0 +1,49 @@ +package tconstruct.items; + +import java.util.List; + +import tconstruct.common.TContent; +import tconstruct.library.util.IToolPart; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; + +public class Bowstring extends CraftingItem implements IToolPart +{ + public Bowstring(int id) + { + super(id, toolMaterialNames, buildTextureNames("_bowstring"), "parts/"); + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + private static String[] buildTextureNames (String textureType) + { + String[] names = new String[toolMaterialNames.length]; + for (int i = 0; i < toolMaterialNames.length; i++) + { + if (toolTextureNames[i].equals("")) + names[i] = ""; + else + names[i] = toolTextureNames[i] + textureType; + } + return names; + } + + public static final String[] toolMaterialNames = new String[] { "string", "enchantedfabric" }; + + public static final String[] toolTextureNames = new String[] { "string", "magicfabric" }; + + @Override + public int getMaterialID (ItemStack stack) + { + return stack.getItemDamage(); + } + + public void getSubItems (int id, CreativeTabs tab, List list) + { + list.add(new ItemStack(id, 1, 0)); + if (TContent.thaumcraftAvailable) + list.add(new ItemStack(id, 1, 1)); + } +} diff --git a/tconstruct/items/CraftingItem.java b/tconstruct/items/CraftingItem.java new file mode 100644 index 00000000..3e2e32c2 --- /dev/null +++ b/tconstruct/items/CraftingItem.java @@ -0,0 +1,67 @@ +package tconstruct.items; + +import java.util.List; + +import tconstruct.library.TConstructRegistry; + + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CraftingItem extends Item +{ + public String[] textureNames; + public String[] unlocalizedNames; + public String folder; + public Icon[] icons; + + public CraftingItem(int id, String[] names, String[] tex, String folder) + { + super(id); + this.setCreativeTab(TConstructRegistry.materialTab); + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.textureNames = tex; + this.unlocalizedNames = names; + this.folder = folder; + } + + @SideOnly(Side.CLIENT) + public Icon getIconFromDamage (int meta) + { + int arr = MathHelper.clamp_int(meta, 0, unlocalizedNames.length); + return icons[arr]; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + if (!(textureNames[i].equals(""))) + this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]); + } + } + + public String getUnlocalizedName (ItemStack stack) + { + int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, unlocalizedNames.length); + return getUnlocalizedName() + "." + unlocalizedNames[arr]; + } + + public void getSubItems (int id, CreativeTabs tab, List list) + { + for (int i = 0; i < unlocalizedNames.length; i++) + if (!(textureNames[i].equals(""))) + list.add(new ItemStack(id, 1, i)); + } +} diff --git a/tconstruct/items/DiamondApple.java b/tconstruct/items/DiamondApple.java new file mode 100644 index 00000000..6475ae42 --- /dev/null +++ b/tconstruct/items/DiamondApple.java @@ -0,0 +1,77 @@ +package tconstruct.items; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class DiamondApple extends ItemFood +{ + public Icon[] icons; + public String[] textureNames = new String[] { "apple_diamond" }; + public String[] itemNames = new String[] { "apple.diamond" }; + + public DiamondApple(int id) + { + super(id, 4, 2.0F, false); + setHasSubtypes(true); + setMaxDamage(0); + this.setAlwaysEdible(); + } + + protected void onFoodEaten (ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote) + { + int duration = 0; + PotionEffect potion; + + potion = player.getActivePotionEffect(Potion.resistance); + if (potion != null) + duration = potion.duration; + player.addPotionEffect(new PotionEffect(Potion.resistance.id, duration + 60 * 20, 0)); + + potion = player.getActivePotionEffect(Potion.digSpeed); + if (potion != null) + duration = potion.duration; + player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, duration + 60 * 20, 0)); + + potion = player.getActivePotionEffect(Potion.damageBoost); + if (potion != null) + duration = potion.duration; + player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, duration + 60 * 20, 0)); + } + } + + @SideOnly(Side.CLIENT) + @Override + public Icon getIconFromDamage (int meta) + { + return icons[meta]; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]); + } + } + + /* Name override */ + @Override + public String getUnlocalizedName (ItemStack itemstack) + { + return (new StringBuilder()).append("item.food.").append(itemNames[itemstack.getItemDamage()]).toString(); + } +} diff --git a/tconstruct/items/FilledBucket.java b/tconstruct/items/FilledBucket.java new file mode 100644 index 00000000..66f971db --- /dev/null +++ b/tconstruct/items/FilledBucket.java @@ -0,0 +1,184 @@ +package tconstruct.items; + +import java.util.List; + +import tconstruct.blocks.logic.LiquidTextureLogic; +import tconstruct.common.TContent; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBucket; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumMovingObjectType; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class FilledBucket extends ItemBucket +{ + + public FilledBucket(int id) + { + super(id, 0); + //setTextureFile(TContent.craftingTexture); + //setIconIndex(224); + setUnlocalizedName("tconstruct.bucket"); + setContainerItem(Item.bucketEmpty); + this.setHasSubtypes(true); + } + + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + { + float var4 = 1.0F; + double trueX = player.prevPosX + (player.posX - player.prevPosX) * (double) var4; + double trueY = player.prevPosY + (player.posY - player.prevPosY) * (double) var4 + 1.62D - (double) player.yOffset; + double trueZ = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) var4; + boolean wannabeFull = false; + MovingObjectPosition position = this.getMovingObjectPositionFromPlayer(world, player, wannabeFull); + + if (position == null) + { + return stack; + } + else + { + /*FillBucketEvent event = new FillBucketEvent(player, stack, world, position); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return stack; + } + + if (event.getResult() == Event.Result.ALLOW) + { + if (player.capabilities.isCreativeMode) + { + return stack; + } + + if (--stack.stackSize <= 0) + { + return event.result; + } + + if (!player.inventory.addItemStackToInventory(event.result)) + { + player.dropPlayerItem(event.result); + } + + return stack; + }*/ + + if (position.typeOfHit == EnumMovingObjectType.TILE) + { + int clickX = position.blockX; + int clickY = position.blockY; + int clickZ = position.blockZ; + + if (!world.canMineBlock(player, clickX, clickY, clickZ)) + { + return stack; + } + + if (position.sideHit == 0) + { + --clickY; + } + + if (position.sideHit == 1) + { + ++clickY; + } + + if (position.sideHit == 2) + { + --clickZ; + } + + if (position.sideHit == 3) + { + ++clickZ; + } + + if (position.sideHit == 4) + { + --clickX; + } + + if (position.sideHit == 5) + { + ++clickX; + } + + if (!player.canPlayerEdit(clickX, clickY, clickZ, position.sideHit, stack)) + { + return stack; + } + + if (this.tryPlaceContainedLiquid(world, clickX, clickY, clickZ, stack.getItemDamage()) && !player.capabilities.isCreativeMode) + { + return new ItemStack(Item.bucketEmpty); + } + } + + return stack; + } + } + + public boolean tryPlaceContainedLiquid (World world, int clickX, int clickY, int clickZ, int meta) + { + if (!world.isAirBlock(clickX, clickY, clickZ) && world.getBlockMaterial(clickX, clickY, clickZ).isSolid()) + { + return false; + } + else + { + int id = 0; + world.setBlock(clickX, clickY, clickZ, TContent.fluidBlocks[meta].blockID, 7, 3); //TODO: Merge liquids + + return true; + } + } + + @Override + public void getSubItems (int id, CreativeTabs tab, List list) + { + for (int i = 0; i < icons.length; i++) + list.add(new ItemStack(id, 1, i)); + } + + public Icon[] icons; + + @SideOnly(Side.CLIENT) + public Icon getIconFromDamage (int meta) + { + return icons[meta]; + } + + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:materials/bucket_" + textureNames[i]); + } + } + + public String getUnlocalizedName (ItemStack stack) + { + int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, materialNames.length); + return getUnlocalizedName() + "." + materialNames[arr]; + } + + public static final String[] materialNames = new String[] { "Iron", "Gold", "Copper", "Tin", "Aluminum", "Cobalt", "Ardite", "Bronze", "AluBrass", "Manyullyn", "Alumite", "Obsidian", "Steel", + "Glass", "Stone", "Villager", "Cow" }; + + public static final String[] textureNames = new String[] { "iron", "gold", "copper", "tin", "aluminum", "cobalt", "ardite", "bronze", "alubrass", "manyullyn", "alumite", "obsidian", "steel", + "glass", "stone", "emerald", "blood" }; +} diff --git a/tconstruct/items/Fletching.java b/tconstruct/items/Fletching.java new file mode 100644 index 00000000..283d9ffb --- /dev/null +++ b/tconstruct/items/Fletching.java @@ -0,0 +1,37 @@ +package tconstruct.items; + +import tconstruct.library.util.IToolPart; +import net.minecraft.item.ItemStack; + +public class Fletching extends CraftingItem implements IToolPart +{ + public Fletching(int id) + { + super(id, toolMaterialNames, buildTextureNames("_fletching"), "parts/"); + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + private static String[] buildTextureNames (String textureType) + { + String[] names = new String[toolMaterialNames.length]; + for (int i = 0; i < toolMaterialNames.length; i++) + { + if (toolTextureNames[i].equals("")) + names[i] = ""; + else + names[i] = toolTextureNames[i] + textureType; + } + return names; + } + + public static final String[] toolMaterialNames = new String[] { "feather", "leaf", "slime", "blueslime" }; + + public static final String[] toolTextureNames = new String[] { "feather", "leaf", "slime", "blueslime" }; + + @Override + public int getMaterialID (ItemStack stack) + { + return stack.getItemDamage(); + } +} diff --git a/tconstruct/items/GoldenHead.java b/tconstruct/items/GoldenHead.java new file mode 100644 index 00000000..1e253722 --- /dev/null +++ b/tconstruct/items/GoldenHead.java @@ -0,0 +1,78 @@ +package tconstruct.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class GoldenHead extends ItemFood +{ + public GoldenHead(int par1, int par2, float par3, boolean par4) + { + super(par1, par2, par3, par4); + this.setHasSubtypes(true); + } + + @SideOnly(Side.CLIENT) + public boolean hasEffect (ItemStack par1ItemStack) + { + return par1ItemStack.getItemDamage() > 0; + } + + @SideOnly(Side.CLIENT) + /** + * Return an item rarity from EnumRarity + */ + public EnumRarity getRarity (ItemStack par1ItemStack) + { + return par1ItemStack.getItemDamage() == 0 ? EnumRarity.rare : EnumRarity.epic; + } + + protected void onFoodEaten (ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par1ItemStack.getItemDamage() > 0) + { + if (!par2World.isRemote) + { + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 3)); + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0)); + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0)); + } + } + else + { + super.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer); + } + } + + @SideOnly(Side.CLIENT) + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + public void getSubItems (int par1, CreativeTabs par2CreativeTabs, List par3List) + { + par3List.add(new ItemStack(par1, 1, 0)); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons (IconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("tinker:skull_char_gold"); + /*this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:"+textureNames[i]); + }*/ + } +} diff --git a/tconstruct/items/Manual.java b/tconstruct/items/Manual.java new file mode 100644 index 00000000..8a492452 --- /dev/null +++ b/tconstruct/items/Manual.java @@ -0,0 +1,50 @@ +package tconstruct.items; + +import java.util.List; + +import tconstruct.TConstruct; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Manual extends CraftingItem +{ + static String[] name = new String[] { "beginner", "toolstation", "smeltery" }; + static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery" }; + + public Manual(int id) + { + super(id, name, textureName, ""); + setUnlocalizedName("tconstruct.manual"); + } + + @Override + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + { + player.openGui(TConstruct.instance, TConstruct.proxy.manualGuiID, world, 0, 0, 0); + /*Side side = FMLCommonHandler.instance().getEffectiveSide(); + if (side.isClient()) + FMLClientHandler.instance().displayGuiScreen(player, new GuiManual(player.getCurrentEquippedItem(), getManualFromStack(stack)));*/ + return stack; + } + + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage()) + { + case 0: + list.add("\u00a7oBy: Skyla"); + break; + case 1: + list.add("\u00a7oBy: Skyla"); + break; + case 2: + list.add("\u00a7oBy: Thruul M'gon"); + break; + } + } +} diff --git a/tconstruct/items/MaterialItem.java b/tconstruct/items/MaterialItem.java new file mode 100644 index 00000000..ecc1c49e --- /dev/null +++ b/tconstruct/items/MaterialItem.java @@ -0,0 +1,29 @@ +package tconstruct.items; + +public class MaterialItem extends CraftingItem +{ + + public MaterialItem(int id) + { + super(id, materialNames, getTextures(), "materials/"); + } + + private static String[] getTextures () + { + String[] names = new String[craftingTextures.length]; + for (int i = 0; i < craftingTextures.length; i++) + names[i] = "material_" + craftingTextures[i]; + return names; + } + + static String[] materialNames = new String[] { "PaperStack", "SlimeCrystal", "SearedBrick", "CobaltIngot", "ArditeIngot", "ManyullynIngot", "Mossball", "LavaCrystal", "NecroticBone", + "CopperIngot", "TinIngot", "AluminumIngot", "RawAluminum", "BronzeIngot", "AluBrassIngot", "AlumiteIngot", "SteelIngot", "BlueSlimeCrystal", "ObsidianIngot", "IronNugget", "CopperNugget", + "TinNugget", "AluminumNugget", "EssenceCrystal", "AluBrassNugget", "SilkyCloth", "SilkyJewel", "ObsidianNugget", "CobaltNugget", "ArditeNugget", "ManyullynNugget", "BronzeNugget", + "AlumiteNugget", "SteelNugget" }; + + static String[] craftingTextures = new String[] { "paperstack", "slimecrystal", "searedbrick", "cobaltingot", "arditeingot", "manyullyningot", "mossball", "lavacrystal", "necroticbone", + "copperingot", "tiningot", "aluminumingot", "aluminumraw", "bronzeingot", "alubrassingot", "alumiteingot", "steelingot", "blueslimecrystal", "obsidianingot", "nugget_iron", + "nugget_copper", "nugget_tin", "nugget_aluminum", "essencecrystal", "nugget_alubrass", "silkycloth", "silkyjewel", "nugget_obsidian", "nugget_cobalt", "nugget_ardite", "nugget_manyullyn", + "nugget_bronze", "nugget_alumite", "nugget_steel" }; + +} diff --git a/tconstruct/items/MetalPattern.java b/tconstruct/items/MetalPattern.java new file mode 100644 index 00000000..c65fcfff --- /dev/null +++ b/tconstruct/items/MetalPattern.java @@ -0,0 +1,34 @@ +package tconstruct.items; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; + +public class MetalPattern extends Pattern +{ + + public MetalPattern(int id, String partType, String patternType, String folder) + { + super(id, partType, patternType, folder); + } + + protected static String[] getPatternNames (String partType) + { + String[] names = new String[patternName.length]; + for (int i = 0; i < patternName.length; i++) + if (!(patternName[i].equals(""))) + names[i] = partType + patternName[i]; + return names; + } + + private static final String[] patternName = new String[] { "ingot", "rod", "pickaxe", "shovel", "axe", "swordblade", "largeguard", "mediumguard", "crossbar", "binding", "frypan", "sign", + "knifeblade", "chisel", "largerod", "toughbinding", "largeplate", "broadaxe", "scythe", "excavator", "largeblade", "hammerhead", "fullguard", "", "", "arrowhead" }; + + public void getSubItems (int id, CreativeTabs tab, List list) + { + for (int i = 0; i < patternName.length; i++) + if (!(patternName[i].equals(""))) + list.add(new ItemStack(id, 1, i)); + } +} diff --git a/tconstruct/items/OreBerries.java b/tconstruct/items/OreBerries.java new file mode 100644 index 00000000..b8987d4a --- /dev/null +++ b/tconstruct/items/OreBerries.java @@ -0,0 +1,71 @@ +package tconstruct.items; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class OreBerries extends CraftingItem +{ + static String[] names = new String[] { "iron", "gold", "copper", "tin", "aluminum", "essence" }; + static String[] tex = new String[] { "oreberry_iron", "oreberry_gold", "oreberry_copper", "oreberry_tin", "oreberry_aluminum", "oreberry_essence" }; + + public OreBerries(int id) + { + super(id, names, tex, "oreberries/"); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage()) + { + case 0: + list.add("Sweet Irony"); + break; + case 1: + list.add("Pure Luster"); + break; + case 2: + list.add("Tastes like metal"); + break; + case 3: + list.add("Tin Man"); + break; + case 4: + list.add("White Chocolate"); + break; + case 5: + list.add("Tastes like Creeper"); + break; + } + } + + @Override + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + { + if (stack.getItemDamage() == 5) + { + EntityXPOrb entity = new EntityXPOrb(world, player.posX, player.posY + 1, player.posZ, itemRand.nextInt(4) + 3); + spawnEntity(player.posX, player.posY + 1, player.posZ, entity, world, player); + if (!player.capabilities.isCreativeMode) + stack.stackSize--; + } + return stack; + } + + public static void spawnEntity (double x, double y, double z, Entity entity, World world, EntityPlayer player) + { + if (!world.isRemote) + { + world.spawnEntityInWorld(entity); + } + } + +} diff --git a/tconstruct/items/Pattern.java b/tconstruct/items/Pattern.java new file mode 100644 index 00000000..53c3c86c --- /dev/null +++ b/tconstruct/items/Pattern.java @@ -0,0 +1,140 @@ +package tconstruct.items; + +import java.util.List; + +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.PatternBuilder.MaterialSet; +import tconstruct.library.util.IPattern; + + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Pattern extends CraftingItem implements IPattern +{ + public Pattern(int id, String partType, String patternType, String folder) + { + super(id, patternName, getPatternNames(patternType), folder); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setContainerItem(this); + this.setMaxStackSize(1); + } + + protected static String[] getPatternNames (String partType) + { + String[] names = new String[patternName.length]; + for (int i = 0; i < patternName.length; i++) + names[i] = partType + patternName[i]; + return names; + } + + private static final String[] patternName = new String[] { "ingot", "rod", "pickaxe", "shovel", "axe", "swordblade", "largeguard", "mediumguard", "crossbar", "binding", "frypan", "sign", + "knifeblade", "chisel", "largerod", "toughbinding", "largeplate", "broadaxe", "scythe", "excavator", "largeblade", "hammerhead", "fullguard", "bowstring", "fletching", "arrowhead" }; + + public void getSubItems (int id, CreativeTabs tab, List list) + { + for (int i = 1; i < patternName.length; i++) + { + //if (i != 23) + list.add(new ItemStack(id, 1, i)); + } + } + + public ItemStack getContainerItemStack (ItemStack stack) + { + return stack; + } + + public boolean doesContainerItemLeaveCraftingGrid (ItemStack stack) + { + return false; + } + + /* Tags and information about the pattern */ + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + float cost = getPatternCost(stack) / 2f; + if (cost > 0) + { + if (cost - (int) cost < 0.1) + list.add("Material Cost: " + (int) cost); + else + list.add("Material Cost: " + cost); + } + } + + //2 for full material, 1 for half. + @Override + public int getPatternCost (ItemStack pattern) + { + switch (pattern.getItemDamage()) + { + case 0: + return 2; + case 1: + return 1; + case 2: + return 2; + case 3: + return 2; + case 4: + return 2; + case 5: + return 2; + case 6: + return 1; + case 7: + return 1; + case 8: + return 1; + case 9: + return 1; + case 10: + return 2; + case 11: + return 2; + case 12: + return 1; + case 13: + return 1; + case 14: + return 6; + case 15: + return 6; + case 16: + return 16; + case 17: + return 16; + case 18: + return 16; + case 19: + return 16; + case 20: + return 16; + case 21: + return 16; + case 22: + return 6; + case 23: + return 6; + case 24: + return 2; + case 25: + return 2; + default: + return 0; + } + } + + @Override + public ItemStack getPatternOutput (ItemStack stack, ItemStack input, MaterialSet set) + { + return TConstructRegistry.getPartMapping(this.itemID, stack.getItemDamage(), set.materialID); + } +} diff --git a/tconstruct/items/RedstoneBallRepeaterItem.java b/tconstruct/items/RedstoneBallRepeaterItem.java new file mode 100644 index 00000000..5320a41c --- /dev/null +++ b/tconstruct/items/RedstoneBallRepeaterItem.java @@ -0,0 +1,87 @@ +package tconstruct.items; + +import tconstruct.common.TContent; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RedstoneBallRepeaterItem extends Item +{ + public RedstoneBallRepeaterItem(int par1) + { + super(par1); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + /** + * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return + * True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ + public boolean onItemUse (ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par3World.getBlockId(par4, par5, par6) != Block.snow.blockID) + { + if (par7 == 0) + { + --par5; + } + + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + + if (!par3World.isAirBlock(par4, par5, par6)) + { + return false; + } + } + + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else + { + if (Block.redstoneWire.canPlaceBlockAt(par3World, par4, par5, par6)) + { + --par1ItemStack.stackSize; + par3World.setBlock(par4, par5, par6, TContent.redstoneBallRepeater.blockID); + } + + return true; + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("tinker:redstoneball"); + } +} diff --git a/tconstruct/items/SpecialFood.java b/tconstruct/items/SpecialFood.java new file mode 100644 index 00000000..951b176f --- /dev/null +++ b/tconstruct/items/SpecialFood.java @@ -0,0 +1,73 @@ +package tconstruct.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SpecialFood extends ItemFood +{ + int[] hunger; + float[] saturation; + String[] unlocalizedNames; + String[] iconNames; + Icon[] icons; + + public SpecialFood(int id, int[] hunger, float[] saturation, String[] textureNames, String[] iconNames) + { + super(id, 0, 0, false); + this.hunger = hunger; + this.saturation = saturation; + this.unlocalizedNames = textureNames; + this.iconNames = iconNames; + } + + @Override + public ItemStack onEaten (ItemStack stack, World world, EntityPlayer player) + { + stack.stackSize--; + int damage = stack.getItemDamage(); + player.getFoodStats().addStats(hunger[damage], saturation[damage]); + world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); + this.onFoodEaten(stack, world, player); + return stack; + } + + @SideOnly(Side.CLIENT) + public Icon getIconFromDamage (int meta) + { + return icons[meta]; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[iconNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + iconNames[i]); + } + } + + public String getUnlocalizedName (ItemStack stack) + { + int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, unlocalizedNames.length); + return getUnlocalizedName() + "." + unlocalizedNames[arr]; + } + + public void getSubItems (int id, CreativeTabs tab, List list) + { + for (int i = 0; i < unlocalizedNames.length; i++) + list.add(new ItemStack(id, 1, i)); + } +} diff --git a/tconstruct/items/StrangeFood.java b/tconstruct/items/StrangeFood.java new file mode 100644 index 00000000..e19080f0 --- /dev/null +++ b/tconstruct/items/StrangeFood.java @@ -0,0 +1,24 @@ +package tconstruct.items; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class StrangeFood extends SpecialFood +{ + public StrangeFood(int id) + { + super(id, new int[] { 2 }, new float[] { 1f }, new String[] { "edibleslime" }, new String[] { "edibleslime" }); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + list.add("\u00a7b\u00a7oIt smells terrible, but if you"); + list.add("\u00a7b\u00a7ohave nothing else to eat..."); + } +} diff --git a/tconstruct/items/TitleIcon.java b/tconstruct/items/TitleIcon.java new file mode 100644 index 00000000..487f7d91 --- /dev/null +++ b/tconstruct/items/TitleIcon.java @@ -0,0 +1,194 @@ +package tconstruct.items; + +import java.util.List; + +import tconstruct.client.TProxyClient; +import tconstruct.entity.BlueSlime; +import tconstruct.library.tools.ToolCore; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Facing; +import net.minecraft.util.Icon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class TitleIcon extends Item +{ + int[] primaryColor = { 0x66BBE8, 0x66BBE8 }; + int[] secondaryColor = { 0x1567BF, 0xFFEC6E }; + String[] mobNames = { "TConstruct.EdibleSlime", "TConstruct.KingSlime" }; + + public TitleIcon(int par1) + { + super(par1); + this.setCreativeTab(CreativeTabs.tabMisc); + } + + @Override + public void registerIcons (IconRegister iconRegister) + { + ToolCore.blankSprite = iconRegister.registerIcon("tinker:blanksprite"); + TProxyClient.metalBall = iconRegister.registerIcon("tinker:metalball"); + itemIcon = iconRegister.registerIcon("tinker:tparts"); + } + + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses () + { + return true; + } + + @SideOnly(Side.CLIENT) + public Icon getIconFromDamageForRenderPass (int par1, int par2) + { + if (par1 == 255) + return itemIcon; + return Item.monsterPlacer.getIconFromDamageForRenderPass(par1, par2); + } + + @Override + public String getItemDisplayName (ItemStack par1ItemStack) + { + String s = ("" + StatCollector.translateToLocal(this.getUnlocalizedName() + ".name")).trim(); + String s1 = mobNames[par1ItemStack.getItemDamage()]; + + if (s1 != null) + { + s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name"); + } + + return s; + } + + @Override + public void getSubItems (int id, CreativeTabs tab, List list) + { + for (int i = 0; i < mobNames.length; i++) + list.add(new ItemStack(id, 1, i)); + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack (ItemStack stack, int pass) + { + int damage = stack.getItemDamage(); + if (damage == 255) + return 0xffffff; + return pass == 0 ? primaryColor[damage] : secondaryColor[damage]; + } + + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int posX, int posY, int posZ, int par7, float par8, float par9, float par10) + { + if (!world.isRemote) + { + int i1 = world.getBlockId(posX, posY, posZ); + posX += Facing.offsetsXForSide[par7]; + posY += Facing.offsetsYForSide[par7]; + posZ += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if (par7 == 1 && Block.blocksList[i1] != null && Block.blocksList[i1].getRenderType() == 11) + { + d0 = 0.5D; + } + + int damage = stack.getItemDamage(); + switch (damage) + { + case 0: + spawnEntity(posX, posY, posZ, new BlueSlime(world), world, player); + break; + case 1: + spawnBossSlime(posX, posY, posZ, new BlueSlime(world), world, player); + break; + } + if (!player.capabilities.isCreativeMode) + { + --stack.stackSize; + } + } + return true; + } + + public static EntityLiving activateSpawnEgg (ItemStack stack, World world, double posX, double posY, double posZ, int par7) + { + int i1 = world.getBlockId((int) posX, (int) posY, (int) posZ); + posX += Facing.offsetsXForSide[par7]; + posY += Facing.offsetsYForSide[par7]; + posZ += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if (par7 == 1 && Block.blocksList[i1] != null && Block.blocksList[i1].getRenderType() == 11) + { + d0 = 0.5D; + } + + int damage = stack.getItemDamage(); + EntityLiving entity = null; + switch (damage) + { + case 0: + entity = new BlueSlime(world); + spawnEntity(posX, posY, posZ, entity, world); + break; + case 1: + entity = new BlueSlime(world); + spawnBossSlime(posX, posY, posZ, new BlueSlime(world), world); + break; + } + return entity; + } + + public static void spawnEntity (double x, double y, double z, Entity entity, World world) + { + if (!world.isRemote) + { + entity.setPosition(x, y, z); + ((EntityLiving) entity).func_110161_a((EntityLivingData)null); + world.spawnEntityInWorld(entity); + } + } + + public static void spawnEntity (double x, double y, double z, Entity entity, World world, EntityPlayer player) + { + if (!world.isRemote) + { + entity.setPosition(x, y, z); + entity.setAngles(player.cameraYaw, player.cameraYaw); + ((EntityLiving) entity).func_110161_a((EntityLivingData)null); + world.spawnEntityInWorld(entity); + } + } + + public static void spawnBossSlime (double x, double y, double z, BlueSlime entity, World world, EntityPlayer player) + { + if (!world.isRemote) + { + entity.setPosition(x, y, z); + entity.setAngles(player.cameraYaw, player.cameraYaw); + entity.setSlimeSize(8); + entity.func_110161_a((EntityLivingData)null); + world.spawnEntityInWorld(entity); + } + } + + public static void spawnBossSlime (double x, double y, double z, BlueSlime entity, World world) + { + if (!world.isRemote) + { + entity.setPosition(x, y, z); + entity.setSlimeSize(8); + entity.func_110161_a((EntityLivingData)null); + world.spawnEntityInWorld(entity); + } + } +} diff --git a/tconstruct/items/ToolPart.java b/tconstruct/items/ToolPart.java new file mode 100644 index 00000000..c139c8a3 --- /dev/null +++ b/tconstruct/items/ToolPart.java @@ -0,0 +1,53 @@ +package tconstruct.items; + +import java.util.List; + +import tconstruct.common.TContent; +import tconstruct.library.util.IToolPart; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; + +public class ToolPart extends CraftingItem implements IToolPart +{ + public ToolPart(int id, String textureType) + { + super(id, toolMaterialNames, buildTextureNames(textureType), "parts/"); + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + private static String[] buildTextureNames (String textureType) + { + String[] names = new String[toolMaterialNames.length]; + for (int i = 0; i < toolMaterialNames.length; i++) + { + if (toolTextureNames[i].equals("")) + names[i] = ""; + else + names[i] = toolTextureNames[i] + textureType; + } + return names; + } + + public static final String[] toolMaterialNames = new String[] { "Wood", "Stone", "Iron", "Flint", "Cactus", "Bone", "Obsidian", "Netherrack", "Slime", "Paper", "Cobalt", "Ardite", "Manyullyn", + "Copper", "Bronze", "Alumite", "Steel", "Blue Slime", "", "", "", "", "", "", "", "", "", "", "", "", "", "Thaumium" }; + + public static final String[] toolTextureNames = new String[] { "wood", "stone", "iron", "flint", "cactus", "bone", "obsidian", "netherrack", "slime", "paper", "cobalt", "ardite", "manyullyn", + "copper", "bronze", "alumite", "steel", "blueslime", "", "", "", "", "", "", "", "", "", "", "", "", "", "thaumium" }; + + public void getSubItems (int id, CreativeTabs tab, List list) + { + for (int i = 0; i < 17; i++) + list.add(new ItemStack(id, 1, i)); + + if (TContent.thaumcraftAvailable) + list.add(new ItemStack(id, 1, 31)); + } + + @Override + public int getMaterialID (ItemStack stack) + { + return stack.getItemDamage(); + } +} diff --git a/tconstruct/items/ToolPartHidden.java b/tconstruct/items/ToolPartHidden.java new file mode 100644 index 00000000..2b3352da --- /dev/null +++ b/tconstruct/items/ToolPartHidden.java @@ -0,0 +1,19 @@ +package tconstruct.items; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; + +public class ToolPartHidden extends ToolPart +{ + + public ToolPartHidden(int id, String textureType) + { + super(id, textureType); + } + + public void getSubItems (int id, CreativeTabs tab, List list) + { + + } +} diff --git a/tconstruct/items/ToolShard.java b/tconstruct/items/ToolShard.java new file mode 100644 index 00000000..2fc9ef15 --- /dev/null +++ b/tconstruct/items/ToolShard.java @@ -0,0 +1,65 @@ +package tconstruct.items; + +import java.util.List; + +import tconstruct.common.TContent; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ToolShard extends ToolPart +{ + + public ToolShard(int id, String tex) + { + super(id, tex); + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + private static String[] buildTextureNames (String textureType) + { + String[] names = new String[toolMaterialNames.length]; + for (int i = 0; i < toolMaterialNames.length; i++) + names[i] = toolTextureNames[i] + textureType; + return names; + } + + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < 5; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]); + } + icons[5] = icons[4]; + for (int i = 6; i < 9; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]); + } + icons[9] = icons[8]; + for (int i = 10; i < icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]); + } + } + + public void getSubItems (int id, CreativeTabs tab, List list) + { + for (int i = 1; i < 5; i++) + list.add(new ItemStack(id, 1, i)); + for (int i = 6; i < 9; i++) + list.add(new ItemStack(id, 1, i)); + for (int i = 10; i < 17; i++) + list.add(new ItemStack(id, 1, i)); + + if (TContent.thaumcraftAvailable) + list.add(new ItemStack(id, 1, 31)); + } +} diff --git a/tconstruct/items/armor/Glove.java b/tconstruct/items/armor/Glove.java new file mode 100644 index 00000000..d7d873b5 --- /dev/null +++ b/tconstruct/items/armor/Glove.java @@ -0,0 +1,20 @@ +package tconstruct.items.armor; + +import tconstruct.library.TConstructRegistry; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.item.Item; + +public class Glove extends Item +{ + public Glove(int par1) + { + super(par1); + this.setCreativeTab(TConstructRegistry.materialTab); + } + + @Override + public void registerIcons (IconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon("tinker:armor/dirthand"); + } +} diff --git a/tconstruct/items/armor/HeartCanister.java b/tconstruct/items/armor/HeartCanister.java new file mode 100644 index 00000000..7bae44df --- /dev/null +++ b/tconstruct/items/armor/HeartCanister.java @@ -0,0 +1,71 @@ +package tconstruct.items.armor; + +import java.util.List; + +import tconstruct.TConstruct; +import tconstruct.items.CraftingItem; +import tconstruct.util.player.ArmorExtended; +import tconstruct.util.player.TPlayerStats; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class HeartCanister extends CraftingItem +{ + + public HeartCanister(int id) + { + super(id, new String[] { "empty", "miniheart.red", "heart" }, new String[] { "canister_empty", "miniheart_red", "canister_heart" }, ""); + this.setMaxStackSize(10); + } + + @Override + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote && stack.getItemDamage() == 2) + { + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + if (stats != null) + { + ArmorExtended armor = stats.armor; + ItemStack slotStack = armor.getStackInSlot(6); + if (slotStack == null)// || slotStack.getItem() == this) + { + armor.setInventorySlotContents(6, new ItemStack(this, 1, 2)); + stack.stackSize--; + } + else if (slotStack.getItem() == this && slotStack.stackSize < this.maxStackSize) + { + slotStack.stackSize++; + stack.stackSize--; + } + armor.recalculateHealth(player, stats); + } + } + return stack; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage()) + { + case 0: + list.add("Crafting Item"); + break; + case 1: + list.add("Crafting Item"); + list.add("Part of low-level Heart Canisters"); + break; + case 2: + list.add("Accessory"); + list.add("Permanent health increase"); + break; + } + } + +} diff --git a/tconstruct/items/armor/Knapsack.java b/tconstruct/items/armor/Knapsack.java new file mode 100644 index 00000000..e8ee10b3 --- /dev/null +++ b/tconstruct/items/armor/Knapsack.java @@ -0,0 +1,33 @@ +package tconstruct.items.armor; + +import java.util.List; + +import tconstruct.items.CraftingItem; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Knapsack extends CraftingItem +{ + + public Knapsack(int id) + { + super(id, new String[] { "knapsack" }, new String[] { "knapsack" }, "armor/"); + this.setMaxStackSize(10); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage()) + { + case 0: + list.add("A Knapsack to hold your things."); + break; + } + } + +} diff --git a/tconstruct/items/armor/TArmorBase.java b/tconstruct/items/armor/TArmorBase.java new file mode 100644 index 00000000..7a9bf99e --- /dev/null +++ b/tconstruct/items/armor/TArmorBase.java @@ -0,0 +1,124 @@ +package tconstruct.items.armor; + +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumArmorMaterial; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class TArmorBase extends ItemArmor +//implements ISpecialArmor +{ + Icon[] icons; + String[] iconNames = { "wood_boots" }; + + //static Minecraft mc = Minecraft.getMinecraft(); + //private ModelBiped modelArmor; + + public TArmorBase(int id, int armorSlot) + { + super(id, EnumArmorMaterial.CLOTH, 0, armorSlot); + this.maxStackSize = 1; + this.setMaxDamage(100); + setNoRepair(); + canRepair = false; + this.setCreativeTab(CreativeTabs.tabMisc); + //this.modelArmor = new ModelBiped(0.75F); + //this.setCreativeTab(TConstructRegistry.toolTab); + } + + public void onArmorTickUpdate (World world, EntityPlayer player, ItemStack itemStack) + { + + } + + /** + * Called by RenderBiped and RenderPlayer to determine the armor texture that + * should be use for the currently equiped item. + * This will only be called on instances of ItemArmor. + * + * Returning null from this function will use the default value. + * + * @param stack ItemStack for the equpt armor + * @param entity The entity wearing the armor + * @param slot The slot the armor is in + * @param layer The render layer, either 1 or 2, 2 is only used for CLOTH armor by default + * @return Path of texture to bind, or null to use default + */ + @Override + @SideOnly(Side.CLIENT) + public String getArmorTexture (ItemStack stack, Entity entity, int slot, int layer) + { + return "/mods/tinker/textures/armor/wood_1.png"; + } + + /** + * Override this method to have an item handle its own armor rendering. + * + * @param entityLiving The entity wearing the armor + * @param itemStack The itemStack to render the model of + * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet + * + * @return A ModelBiped to render instead of the default + */ + @Override + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModel (EntityLivingBase par1EntityLiving, ItemStack itemStack, int armorSlot) + { + return null; + } + + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses () + { + return false; + } + + @SideOnly(Side.CLIENT) + @Override + public Icon getIconFromDamage (int meta) + { + return icons[0]; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[iconNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:armor/" + iconNames[i]); + } + } + + /*@Override + public ArmorProperties getProperties (EntityLiving player, ItemStack armor, DamageSource source, double damage, int slot) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getArmorDisplay (EntityPlayer player, ItemStack armor, int slot) + { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void damageArmor (EntityLiving entity, ItemStack stack, DamageSource source, int damage, int slot) + { + // TODO Auto-generated method stub + + }*/ +} diff --git a/tconstruct/items/blocks/CraftedSoilItemBlock.java b/tconstruct/items/blocks/CraftedSoilItemBlock.java new file mode 100644 index 00000000..eec72a9d --- /dev/null +++ b/tconstruct/items/blocks/CraftedSoilItemBlock.java @@ -0,0 +1,48 @@ +package tconstruct.items.blocks; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CraftedSoilItemBlock extends ItemBlock +{ + public static final String blockType[] = { "Slime", "Grout", "BlueSlime", "GraveyardSoil", "ConsecratedSoil" }; + + public CraftedSoilItemBlock(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("CraftedSoil.").append(blockType[pos]).toString(); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage()) + { + case 3: + list.add("Heals Undead"); + break; + case 4: + list.add("Harmful to Undead"); + break; + } + } +} diff --git a/tconstruct/items/blocks/GlassBlockItem.java b/tconstruct/items/blocks/GlassBlockItem.java new file mode 100644 index 00000000..279a40b0 --- /dev/null +++ b/tconstruct/items/blocks/GlassBlockItem.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class GlassBlockItem extends ItemBlock +{ + public static final String blockType[] = { "glass.pure"};//, "glass.soul", "glass.soul.pure" }; + + public GlassBlockItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/GlassPaneItem.java b/tconstruct/items/blocks/GlassPaneItem.java new file mode 100644 index 00000000..00edd252 --- /dev/null +++ b/tconstruct/items/blocks/GlassPaneItem.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class GlassPaneItem extends ItemBlock +{ + public static final String blockType[] = { "glass.pure", "glass.soul", "glass.soul.pure" }; + + public GlassPaneItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.").append(blockType[pos]).append(".pane").toString(); + } +} diff --git a/tconstruct/items/blocks/GravelOreItem.java b/tconstruct/items/blocks/GravelOreItem.java new file mode 100644 index 00000000..2bca15db --- /dev/null +++ b/tconstruct/items/blocks/GravelOreItem.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class GravelOreItem extends ItemBlock +{ + public static final String blockType[] = { "iron", "gold", "copper", "tin", "aluminum", "cobalt" }; + + public GravelOreItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.ore.gravel.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/LavaTankItemBlock.java b/tconstruct/items/blocks/LavaTankItemBlock.java new file mode 100644 index 00000000..47c47046 --- /dev/null +++ b/tconstruct/items/blocks/LavaTankItemBlock.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class LavaTankItemBlock extends ItemBlock +{ + public static final String blockType[] = { "Tank", "Gague", "Window" }; + + public LavaTankItemBlock(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("LavaTank.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/LightCrystalItem.java b/tconstruct/items/blocks/LightCrystalItem.java new file mode 100644 index 00000000..5256bfa5 --- /dev/null +++ b/tconstruct/items/blocks/LightCrystalItem.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; + +public class LightCrystalItem extends ItemBlock +{ + public static final String blockType[] = { "Crafter", "Parts", "Parts", "Parts", "Parts", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternShaper", + "PatternShaper", "PatternShaper", "PatternShaper", "CastingTable" }; + + public LightCrystalItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + /*@Override + public String getUnlocalizedName(ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length-1); + return (new StringBuilder()).append("ToolStation.").append(blockType[pos]).toString(); + }*/ +} diff --git a/tconstruct/items/blocks/MetalItemBlock.java b/tconstruct/items/blocks/MetalItemBlock.java new file mode 100644 index 00000000..d93e89b6 --- /dev/null +++ b/tconstruct/items/blocks/MetalItemBlock.java @@ -0,0 +1,37 @@ +package tconstruct.items.blocks; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class MetalItemBlock extends ItemBlock +{ + public static final String blockType[] = { "Cobalt", "Ardite", "Manyullyn", "Copper", "Bronze", "Tin", "Aluminum", "AlBrass", "Alumite", "Steel" }; + + public MetalItemBlock(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("StorageMetals.").append(blockType[pos]).toString(); + } + + @Override + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + list.add("Usable for Beacon bases"); + } +} diff --git a/tconstruct/items/blocks/MetalOreItemBlock.java b/tconstruct/items/blocks/MetalOreItemBlock.java new file mode 100644 index 00000000..71a53dfc --- /dev/null +++ b/tconstruct/items/blocks/MetalOreItemBlock.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class MetalOreItemBlock extends ItemBlock +{ + public static final String blockType[] = { "NetherSlag", "Cobalt", "Ardite", "Copper", "Tin", "Aluminum", "Slag" }; + + public MetalOreItemBlock(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("MetalOre.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/MultiBrickFancyItem.java b/tconstruct/items/blocks/MultiBrickFancyItem.java new file mode 100644 index 00000000..d50fce0b --- /dev/null +++ b/tconstruct/items/blocks/MultiBrickFancyItem.java @@ -0,0 +1,58 @@ +package tconstruct.items.blocks; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MultiBrickFancyItem extends ItemBlock +{ + static String blockType[] = { "obsidian", "sandstone", "netherrack", "stone.refined", "iron", "gold", "lapis", "diamond", "redstone", "bone", "slime", "blueslime", "endstone", "obsidian.ingot", + "stone", "stone.road" }; + + public MultiBrickFancyItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.fancybrick.").append(blockType[pos]).toString(); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage()) + { + case 5: + case 6: + list.add("Somewhat expensive"); + break; + case 7: + list.add("Quite expensive"); + break; + case 8: + list.add("Emits Redstone signal up to"); + list.add("4 blocks away"); + break; + case 10: + case 11: + list.add("Bouncy!"); + break; + } + } +} diff --git a/tconstruct/items/blocks/MultiBrickItem.java b/tconstruct/items/blocks/MultiBrickItem.java new file mode 100644 index 00000000..951a8c8c --- /dev/null +++ b/tconstruct/items/blocks/MultiBrickItem.java @@ -0,0 +1,58 @@ +package tconstruct.items.blocks; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MultiBrickItem extends ItemBlock +{ + static String blockType[] = { "obsidian", "sandstone", "netherrack", "stone.refined", "iron", "gold", "lapis", "diamond", "redstone", "bone", "slime", "blueslime", "endstone", "obsidian.ingot", + "stone.road", "stone.refined.road" }; + + public MultiBrickItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.brick.").append(blockType[pos]).toString(); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage()) + { + case 5: + case 6: + list.add("Somewhat expensive"); + break; + case 7: + list.add("Quite expensive"); + break; + case 8: + list.add("Emits Redstone signal up to"); + list.add("4 blocks away"); + break; + case 10: + case 11: + list.add("Bouncy!"); + break; + } + } +} diff --git a/tconstruct/items/blocks/OreberryBushItem.java b/tconstruct/items/blocks/OreberryBushItem.java new file mode 100644 index 00000000..e78e5662 --- /dev/null +++ b/tconstruct/items/blocks/OreberryBushItem.java @@ -0,0 +1,92 @@ +package tconstruct.items.blocks; + +import java.util.List; + +import tconstruct.common.TContent; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.IPlantable; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class OreberryBushItem extends ItemBlock +{ + public int blockID; + + public OreberryBushItem(int id) + { + super(id); + blockID = id + 256; + setHasSubtypes(true); + } + + @Override + public int getMetadata (int meta) + { + return meta % 4; + } + + /* Place bushes on dirt, grass, or other bushes only */ + @Override + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) + { + if (side != 1) + return false; + + else if (player.canPlayerEdit(x, y, z, side, stack) && player.canPlayerEdit(x, y + 1, z, side, stack)) + { + Block block = Block.blocksList[world.getBlockId(x, y, z)]; + + if (block != null && block.canSustainPlant(world, x, y, z, ForgeDirection.UP, (IPlantable) TContent.oreBerry) && world.isAirBlock(x, y + 1, z)) + { + world.setBlock(x, y + 1, z, blockID, stack.getItemDamage() % 4, 3); + if (!player.capabilities.isCreativeMode) + stack.stackSize--; + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, blockID); + return true; + } + else + return false; + } + else + return false; + } + + /* Block name in inventory */ + @Override + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.oreberry.").append(blockType[pos]).toString(); + } + + public static final String blockType[] = { "iron", "gold", "copper", "tin", "iron", "gold", "copper", "tin", "iron", "gold", "copper", "tin", "iron", "gold", "copper", "tin" }; + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage() % 4) + { + case 0: + list.add("Sweet Irony"); + break; + case 1: + list.add("Pure Luster"); + break; + case 2: + list.add("Tastes like metal"); + break; + case 3: + list.add("Tin Man"); + break; + } + } +} diff --git a/tconstruct/items/blocks/OreberryBushSecondItem.java b/tconstruct/items/blocks/OreberryBushSecondItem.java new file mode 100644 index 00000000..2db417c4 --- /dev/null +++ b/tconstruct/items/blocks/OreberryBushSecondItem.java @@ -0,0 +1,90 @@ +package tconstruct.items.blocks; + +import java.util.List; + +import tconstruct.common.TContent; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.IPlantable; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class OreberryBushSecondItem extends ItemBlock +{ + public int blockID; + + public OreberryBushSecondItem(int id) + { + super(id); + blockID = id + 256; + setHasSubtypes(true); + } + + @Override + public int getMetadata (int meta) + { + return meta % 4; + } + + /* Place bushes on dirt, grass, or other bushes only */ + @Override + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + if (side != 1) + return false; + + int meta = stack.getItemDamage(); + if (meta % 4 != 1 && world.getFullBlockLightValue(x, y + 1, z) >= 13) + return false; + + else if (player.canPlayerEdit(x, y, z, side, stack) && player.canPlayerEdit(x, y + 1, z, side, stack)) + { + Block block = Block.blocksList[world.getBlockId(x, y, z)]; + + if (block != null && block.canSustainPlant(world, x, y, z, ForgeDirection.UP, (IPlantable) TContent.oreBerrySecond) && world.isAirBlock(x, y + 1, z)) + { + world.setBlock(x, y + 1, z, blockID, stack.getItemDamage() % 4, 3); + if (!player.capabilities.isCreativeMode) + stack.stackSize--; + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, blockID); + return true; + } + else + return false; + } + else + return false; + } + + /* Block name in inventory */ + @Override + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.oreberry.").append(blockType[pos]).toString(); + } + + public static final String blockType[] = { "aluminum", "essence", "", "", "aluminum", "essence", "", "", "aluminum", "essence", "", "", "aluminum", "essence", "", "" }; + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage() % 4) + { + case 0: + list.add("White Chocolate"); + break; + case 1: + list.add("Tastes like Creeper"); + break; + } + } +} diff --git a/tconstruct/items/blocks/RedstoneMachineItem.java b/tconstruct/items/blocks/RedstoneMachineItem.java new file mode 100644 index 00000000..4d14fb1a --- /dev/null +++ b/tconstruct/items/blocks/RedstoneMachineItem.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class RedstoneMachineItem extends ItemBlock +{ + public static final String blockType[] = { "drawbridge", "firestarter" }; + + public RedstoneMachineItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/SearedSlabItem.java b/tconstruct/items/blocks/SearedSlabItem.java new file mode 100644 index 00000000..00627dcd --- /dev/null +++ b/tconstruct/items/blocks/SearedSlabItem.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class SearedSlabItem extends ItemBlock +{ + public static final String blockType[] = { "brick", "stone", "cobble", "paver", "road", "fancy", "square", "creeper" }; + + public SearedSlabItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.searedstone.slab.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/SearedTableItemBlock.java b/tconstruct/items/blocks/SearedTableItemBlock.java new file mode 100644 index 00000000..357ddef0 --- /dev/null +++ b/tconstruct/items/blocks/SearedTableItemBlock.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class SearedTableItemBlock extends ItemBlock +{ + public static final String blockType[] = { "Table", "Faucet", "Basin" }; + + public SearedTableItemBlock(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("SearedBlock.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/SmelteryItemBlock.java b/tconstruct/items/blocks/SmelteryItemBlock.java new file mode 100644 index 00000000..dfafdd05 --- /dev/null +++ b/tconstruct/items/blocks/SmelteryItemBlock.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class SmelteryItemBlock extends ItemBlock +{ + public static final String blockType[] = { "Controller", "Drain", "Brick", "Furnace", "Stone", "Cobblestone", "Paver", "Brick.Cracked", "Road", "Brick.Fancy", "Brick.Square" }; + + public SmelteryItemBlock(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("Smeltery.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/SoilSlabItem.java b/tconstruct/items/blocks/SoilSlabItem.java new file mode 100644 index 00000000..0c930cc1 --- /dev/null +++ b/tconstruct/items/blocks/SoilSlabItem.java @@ -0,0 +1,48 @@ +package tconstruct.items.blocks; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SoilSlabItem extends ItemBlock +{ + public static final String blockType[] = { "grass", "dirt", "mycelium", "slime", "grout", "blueslime", "graveyardsoil", "consecratedsoil" }; + + public SoilSlabItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.soil.slab.").append(blockType[pos]).toString(); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + switch (stack.getItemDamage()) + { + case 3: + list.add("Heals Undead"); + break; + case 4: + list.add("Harmful to Undead"); + break; + } + } +} diff --git a/tconstruct/items/blocks/SpeedBlockItem.java b/tconstruct/items/blocks/SpeedBlockItem.java new file mode 100644 index 00000000..a4e01ee2 --- /dev/null +++ b/tconstruct/items/blocks/SpeedBlockItem.java @@ -0,0 +1,41 @@ +package tconstruct.items.blocks; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class SpeedBlockItem extends ItemBlock +{ + public static final String blockType[] = { "brownstone.rough", "brownstone.rough.road", "brownstone.smooth", "brownstone.smooth.brick", "brownstone.smooth.road", "brownstone.smooth.fancy", + "brownstone.smooth.chiseled" }; + + public SpeedBlockItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.").append(blockType[pos]).toString(); + } + + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + int metadata = stack.getItemDamage(); + if (metadata == 1 || metadata == 4) + list.add("You run pretty fast on it"); + else + list.add("You run a bit faster on it"); + } +} diff --git a/tconstruct/items/blocks/SpeedSlabItem.java b/tconstruct/items/blocks/SpeedSlabItem.java new file mode 100644 index 00000000..151f1792 --- /dev/null +++ b/tconstruct/items/blocks/SpeedSlabItem.java @@ -0,0 +1,41 @@ +package tconstruct.items.blocks; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class SpeedSlabItem extends ItemBlock +{ + public static final String blockType[] = { "brownstone.rough", "brownstone.rough.road", "brownstone.smooth", "brownstone.smooth.brick", "brownstone.smooth.road", "brownstone.smooth.fancy", + "brownstone.smooth.chiseled" }; + + public SpeedSlabItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.").append(blockType[pos]).append(".slab").toString(); + } + + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + int metadata = stack.getItemDamage() % 8; + if (metadata == 1 || metadata == 4) + list.add("You run pretty fast on it"); + else + list.add("You run a bit faster on it"); + } +} diff --git a/tconstruct/items/blocks/StainedGlassClearItem.java b/tconstruct/items/blocks/StainedGlassClearItem.java new file mode 100644 index 00000000..237c10ec --- /dev/null +++ b/tconstruct/items/blocks/StainedGlassClearItem.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class StainedGlassClearItem extends ItemBlock +{ + public static final String blockType[] = { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "gray", "lightgray", "cyan", "purple", "blue", "brown", "green", "red", "black" }; + + public StainedGlassClearItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.stainedglass.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/StainedGlassClearPaneItem.java b/tconstruct/items/blocks/StainedGlassClearPaneItem.java new file mode 100644 index 00000000..ded8851c --- /dev/null +++ b/tconstruct/items/blocks/StainedGlassClearPaneItem.java @@ -0,0 +1,28 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class StainedGlassClearPaneItem extends ItemBlock +{ + public static final String blockType[] = { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "gray", "lightgray", "cyan", "purple", "blue", "brown", "green", "red", "black" }; + + public StainedGlassClearPaneItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.stainedglass.pane.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/blocks/ToolForgeItemBlock.java b/tconstruct/items/blocks/ToolForgeItemBlock.java new file mode 100644 index 00000000..52018495 --- /dev/null +++ b/tconstruct/items/blocks/ToolForgeItemBlock.java @@ -0,0 +1,27 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; + +public class ToolForgeItemBlock extends ItemBlock +{ + public static final String blockType[] = { "iron", "gold", "diamond", "emerald", "cobalt", "ardite", "manyullyn", "copper", "bronze", "tin", "aluminum", "alubrass", "alumite", "steel" }; + + public ToolForgeItemBlock(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + /*@Override + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("block.ToolForge.").append(blockType[pos]).toString(); + }*/ +} diff --git a/tconstruct/items/blocks/ToolStationItemBlock.java b/tconstruct/items/blocks/ToolStationItemBlock.java new file mode 100644 index 00000000..67429605 --- /dev/null +++ b/tconstruct/items/blocks/ToolStationItemBlock.java @@ -0,0 +1,30 @@ +package tconstruct.items.blocks; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public class ToolStationItemBlock extends ItemBlock +{ + public static final String blockType[] = { "Crafter", "Parts", "Parts", "Parts", "Parts", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternShaper", + "PatternShaper", "PatternShaper", "PatternShaper", "CastingTable" }; + + public ToolStationItemBlock(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + public int getMetadata (int meta) + { + return meta; + } + + @Override + public String getUnlocalizedName (ItemStack itemstack) + { + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); + return (new StringBuilder()).append("ToolStation.").append(blockType[pos]).toString(); + } +} diff --git a/tconstruct/items/tools/Arrow.java b/tconstruct/items/tools/Arrow.java new file mode 100644 index 00000000..9b674de4 --- /dev/null +++ b/tconstruct/items/tools/Arrow.java @@ -0,0 +1,227 @@ +package tconstruct.items.tools; + +import java.util.List; + +import tconstruct.common.TContent; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.tools.ToolCore; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Arrow extends ToolCore +{ + + public Arrow(int id) + { + super(id, 3); + this.setUnlocalizedName("InfiTool.Arrow"); + this.setMaxStackSize(64); + this.setMaxDamage(0); + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_arrow_head"; + case 1: + return ""; //Doesn't break + case 2: + return "_arrow_shaft"; + case 3: + return "_arrow_fletching"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_arrow_effect"; + } + + @Override + public String getDefaultFolder () + { + return "arrow"; + } + + @Override + public void registerPartPaths (int index, String[] location) + { + headStrings.put(index, location[0]); + handleStrings.put(index, location[2]); + } + + @Override + public void registerAlternatePartPaths (int index, String[] location) + { + accessoryStrings.put(index, location[3]); + } + + @Override + public Item getHeadItem () + { + return TContent.arrowhead; + } + + @Override + public Item getAccessoryItem () + { + return TContent.fletching; + } + + @Override + public String[] toolCategories () + { + return new String[] { "ammo" }; + } + + @Override + public void getSubItems (int id, CreativeTabs tab, List list) + { + //Vanilla style arrow + Item accessory = getAccessoryItem(); + ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, 0) : null; + Item extra = getExtraItem(); + ItemStack extraStack = extra != null ? new ItemStack(extra, 1, 0) : null; + ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, 3), new ItemStack(getHandleItem(), 1, 0), accessoryStack, extraStack, ""); + if (tool == null) + { + System.out.println("Creative builder failed tool for Vanilla style" + this.getToolName()); + System.out.println("Make sure you do not have item ID conflicts"); + } + else + { + tool.stackSize = 1; + tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true); + list.add(tool); + } + + //Random arrow + accessory = getAccessoryItem(); + accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, random.nextInt(4)) : null; + extra = getExtraItem(); + extraStack = extra != null ? new ItemStack(extra, 1, 0) : null; + tool = ToolBuilder.instance + .buildTool(new ItemStack(getHeadItem(), 1, random.nextInt(18)), new ItemStack(getHandleItem(), 1, random.nextInt(18)), accessoryStack, extraStack, "Random Streamer"); + + if (tool == null) + { + System.out.println("Creative builder failed tool for Vanilla style" + this.getToolName()); + System.out.println("Make sure you do not have item ID conflicts"); + } + else + { + tool.stackSize = 1; + tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true); + list.add(tool); + } + super.getSubItems(id, tab, list); + } + + @Override + public void buildTool (int id, String name, List list) + { + Item accessory = getAccessoryItem(); + ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, 0) : null; + Item extra = getExtraItem(); + ItemStack extraStack = extra != null ? new ItemStack(getExtraItem(), 1, id) : null; + ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), new ItemStack(getHandleItem(), 1, id), accessoryStack, extraStack, name + getToolName()); + if (tool == null) + { + System.out.println("Creative builder failed tool for " + name + this.getToolName()); + System.out.println("Make sure you do not have item ID conflicts"); + } + else + { + tool.stackSize = 1; + tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true); + list.add(tool); + } + } + + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ) + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + if (!stack.hasTagCompound()) + return; + + NBTTagCompound tags = stack.getTagCompound(); + if (tags.hasKey("charge")) + { + String color = ""; + //double joules = this.getJoules(stack); + int power = tags.getInteger("charge"); + + if (power != 0) + { + if (power <= this.getMaxCharge(stack) / 3) + color = "\u00a74"; + else if (power > this.getMaxCharge(stack) * 2 / 3) + color = "\u00a72"; + else + color = "\u00a76"; + } + + String charge = new StringBuilder().append(color).append(tags.getInteger("charge")).append("/").append(getMaxCharge(stack)).append(" EU").toString(); + list.add(charge); + } + if (tags.hasKey("InfiTool")) + { + boolean broken = tags.getCompoundTag("InfiTool").getBoolean("Broken"); + if (broken) + list.add("\u00A7oBroken"); + else + { + int head = tags.getCompoundTag("InfiTool").getInteger("Head"); + int handle = tags.getCompoundTag("InfiTool").getInteger("Handle"); + + String headName = getAbilityNameForType(head); + if (!headName.equals("")) + list.add(getStyleForType(head) + headName); + + String handleName = getAbilityNameForType(handle); + if (!handleName.equals("") && handle != head) + list.add(getStyleForType(handle) + handleName); + + int unbreaking = tags.getCompoundTag("InfiTool").getInteger("Unbreaking"); + String reinforced = getReinforcedName(head, handle, 0, 0, unbreaking); + if (!reinforced.equals("")) + list.add(reinforced); + + boolean displayToolTips = true; + int tipNum = 0; + while (displayToolTips) + { + tipNum++; + String tooltip = "Tooltip" + tipNum; + if (tags.getCompoundTag("InfiTool").hasKey(tooltip)) + { + String tipName = tags.getCompoundTag("InfiTool").getString(tooltip); + if (!tipName.equals("")) + list.add(tipName); + } + else + displayToolTips = false; + } + } + } + } +} diff --git a/tconstruct/items/tools/BattleSign.java b/tconstruct/items/tools/BattleSign.java new file mode 100644 index 00000000..5dc71435 --- /dev/null +++ b/tconstruct/items/tools/BattleSign.java @@ -0,0 +1,159 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.tools.Weapon; +import net.minecraft.item.Item; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BattleSign extends Weapon +{ + public BattleSign(int itemID) + { + super(itemID, 1); + this.setUnlocalizedName("InfiTool.Battlesign"); + } + + /*public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (!player.isSneaking()) + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + return stack; + }*/ + + public String getToolName () + { + return "Battlesign"; + } + + /*public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par7 == 0 || !player.isSneaking()) + { + return false; + } + else if (!par3World.getBlockMaterial(par4, par5, par6).isSolid()) + { + return false; + } + else + { + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + + if (!player.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else if (!Block.signPost.canPlaceBlockAt(par3World, par4, par5, par6)) + { + return false; + } + else + { + if (par7 == 1) + { + int var11 = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15; + par3World.setBlock(par4, par5, par6, Block.signPost.blockID, var11); + } + else + { + par3World.setBlock(par4, par5, par6, Block.signWall.blockID, par7); + } + + //--par1ItemStack.stackSize; + TileEntitySign var12 = (TileEntitySign)par3World.getBlockTileEntity(par4, par5, par6); + + if (var12 != null) + { + player.displayGUIEditSign(var12); + } + + return true; + } + } + }*/ + + @Override + public Item getHeadItem () + { + return TContent.signHead; + } + + @Override + public Item getAccessoryItem () + { + return null; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 8; + } + + @Override + public int getPartAmount () + { + return 2; + } + + @Override + public void registerPartPaths (int index, String[] location) + { + headStrings.put(index, location[0]); + brokenPartStrings.put(index, location[1]); + handleStrings.put(index, location[2]); + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_battlesign_head"; + case 1: + return "_battlesign_head_broken"; + case 2: + return "_battlesign_handle"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_battlesign_effect"; + } + + @Override + public String getDefaultFolder () + { + return "battlesign"; + } +} diff --git a/tconstruct/items/tools/Battleaxe.java b/tconstruct/items/tools/Battleaxe.java new file mode 100644 index 00000000..56db1d50 --- /dev/null +++ b/tconstruct/items/tools/Battleaxe.java @@ -0,0 +1,292 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.HarvestTool; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Battleaxe extends HarvestTool +{ + public Battleaxe(int itemID) + { + super(itemID, 4); + this.setUnlocalizedName("InfiTool.Battleaxe"); + } + + @Override + protected Material[] getEffectiveMaterials () + { + return materials; + } + + @Override + protected String getHarvestType () + { + return "axe"; + } + + @Override + public boolean onBlockDestroyed (ItemStack itemstack, World world, int bID, int x, int y, int z, EntityLivingBase player) + { + Block block = Block.blocksList[bID]; + if (block != null && block.blockMaterial == Material.leaves) + return false; + + return AbilityHelper.onBlockChanged(itemstack, world, bID, x, y, z, player, random); + } + + static Material[] materials = { Material.wood, Material.vine, Material.circuits, Material.cactus, Material.pumpkin }; + + @Override + public Item getHeadItem () + { + return TContent.broadAxeHead; + } + + @Override + public Item getHandleItem () + { + return TContent.toughRod; + } + + @Override + public Item getAccessoryItem () + { + return TContent.broadAxeHead; + } + + @Override + public Item getExtraItem () + { + return TContent.toughBinding; + } + + @Override + public int durabilityTypeAccessory () + { + return 2; + } + + @Override + public int durabilityTypeExtra () + { + return 1; + } + + @Override + public float getRepairCost () + { + return 4.0f; + } + + public float getDurabilityModifier () + { + return 2.5f; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 10; + } + + @Override + public int getPartAmount () + { + return 4; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_battleaxe_fronthead"; + case 1: + return "_battleaxe_fronthead_broken"; + case 2: + return "_battleaxe_handle"; + case 3: + return "_battleaxe_backhead"; + case 4: + return "_battleaxe_binding"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_battleaxe_effect"; + } + + @Override + public String getDefaultFolder () + { + return "battleaxe"; + } + + @Override + public String[] toolCategories () + { + return new String[] { "weapon", "harvest", "melee", "slicing" }; + } + + /* Battleaxe Specific */ + + @Override + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ) + { + return false; + } + + @Override + public EnumAction getItemUseAction (ItemStack par1ItemStack) + { + return EnumAction.bow; + } + + @Override + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + { + //player.rotationYaw += 1; + //if (player.onGround) + //{ + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + //} + return stack; + } + + @Override + public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int useCount) + { + //if (player.onGround) + { + int time = this.getMaxItemUseDuration(stack) - useCount; + int boost = time / 100; + if (boost > 2) + boost = 2; + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, time * 4, boost)); + player.addPotionEffect(new PotionEffect(Potion.jump.id, time * 4, boost)); + player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, time * 4, 0)); + player.addPotionEffect(new PotionEffect(Potion.hunger.id, time * 2, 0)); + if (time > 5 && player.onGround) + { + player.addExhaustion(0.2F); + player.setSprinting(true); + + float speed = 0.025F * time; + if (speed > 0.925f) + speed = 0.925f; + + float increase = (float) (0.02 * time + 0.2); + if (increase > 0.56f) + increase = 0.56f; + player.motionY += increase; + + player.motionX = (double) (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed); + player.motionZ = (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed); + } + } + } + + public int getMaxItemUseDuration (ItemStack par1ItemStack) + { + return 72000; + } + + @Override + public boolean hitEntity (ItemStack stack, EntityLivingBase mob, EntityLivingBase player) + { + AbilityHelper.knockbackEntity(mob, 1.5f); + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayerSP) + { + EntityPlayerSP player = (EntityPlayerSP) entity; + ItemStack usingItem = player.getItemInUse(); + if (usingItem != null && usingItem.getItem() == this) + { + player.movementInput.moveForward *= 5.0F; + player.movementInput.moveStrafe *= 5.0F; + } + } + } + + @Override + public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) + { + World world = player.worldObj; + final int woodID = world.getBlockId(x, y, z); + final Block wood = Block.blocksList[woodID]; + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + final int meta = world.getBlockMetadata(x, y, z); + for (int yPos = y + 1; yPos < y + 9; yPos++) + { + int blockID = world.getBlockId(x, yPos, z); + Block block = Block.blocksList[blockID]; + if (!(tags.getBoolean("Broken")) && block != null && block.blockMaterial == Material.wood) + { + int localblockID = world.getBlockId(x, yPos, z); + int localMeta = world.getBlockMetadata(x, yPos, z); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + + if (hlvl <= tags.getInteger("HarvestLevel")) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, x, yPos, z, player)) + cancelHarvest = true; + } + + if (!cancelHarvest) + { + if (block != null && block.blockMaterial == Material.wood) + { + localMeta = world.getBlockMetadata(x, yPos, z); + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, x, yPos, z, localMeta); + block.onBlockHarvested(world, x, y, z, localMeta, player); + onBlockDestroyed(stack, world, localblockID, x, yPos, z, player); + } + world.setBlockToAir(x, yPos, z); + } + } + } + } + + } + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, woodID + (meta << 12)); + return super.onBlockStartBreak(stack, x, y, z, player); + } +} diff --git a/tconstruct/items/tools/Broadsword.java b/tconstruct/items/tools/Broadsword.java new file mode 100644 index 00000000..6e9baef0 --- /dev/null +++ b/tconstruct/items/tools/Broadsword.java @@ -0,0 +1,77 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.tools.Weapon; +import net.minecraft.item.Item; + +public class Broadsword extends Weapon +{ + public Broadsword(int itemID) + { + super(itemID, 4); + this.setUnlocalizedName("InfiTool.Broadsword"); + } + + @Override + public Item getHeadItem () + { + return TContent.swordBlade; + } + + @Override + public Item getAccessoryItem () + { + return TContent.wideGuard; + } + + public float getDurabilityModifier () + { + return 1.2f; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_sword_blade"; + case 1: + return "_sword_blade_broken"; + case 2: + return "_sword_handle"; + case 3: + return "_sword_accessory"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_sword_effect"; + } + + @Override + public String getDefaultFolder () + { + return "broadsword"; + } + + /*@Override + @SideOnly(Side.CLIENT) + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayerSP) + { + EntityPlayerSP player = (EntityPlayerSP) entity; + if (player.itemInUse != null && player.itemInUse.getItem() == this) + { + player.movementInput.moveForward *= 5.0F; + player.movementInput.moveStrafe *= 5.0F; + } + } + }*/ +} diff --git a/tconstruct/items/tools/Chisel.java b/tconstruct/items/tools/Chisel.java new file mode 100644 index 00000000..487dc283 --- /dev/null +++ b/tconstruct/items/tools/Chisel.java @@ -0,0 +1,228 @@ +package tconstruct.items.tools; + +import tconstruct.TConstruct; +import tconstruct.common.TContent; +import tconstruct.library.crafting.Detailing.DetailInput; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.ToolCore; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumMovingObjectType; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Chisel extends ToolCore +{ + public Chisel(int id) + { + super(id, 0); + this.setUnlocalizedName("InfiTool.Chisel"); + this.setContainerItem(this); + } + + @Override + public ItemStack getContainerItemStack (ItemStack itemStack) + { + //AbilityHelper.damageTool(itemStack, 1, null, false); + + int reinforced = 0; + NBTTagCompound tags = itemStack.getTagCompound(); + + if (tags.getCompoundTag("InfiTool").hasKey("Unbreaking")) + reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking"); + + if (random.nextInt(10) < 10 - reinforced) + { + AbilityHelper.damageTool(itemStack, 1, null, false); + } + return itemStack; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid (ItemStack par1ItemStack) + { + return false; + } + + boolean performDetailing (World world, int x, int y, int z, int blockID, int blockMeta) + { + boolean detailed = false; + return detailed; + } + + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ) + { + return false; + } + + @Override + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer entityplayer) + { + if (entityplayer.capabilities.isCreativeMode) + { + onEaten(stack, world, entityplayer); + } + else + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.getBoolean("Broken")) + entityplayer.setItemInUse(stack, getMaxItemUseDuration(stack)); + } + return stack; + } + + @Override + public ItemStack onEaten (ItemStack itemstack, World world, EntityPlayer entityplayer) + { + if (!world.isRemote) + { + MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, entityplayer, true); + if (movingobjectposition == null) + { + return itemstack; + } + if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) + { + int x = movingobjectposition.blockX; + int y = movingobjectposition.blockY; + int z = movingobjectposition.blockZ; + int blockID = world.getBlockId(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + DetailInput details = TConstruct.chiselDetailing.getDetailing(blockID, meta); + if (details != null && details.outputID < 4096) + { + world.setBlock(x, y, z, details.outputID, details.outputMeta, 3); + if (!(entityplayer.capabilities.isCreativeMode)) + { + int reinforced = 0; + NBTTagCompound tags = itemstack.getTagCompound(); + + if (tags.getCompoundTag("InfiTool").hasKey("Unbreaking")) + reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking"); + + if (random.nextInt(10) < 10 - reinforced) + { + AbilityHelper.damageTool(itemstack, 1, null, false); + } + } + world.playAuxSFX(2001, x, y, z, blockID + (meta << 12)); + entityplayer.swingItem(); + } + } + } + + return itemstack; + } + + @Override + @SideOnly(Side.CLIENT) + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayerSP) + { + EntityPlayerSP player = (EntityPlayerSP) entity; + ItemStack usingItem = player.getItemInUse(); + if (usingItem != null && usingItem.getItem() == this) + { + player.movementInput.moveForward *= 2.0; + player.movementInput.moveStrafe *= 2.0; + } + } + } + + @Override + public int getMaxItemUseDuration (ItemStack itemstack) + { + if (!itemstack.hasTagCompound()) + return 20; + + int speed = itemstack.getTagCompound().getCompoundTag("InfiTool").getInteger("MiningSpeed") / 100; + int truespeed = 20 - speed; + if (truespeed < 0) + truespeed = 0; + return truespeed; + } + + @Override + public EnumAction getItemUseAction (ItemStack itemstack) + { + return EnumAction.eat; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 8; + } + + @Override + public int getPartAmount () + { + return 2; + } + + @Override + public void registerPartPaths (int index, String[] location) + { + headStrings.put(index, location[0]); + brokenPartStrings.put(index, location[1]); + handleStrings.put(index, location[2]); + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_chisel_head"; + case 1: + return "_chisel_head_broken"; + case 2: + return "_chisel_handle"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_chisel_effect"; + } + + @Override + public String getDefaultFolder () + { + return "chisel"; + } + + @Override + public Item getHeadItem () + { + return TContent.chiselHead; + } + + @Override + public Item getAccessoryItem () + { + return null; + } + + @Override + public String[] toolCategories () + { + return new String[] { "utility" }; + } + +} diff --git a/tconstruct/items/tools/Cleaver.java b/tconstruct/items/tools/Cleaver.java new file mode 100644 index 00000000..26cd40b4 --- /dev/null +++ b/tconstruct/items/tools/Cleaver.java @@ -0,0 +1,164 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.Weapon; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Cleaver extends Weapon +{ + public Cleaver(int itemID) + { + super(itemID, 4); + this.setUnlocalizedName("InfiTool.Cleaver"); + } + + @Override + public Item getHeadItem () + { + return TContent.largeSwordBlade; + } + + @Override + public Item getHandleItem () + { + return TContent.toughRod; + } + + @Override + public Item getAccessoryItem () + { + return TContent.heavyPlate; + } + + @Override + public Item getExtraItem () + { + return TContent.toughRod; + } + + @Override + public int durabilityTypeAccessory () + { + return 2; + } + + @Override + public int durabilityTypeExtra () + { + return 1; + } + + @Override + public float getRepairCost () + { + return 4.0f; + } + + @Override + public float getDurabilityModifier () + { + return 2.5f; + } + + @Override + public float getDamageModifier () + { + return 1.25f; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 10; + } + + @Override + public int getPartAmount () + { + return 4; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_cleaver_head"; + case 1: + return "_cleaver_head_broken"; + case 2: + return "_cleaver_handle"; + case 3: + return "_cleaver_shield"; + case 4: + return "_cleaver_guard"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_cleaver_effect"; + } + + @Override + public String getDefaultFolder () + { + return "cleaver"; + } + + /* Cleaver specific */ + @Override + public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity) + { + if (AbilityHelper.onLeftClickEntity(stack, player, entity, this)) + { + entity.hurtResistantTime += 7; + + /*if (entity instanceof EntityLiving) + { + EntityLiving living = (EntityLiving) entity; + if (living.getHealth() <= 0) + { + + } + }*/ + //if (entity.getHealth() <= 0) + } + return true; + } + + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) entity; + ItemStack equipped = player.getCurrentEquippedItem(); + if (equipped == stack) + { + player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 2)); + } + } + } + + /*@Override + public boolean onEntitySwing (EntityLiving entity, ItemStack stack) + { + entity.swingProgressInt /= 2; + return false; + }*/ +} diff --git a/tconstruct/items/tools/Cutlass.java b/tconstruct/items/tools/Cutlass.java new file mode 100644 index 00000000..c2ec8fc0 --- /dev/null +++ b/tconstruct/items/tools/Cutlass.java @@ -0,0 +1,71 @@ +package tconstruct.items.tools; + +import java.util.List; + +import tconstruct.common.TContent; +import tconstruct.library.tools.Weapon; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class Cutlass extends Weapon +{ + public Cutlass(int itemID) + { + super(itemID, 4); + this.setUnlocalizedName("InfiTool.Cutlass"); + } + + @Override + public Item getHeadItem () + { + return TContent.swordBlade; + } + + @Override + public Item getAccessoryItem () + { + return TContent.fullGuard; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_cutlass_blade"; + case 1: + return "_cutlass_blade_broken"; + case 2: + return "_cutlass_handle"; + case 3: + return "_cutlass_guard"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_cutlass_effect"; + } + + @Override + public String getDefaultFolder () + { + return "cutlass"; + } + + @Override + public int durabilityTypeAccessory () + { + return 1; + } + + public void getSubItems (int id, CreativeTabs tab, List list) + { + + } +} diff --git a/tconstruct/items/tools/Dagger.java b/tconstruct/items/tools/Dagger.java new file mode 100644 index 00000000..04f032ec --- /dev/null +++ b/tconstruct/items/tools/Dagger.java @@ -0,0 +1,108 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.entity.projectile.DaggerEntity; +import tconstruct.library.tools.Weapon; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class Dagger extends Weapon +{ + public Dagger(int id) + { + super(id, 1); + this.setUnlocalizedName("InfiTool.Dagger"); + } + + public ItemStack onItemRightClick (ItemStack itemstack, World world, EntityPlayer player) + { + ItemStack stack = itemstack.copy(); + if (!world.isRemote) + { + DaggerEntity dagger = new DaggerEntity(stack, world, player); + world.spawnEntityInWorld(dagger); + } + itemstack.stackSize--; + return itemstack; + /*player.setItemInUse(itemstack, this.getMaxItemUseDuration(itemstack)); + return itemstack;*/ + } + + public ItemStack onEaten (ItemStack itemstack, World world, EntityPlayer player) + { + ItemStack stack = itemstack.copy(); + if (!world.isRemote) + { + DaggerEntity dagger = new DaggerEntity(stack, world, player); + world.spawnEntityInWorld(dagger); + } + itemstack.stackSize--; + return itemstack; + } + + @Override + public String[] toolCategories () + { + return new String[] { "weapon", "melee", "throwing" }; + } + + public EnumAction getItemUseAction (ItemStack par1ItemStack) + { + return EnumAction.bow; + } + + public int getMaxItemUseDuration (ItemStack stack) + { + return 10; + } + + public boolean rangedTool () + { + return true; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_dagger_blade"; + case 1: + return "_dagger_blade_broken"; + case 2: + return "_dagger_handle"; + case 3: + return "_dagger_accessory"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_dagger_effect"; + } + + @Override + public String getDefaultFolder () + { + return "dagger"; + } + + @Override + public Item getHeadItem () + { + return TContent.knifeBlade; + } + + @Override + public Item getAccessoryItem () + { + return TContent.crossbar; + } +} diff --git a/tconstruct/items/tools/Excavator.java b/tconstruct/items/tools/Excavator.java new file mode 100644 index 00000000..480f95a4 --- /dev/null +++ b/tconstruct/items/tools/Excavator.java @@ -0,0 +1,300 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.HarvestTool; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Excavator extends HarvestTool +{ + public Excavator(int itemID) + { + super(itemID, 2); + this.setUnlocalizedName("InfiTool.Excavator"); + } + + @Override + protected Material[] getEffectiveMaterials () + { + return materials; + } + + @Override + protected String getHarvestType () + { + return "shovel"; + } + + static Material[] materials = { Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay }; + + @Override + public Item getHeadItem () + { + return TContent.excavatorHead; + } + + @Override + public Item getHandleItem () + { + return TContent.toughRod; + } + + @Override + public Item getAccessoryItem () + { + return TContent.heavyPlate; + } + + @Override + public Item getExtraItem () + { + return TContent.toughBinding; + } + + @Override + public float getRepairCost () + { + return 4.0f; + } + + public float getDurabilityModifier () + { + return 2.75f; + } + + @Override + public int durabilityTypeAccessory () + { + return 2; + } + + @Override + public int durabilityTypeExtra () + { + return 1; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 10; + } + + @Override + public int getPartAmount () + { + return 4; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_excavator_head"; + case 1: + return "_excavator_head_broken"; + case 2: + return "_excavator_handle"; + case 3: + return "_excavator_binding"; + case 4: + return "_excavator_grip"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_excavator_effect"; + } + + @Override + public String getDefaultFolder () + { + return "excavator"; + } + + /* Excavator Specific */ + + @Override + public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) + { + World world = player.worldObj; + final int blockID = world.getBlockId(x, y, z); + final int meta = world.getBlockMetadata(x, y, z); + Block block = Block.blocksList[blockID]; + if (!stack.hasTagCompound()) + return false; + + if (block == null) + return super.onBlockStartBreak(stack, x, y, z, player); + + float blockHardness = block.getBlockHardness(world, x, y, z); + + boolean validStart = false; + for (int iter = 0; iter < materials.length; iter++) + { + if (materials[iter] == block.blockMaterial) + { + validStart = true; + break; + } + } + + MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, true, 5.0D); + if (mop == null || !validStart) + return super.onBlockStartBreak(stack, x, y, z, player); + + int xRange = 1; + int yRange = 1; + int zRange = 1; + switch (mop.sideHit) + { + case 0: + case 1: + yRange = 0; + break; + case 2: + case 3: + zRange = 0; + break; + case 4: + case 5: + xRange = 0; + break; + } + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + for (int xPos = x - xRange; xPos <= x + xRange; xPos++) + { + for (int yPos = y - yRange; yPos <= y + yRange; yPos++) + { + for (int zPos = z - zRange; zPos <= z + zRange; zPos++) + { + if (!(tags.getBoolean("Broken"))) + { + int localblockID = world.getBlockId(xPos, yPos, zPos); + block = Block.blocksList[localblockID]; + int localMeta = world.getBlockMetadata(xPos, yPos, zPos); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + float localHardness = block == null ? Float.MAX_VALUE : block.getBlockHardness(world, xPos, yPos, zPos); + + if (hlvl <= tags.getInteger("HarvestLevel") && localHardness - 1.5 <= blockHardness) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player)) + cancelHarvest = true; + } + + if (!cancelHarvest) + { + if (block != null && !(localHardness < 0)) + { + for (int iter = 0; iter < materials.length; iter++) + { + if (materials[iter] == block.blockMaterial) + { + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, xPos, yPos, zPos, localMeta); + block.onBlockHarvested(world, x, y, z, localMeta, player); + if (blockHardness > 0f) + onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); + } + world.setBlockToAir(xPos, yPos, zPos); + } + } + } + } + } + } + } + } + } + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, blockID + (meta << 12)); + return true; + } + + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + if (!stack.hasTagCompound()) + return 1.0f; + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return 0.1f; + + Material[] materials = getEffectiveMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } + + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } + + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + float trueSpeed = mineSpeed / (heads * 300f); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); + + float stonebound = tags.getFloat("Shoddy"); + float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; + trueSpeed += bonusLog; + + if (hlvl <= tags.getInteger("HarvestLevel")) + return trueSpeed; + return 0.1f; + } + } + return super.getStrVsBlock(stack, block, meta); + } + /*@Override + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) entity; + ItemStack equipped = player.getCurrentEquippedItem(); + if (equipped == stack) + { + player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1)); + } + } + }*/ +} diff --git a/tconstruct/items/tools/FryingPan.java b/tconstruct/items/tools/FryingPan.java new file mode 100644 index 00000000..f5c7ea16 --- /dev/null +++ b/tconstruct/items/tools/FryingPan.java @@ -0,0 +1,202 @@ +package tconstruct.items.tools; + +import java.util.List; + +import tconstruct.blocks.logic.EquipLogic; +import tconstruct.common.TContent; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.Weapon; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class FryingPan extends Weapon +{ + public FryingPan(int itemID) + { + super(itemID, 2); + this.setUnlocalizedName("InfiTool.FryingPan"); + } + + @Override + public boolean hitEntity (ItemStack stack, EntityLivingBase mob, EntityLivingBase player) + { + AbilityHelper.knockbackEntity(mob, 1.7f); + mob.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 0)); //5 seconds of stun + return true; + } + + @Override + public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity mob) + { + if (mob.canAttackWithItem() && !mob.func_85031_j(player) && mob.hurtResistantTime < 14) + AbilityHelper.onLeftClickEntity(stack, player, mob, this); + return true; + } + + @Override + public void onEntityDamaged (World world, EntityLivingBase player, Entity entity) + { + world.playSoundEffect(entity.posX, entity.posY, entity.posZ, "sounds.frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F); + } + + public String getToolName () + { + return "Frying Pan"; + } + + public void getSubItems (int id, CreativeTabs tab, List list) + { + super.getSubItems(id, tab, list); + + Item accessory = getAccessoryItem(); + ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, 2), new ItemStack(getHandleItem(), 1, 16), null, "Bane of Pigs"); + + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + tags.setInteger("Modifiers", 0); + tags.setInteger("Attack", Integer.MAX_VALUE / 100); + tags.setInteger("TotalDurability", Integer.MAX_VALUE / 100); + tags.setInteger("BaseDurability", Integer.MAX_VALUE / 100); + tags.setInteger("MiningSpeed", Integer.MAX_VALUE / 100); + + int[] keyPair = new int[] { Integer.MAX_VALUE / 100, 0, 0 }; + tags.setIntArray("Blaze", keyPair); + tags.setInteger("Necrotic", Integer.MAX_VALUE / 100); + tags.setInteger("Effect1", 7); + + tags.setBoolean("Built", true); + list.add(tool); + } + + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ) + { + if (side == 0 || !player.isSneaking()) + { + return false; + } + else if (!world.getBlockMaterial(x, y, z).isSolid()) + { + return false; + } + else + { + if (side == 1) + { + ++y; + } + + if (side == 2) + { + --z; + } + + if (side == 3) + { + ++z; + } + + if (side == 4) + { + --x; + } + + if (side == 5) + { + ++x; + } + + if (!player.canPlayerEdit(x, y, z, side, stack)) + { + return false; + } + else if (!TContent.heldItemBlock.canPlaceBlockAt(world, x, y, z)) + { + return false; + } + else + { + world.setBlock(x, y, z, TContent.heldItemBlock.blockID, 0, 3); + world.playSoundEffect(x, y, z, "sounds.frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 0.65F); + + EquipLogic logic = (EquipLogic) world.getBlockTileEntity(x, y, z); + logic.setEquipmentItem(stack); + --stack.stackSize; + + return true; + } + } + } + + @Override + public Item getHeadItem () + { + return TContent.frypanHead; + } + + @Override + public Item getAccessoryItem () + { + return null; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 8; + } + + @Override + public int getPartAmount () + { + return 2; + } + + @Override + public void registerPartPaths (int index, String[] location) + { + headStrings.put(index, location[0]); + brokenPartStrings.put(index, location[1]); + handleStrings.put(index, location[2]); + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_frypan_head"; + case 1: + return "_frypan_head_broken"; + case 2: + return "_frypan_handle"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_frypan_effect"; + } + + @Override + public String getDefaultFolder () + { + return "frypan"; + } +} diff --git a/tconstruct/items/tools/Hammer.java b/tconstruct/items/tools/Hammer.java new file mode 100644 index 00000000..75145590 --- /dev/null +++ b/tconstruct/items/tools/Hammer.java @@ -0,0 +1,379 @@ +package tconstruct.items.tools; + +import java.util.ArrayList; + +import tconstruct.common.TContent; +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.HarvestTool; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Icon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Hammer extends HarvestTool +{ + public Hammer(int itemID) + { + super(itemID, 2); + this.setUnlocalizedName("InfiTool.Hammer"); + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 10; + } + + @Override + public int getPartAmount () + { + return 4; + } + + public int durabilityTypeAccessory () + { + return 2; + } + + public int durabilityTypeExtra () + { + return 2; + } + + @Override + protected String getHarvestType () + { + return "pickaxe"; + } + + @Override + protected Material[] getEffectiveMaterials () + { + return materials; + } + + static Material[] materials = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil }; + + @Override + public Item getHeadItem () + { + return TContent.hammerHead; + } + + @Override + public Item getHandleItem () + { + return TContent.toughRod; + } + + @Override + public Item getAccessoryItem () + { + return TContent.heavyPlate; + } + + @Override + public Item getExtraItem () + { + return TContent.heavyPlate; + } + + public float getDurabilityModifier () + { + return 4.5f; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_hammer_head"; + case 1: + return "_hammer_handle_broken"; + case 2: + return "_hammer_handle"; + case 3: + return "_hammer_front"; + case 4: + return "_hammer_back"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_hammer_effect"; + } + + @Override + public String getDefaultFolder () + { + return "hammer"; + } + + @Override + public Icon getIcon (ItemStack stack, int renderPass) + { + NBTTagCompound tags = stack.getTagCompound(); + + if (tags != null) + { + tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (renderPass < getPartAmount()) + { + if (renderPass == 0) // Handle + { + if (tags.getBoolean("Broken")) + return (brokenIcons.get(tags.getInteger("RenderHandle"))); + return handleIcons.get(tags.getInteger("RenderHandle")); + } + + else if (renderPass == 1) // Head + { + return (headIcons.get(tags.getInteger("RenderHead"))); + } + + else if (renderPass == 2) // Accessory + { + return (accessoryIcons.get(tags.getInteger("RenderAccessory"))); + } + + else if (renderPass == 3) // Extra + { + return (extraIcons.get(tags.getInteger("RenderExtra"))); + } + } + + else + { + if (renderPass == getPartAmount()) + { + if (tags.hasKey("Effect1")) + return (effectIcons.get(tags.getInteger("Effect1"))); + } + + else if (renderPass == getPartAmount() + 1) + { + if (tags.hasKey("Effect2")) + return (effectIcons.get(tags.getInteger("Effect2"))); + } + + else if (renderPass == getPartAmount() + 2) + { + if (tags.hasKey("Effect3")) + return (effectIcons.get(tags.getInteger("Effect3"))); + } + + else if (renderPass == getPartAmount() + 3) + { + if (tags.hasKey("Effect4")) + return (effectIcons.get(tags.getInteger("Effect4"))); + } + + else if (renderPass == getPartAmount() + 4) + { + if (tags.hasKey("Effect5")) + return (effectIcons.get(tags.getInteger("Effect5"))); + } + + else if (renderPass == getPartAmount() + 5) + { + if (tags.hasKey("Effect6")) + return (effectIcons.get(tags.getInteger("Effect6"))); + } + } + return blankSprite; + } + return emptyIcon; + } + + ArrayList coords = new ArrayList(); + + @Override + public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) + { + World world = player.worldObj; + final int blockID = world.getBlockId(x, y, z); + final int meta = world.getBlockMetadata(x, y, z); + Block block = Block.blocksList[blockID]; + if (!stack.hasTagCompound()) + return false; + + if (block == null) + return super.onBlockStartBreak(stack, x, y, z, player); + + float blockHardness = block.getBlockHardness(world, x, y, z); + + boolean validStart = false; + for (int iter = 0; iter < materials.length; iter++) + { + if (materials[iter] == block.blockMaterial) + { + validStart = true; + break; + } + } + + MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, true, 5.0D); + if (mop == null || !validStart) + return super.onBlockStartBreak(stack, x, y, z, player); + + int xRange = 1; + int yRange = 1; + int zRange = 1; + switch (mop.sideHit) + { + case 0: + case 1: + yRange = 0; + break; + case 2: + case 3: + zRange = 0; + break; + case 4: + case 5: + xRange = 0; + break; + } + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + for (int xPos = x - xRange; xPos <= x + xRange; xPos++) + { + for (int yPos = y - yRange; yPos <= y + yRange; yPos++) + { + for (int zPos = z - zRange; zPos <= z + zRange; zPos++) + { + if (!(tags.getBoolean("Broken"))) + { + int localblockID = world.getBlockId(xPos, yPos, zPos); + block = Block.blocksList[localblockID]; + int localMeta = world.getBlockMetadata(xPos, yPos, zPos); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + float localHardness = block == null ? Float.MAX_VALUE : block.getBlockHardness(world, xPos, yPos, zPos); + + if (hlvl <= tags.getInteger("HarvestLevel") && localHardness - 1.5 <= blockHardness) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player)) + cancelHarvest = true; + } + + if (!cancelHarvest) + { + if (block != null && !(localHardness < 0)) + { + for (int iter = 0; iter < materials.length; iter++) + { + if (materials[iter] == block.blockMaterial) + { + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, xPos, yPos, zPos, localMeta); + block.onBlockHarvested(world, x, y, z, localMeta, player); + if (blockHardness > 0f) + onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); + } + world.setBlockToAir(xPos, yPos, zPos); + } + } + } + } + } + } + } + } + } + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, blockID + (meta << 12)); + return true; + } + + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + if (!stack.hasTagCompound()) + return 1.0f; + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return 0.1f; + + Material[] materials = getEffectiveMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } + + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } + + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + float trueSpeed = mineSpeed / (heads * 300f); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); + + float stonebound = tags.getFloat("Shoddy"); + float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; + trueSpeed += bonusLog; + + if (hlvl <= tags.getInteger("HarvestLevel")) + return trueSpeed; + return 0.1f; + } + } + return super.getStrVsBlock(stack, block, meta); + } + + /*@Override + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) entity; + ItemStack equipped = player.getCurrentEquippedItem(); + if (equipped == stack) + { + player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1)); + } + } + }*/ + + @Override + public String[] toolCategories () + { + return new String[] { "weapon", "harvest", "melee", "bludgeoning" }; + } +} diff --git a/tconstruct/items/tools/Hatchet.java b/tconstruct/items/tools/Hatchet.java new file mode 100644 index 00000000..2baad903 --- /dev/null +++ b/tconstruct/items/tools/Hatchet.java @@ -0,0 +1,107 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.HarvestTool; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Hatchet extends HarvestTool +{ + public Hatchet(int itemID) + { + super(itemID, 3); + this.setUnlocalizedName("InfiTool.Axe"); + } + + @Override + protected Material[] getEffectiveMaterials () + { + return materials; + } + + @Override + protected String getHarvestType () + { + return "axe"; + } + + @Override + public boolean onBlockDestroyed (ItemStack itemstack, World world, int bID, int x, int y, int z, EntityLivingBase player) + { + Block block = Block.blocksList[bID]; + if (block != null && block.blockMaterial == Material.leaves) + return false; + + return AbilityHelper.onBlockChanged(itemstack, world, bID, x, y, z, player, random); + } + + static Material[] materials = { Material.wood, Material.leaves, Material.vine, Material.circuits, Material.cactus, Material.pumpkin }; + + @Override + public Item getHeadItem () + { + return TContent.hatchetHead; + } + + @Override + public Item getAccessoryItem () + { + return null; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 8; + } + + @Override + public int getPartAmount () + { + return 2; + } + + @Override + public void registerPartPaths (int index, String[] location) + { + headStrings.put(index, location[0]); + brokenPartStrings.put(index, location[1]); + handleStrings.put(index, location[2]); + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_axe_head"; + case 1: + return "_axe_head_broken"; + case 2: + return "_axe_handle"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_axe_effect"; + } + + @Override + public String getDefaultFolder () + { + return "axe"; + } +} diff --git a/tconstruct/items/tools/Longsword.java b/tconstruct/items/tools/Longsword.java new file mode 100644 index 00000000..cb01e5bb --- /dev/null +++ b/tconstruct/items/tools/Longsword.java @@ -0,0 +1,143 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.tools.Weapon; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Longsword extends Weapon +{ + public Longsword(int itemID) + { + super(itemID, 4); + this.setUnlocalizedName("InfiTool.Longsword"); + } + + public EnumAction getItemUseAction (ItemStack par1ItemStack) + { + return EnumAction.bow; + } + + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + { + if (player.onGround) + { + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + } + return stack; + } + + public float chargeAttack () + { + return 1.5f; + } + + public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int useCount) + { + /*if (player.onGround) + { + int time = this.getMaxItemUseDuration(stack) - useCount; + if (time > 5) + { + player.addExhaustion(0.2F); + player.setSprinting(true); + + float speed = 0.05F * time; + if (speed > 0.925f) + speed = 0.925f; + + float increase = (float) (0.02 * time + 0.2); + if (increase > 0.56f) + increase = 0.56f; + player.motionY += increase + speed/3; + + player.motionX = (double) (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed); + player.motionZ = (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed); + } + }*/ + int time = this.getMaxItemUseDuration(stack) - useCount; + if (time > 5) + { + player.addExhaustion(0.2F); + player.setSprinting(true); + + float increase = (float) (0.02 * time + 0.2); + if (increase > 0.56f) + increase = 0.56f; + player.motionY += increase; + + float speed = 0.05F * time; + if (speed > 0.925f) + speed = 0.925f; + player.motionX = (double) (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed); + player.motionZ = (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayerSP) + { + EntityPlayerSP player = (EntityPlayerSP) entity; + ItemStack usingItem = player.getItemInUse(); + if (usingItem != null && usingItem.getItem() == this) + { + player.movementInput.moveForward *= 5.0F; + player.movementInput.moveStrafe *= 5.0F; + } + } + } + + @Override + public Item getHeadItem () + { + return TContent.swordBlade; + } + + @Override + public Item getAccessoryItem () + { + return TContent.handGuard; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_longsword_blade"; + case 1: + return "_longsword_blade_broken"; + case 2: + return "_longsword_handle"; + case 3: + return "_longsword_accessory"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_longsword_effect"; + } + + @Override + public String getDefaultFolder () + { + return "longsword"; + } +} diff --git a/tconstruct/items/tools/LumberAxe.java b/tconstruct/items/tools/LumberAxe.java new file mode 100644 index 00000000..4da71c6d --- /dev/null +++ b/tconstruct/items/tools/LumberAxe.java @@ -0,0 +1,381 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.HarvestTool; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class LumberAxe extends HarvestTool +{ + public LumberAxe(int itemID) + { + super(itemID, 0); + this.setUnlocalizedName("InfiTool.LumberAxe"); + } + + @Override + protected Material[] getEffectiveMaterials () + { + return materials; + } + + @Override + protected String getHarvestType () + { + return "axe"; + } + + @Override + public float getRepairCost () + { + return 4.0f; + } + + public float getDurabilityModifier () + { + return 2.5f; + } + + public String getToolName () + { + return "Lumber Axe"; + } + + @Override + public boolean onBlockDestroyed (ItemStack itemstack, World world, int bID, int x, int y, int z, EntityLivingBase player) + { + Block block = Block.blocksList[bID]; + if (block != null && block.blockMaterial == Material.leaves) + return false; + + return AbilityHelper.onBlockChanged(itemstack, world, bID, x, y, z, player, random); + } + + static Material[] materials = { Material.wood, Material.vine, Material.circuits, Material.cactus, Material.pumpkin }; + + /* Lumber axe specific */ + + /*@Override + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) entity; + ItemStack equipped = player.getCurrentEquippedItem(); + if (equipped == stack) + { + player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1)); + } + } + }*/ + + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + if (!stack.hasTagCompound()) + return 1.0f; + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return 0.1f; + + Material[] materials = getEffectiveMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } + + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } + + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + float trueSpeed = mineSpeed / (heads * 300f); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); + + float stonebound = tags.getFloat("Shoddy"); + float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; + trueSpeed += bonusLog; + + if (hlvl <= tags.getInteger("HarvestLevel")) + return trueSpeed; + return 0.1f; + } + } + return super.getStrVsBlock(stack, block, meta); + } + + @Override + public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) + { + World world = player.worldObj; + final int woodID = world.getBlockId(x, y, z); + final Block wood = Block.blocksList[woodID]; + if (wood.isWood(world, x, y, z)) + { + int height = y; + boolean foundTop = false; + do + { + height++; + int blockID = world.getBlockId(x, height, z); + if (blockID != woodID) + { + height--; + foundTop = true; + } + } while (!foundTop); + + int numLeaves = 0; + if (height - y < 30) + { + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + for (int yPos = height - 1; yPos <= height + 1; yPos++) + { + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + Block leaves = Block.blocksList[world.getBlockId(xPos, yPos, zPos)]; + if (leaves != null && leaves.isLeaves(world, xPos, yPos, zPos)) + numLeaves++; + } + } + } + } + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + int meta = world.getBlockMetadata(x, y, z); + if (numLeaves > 3) + breakTree(world, x, y, z, stack, tags, woodID, meta, player); + else + destroyWood(world, x, y, z, stack, tags, player); + + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, woodID + (meta << 12)); + } + return super.onBlockStartBreak(stack, x, y, z, player); + } + + void breakTree (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, int bID, int meta, EntityPlayer player) + { + Block block; + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + for (int yPos = y; yPos <= y + 1; yPos++) + { + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + if (!(tags.getBoolean("Broken"))) + { + int localblockID = world.getBlockId(xPos, yPos, zPos); + if (bID == localblockID) + { + block = Block.blocksList[localblockID]; + meta = world.getBlockMetadata(xPos, yPos, zPos); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + + if (hlvl <= tags.getInteger("HarvestLevel")) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player)) + cancelHarvest = true; + } + + if (cancelHarvest) + { + breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player); + } + else + { + if (localblockID == bID && world.getBlockMetadata(xPos, yPos, zPos) % 4 == meta % 4) + { + /* world.setBlock(xPos, yPos, zPos, 0, 0, 3); + if (!player.capabilities.isCreativeMode) + { + Block.blocksList[bID].harvestBlock(world, player, xPos, yPos, zPos, meta); + onBlockDestroyed(stack, world, bID, xPos, yPos, zPos, player); + }*/ + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, xPos, yPos, zPos, meta); + block.onBlockHarvested(world, x, y, z, meta, player); + onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); + } + world.setBlockToAir(xPos, yPos, zPos); + breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player); + } + /*else + { + Block leaves = Block.blocksList[localID]; + if (leaves != null && leaves.isLeaves(world, xPos, yPos, zPos)) + { + world.setBlockToAir(xPos, yPos, zPos); + if (!player.capabilities.isCreativeMode) + { + Block.blocksList[bID].harvestBlock(world, player, xPos, yPos, zPos, meta); + onBlockDestroyed(stack, world, bID, xPos, yPos, zPos, player); + } + } + }*/ + } + } + } + } + } + } + } + } + + void destroyWood (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, EntityPlayer player) + { + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + for (int yPos = y - 1; yPos <= y + 1; yPos++) + { + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + if (!(tags.getBoolean("Broken"))) + { + int localblockID = world.getBlockId(xPos, yPos, zPos); + Block block = Block.blocksList[localblockID]; + int meta = world.getBlockMetadata(xPos, yPos, zPos); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + + if (hlvl <= tags.getInteger("HarvestLevel")) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player)) + cancelHarvest = true; + } + + if (!cancelHarvest) + { + if (block != null && block.blockMaterial == Material.wood) + { + world.setBlockToAir(xPos, yPos, zPos); + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, xPos, yPos, zPos, meta); + onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); + } + } + } + } + } + } + } + } + } + + @Override + public Item getHeadItem () + { + return TContent.broadAxeHead; + } + + @Override + public Item getHandleItem () + { + return TContent.toughRod; + } + + @Override + public Item getAccessoryItem () + { + return TContent.heavyPlate; + } + + @Override + public Item getExtraItem () + { + return TContent.toughBinding; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 10; + } + + @Override + public int getPartAmount () + { + return 4; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_lumberaxe_head"; + case 1: + return "_lumberaxe_head_broken"; + case 2: + return "_lumberaxe_handle"; + case 3: + return "_lumberaxe_shield"; + case 4: + return "_lumberaxe_binding"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_lumberaxe_effect"; + } + + @Override + public String getDefaultFolder () + { + return "lumberaxe"; + } + + @Override + public int durabilityTypeAccessory () + { + return 2; + } + + @Override + public int durabilityTypeExtra () + { + return 1; + } +} diff --git a/tconstruct/items/tools/Mattock.java b/tconstruct/items/tools/Mattock.java new file mode 100644 index 00000000..e996852b --- /dev/null +++ b/tconstruct/items/tools/Mattock.java @@ -0,0 +1,106 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.DualHarvestTool; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class Mattock extends DualHarvestTool +{ + public Mattock(int itemID) + { + super(itemID, 3); + this.setUnlocalizedName("InfiTool.Mattock"); + } + + @Override + protected Material[] getEffectiveMaterials () + { + return axeMaterials; + } + + @Override + protected Material[] getEffectiveSecondaryMaterials () + { + return shovelMaterials; + } + + @Override + protected String getHarvestType () + { + return "axe"; + } + + @Override + protected String getSecondHarvestType () + { + return "shovel"; + } + + static Material[] axeMaterials = { Material.wood, Material.cactus, Material.pumpkin, Material.plants, Material.vine }; + static Material[] shovelMaterials = { Material.grass, Material.ground, Material.clay }; + + @Override + public Item getHeadItem () + { + return TContent.hatchetHead; + } + + @Override + public Item getAccessoryItem () + { + return TContent.shovelHead; + } + + public int durabilityTypeAccessory () + { + return 2; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_mattock_head"; + case 1: + return "_mattock_head_broken"; + case 2: + return "_mattock_handle"; + case 3: + return "_mattock_back"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_mattock_effect"; + } + + @Override + public String getDefaultFolder () + { + return "mattock"; + } + + /* Mattock specific */ + + @Override + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ) + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return false; + + return AbilityHelper.hoeGround(stack, player, world, x, y, z, side, random); + } +} \ No newline at end of file diff --git a/tconstruct/items/tools/Pickaxe.java b/tconstruct/items/tools/Pickaxe.java new file mode 100644 index 00000000..ce995f87 --- /dev/null +++ b/tconstruct/items/tools/Pickaxe.java @@ -0,0 +1,71 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.tools.HarvestTool; +import net.minecraft.block.material.Material; +import net.minecraft.item.Item; + +public class Pickaxe extends HarvestTool +{ + public Pickaxe(int itemID) + { + super(itemID, 1); + this.setUnlocalizedName("InfiTool.Pickaxe"); + } + + @Override + protected String getHarvestType () + { + return "pickaxe"; + } + + @Override + protected Material[] getEffectiveMaterials () + { + return materials; + } + + static Material[] materials = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil, Material.circuits }; + + @Override + public Item getHeadItem () + { + return TContent.pickaxeHead; + } + + @Override + public Item getAccessoryItem () + { + return TContent.binding; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_pickaxe_head"; + case 1: + return "_pickaxe_head_broken"; + case 2: + return "_pickaxe_handle"; + case 3: + return "_pickaxe_accessory"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_pickaxe_effect"; + } + + @Override + public String getDefaultFolder () + { + return "pickaxe"; + } +} diff --git a/tconstruct/items/tools/PotionLauncher.java b/tconstruct/items/tools/PotionLauncher.java new file mode 100644 index 00000000..b91fd2fe --- /dev/null +++ b/tconstruct/items/tools/PotionLauncher.java @@ -0,0 +1,184 @@ +package tconstruct.items.tools; + +import java.util.List; + +import tconstruct.entity.projectile.LaunchedPotion; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class PotionLauncher extends Item +{ + @SideOnly(Side.CLIENT) + private Icon[] icons; + public static final String[] textureNames = new String[] { "potionlauncher" }; + + public PotionLauncher(int par1) + { + super(par1); + this.maxStackSize = 1; + this.setCreativeTab(CreativeTabs.tabCombat); + this.setMaxDamage(3); + } + + public ItemStack onEaten (ItemStack stack, World world, EntityPlayer player) + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + boolean loaded = tags.getBoolean("Loaded"); + if (!loaded) + { + int slotID = getInventorySlotContainItem(Item.potion.itemID, player.inventory); + ItemStack potion = player.inventory.getStackInSlot(slotID); + + NBTTagCompound potionTag = new NBTTagCompound(); + potion.writeToNBT(potionTag); + tags.setCompoundTag("LoadedPotion", potionTag); + tags.setBoolean("Loaded", true); + + if (!player.capabilities.isCreativeMode) + { + potion.stackSize--; + if (potion.stackSize < 1) + player.inventory.setInventorySlotContents(slotID, null); + } + + world.playSoundEffect(player.posX, player.posY, player.posZ, "sounds.launcher_clank", 1.0F, (world.rand.nextFloat() - world.rand.nextFloat()) * 0.15F + 1.0F); + } + return stack; + } + + public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int time) + { + + } + + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + int slotID = getInventorySlotContainItem(Item.potion.itemID, player.inventory); + if (!tags.getBoolean("Loaded") && slotID >= 0) + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + return stack; + } + + /** + * How long it takes to use or consume an item + */ + public int getMaxItemUseDuration (ItemStack stack) + { + return 30; + } + + /** + * returns the action that specifies what animation to play when the items is being used + */ + public EnumAction getItemUseAction (ItemStack stack) + { + if (!stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Loaded")) + return EnumAction.bow; + else + return EnumAction.none; + } + + @SideOnly(Side.CLIENT) + public void registerIcons (IconRegister par1IconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = par1IconRegister.registerIcon("tinker:" + textureNames[i]); + } + } + + @SideOnly(Side.CLIENT) + public Icon getIconFromDamage (int meta) + { + return icons[0]; + } + + @Override + public void getSubItems (int id, CreativeTabs tabs, List list) + { + ItemStack stack = new ItemStack(id, 1, 0); + NBTTagCompound compound = new NBTTagCompound(); + NBTTagCompound tags = new NBTTagCompound(); + compound.setCompoundTag("InfiTool", tags); + + tags.setBoolean("Loaded", false); + + stack.setTagCompound(compound); + + list.add(stack); + } + + @Override + public boolean onEntitySwing (EntityLivingBase player, ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Loaded")) + { + NBTTagCompound potionTag = tags.getCompoundTag("LoadedPotion"); + ItemStack potion = ItemStack.loadItemStackFromNBT(potionTag);//findPotion(player);InventoryLogic + if (potion != null) + { + World world = player.worldObj; + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if (!world.isRemote) + { + world.spawnEntityInWorld(new LaunchedPotion(world, player, potion)); + } + tags.removeTag("LoadedPotion"); + tags.setBoolean("Loaded", false); + } + return true; + } + return false; + } + + ItemStack findPotion (EntityLivingBase living) + { + if (living instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) living; + int potionSlot = getInventorySlotContainItem(Item.potion.itemID, player.inventory); + if (potionSlot >= 0) + { + return player.inventory.getStackInSlot(potionSlot); + } + } + return null; + } + + int getInventorySlotContainItem (int itemID, InventoryPlayer inventory) + { + for (int j = 0; j < inventory.mainInventory.length; ++j) + { + if (inventory.mainInventory[j] != null && inventory.mainInventory[j].itemID == itemID) + { + return j; + } + } + + return -1; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + list.add("Test Item"); + } +} diff --git a/tconstruct/items/tools/Rapier.java b/tconstruct/items/tools/Rapier.java new file mode 100644 index 00000000..d33597a6 --- /dev/null +++ b/tconstruct/items/tools/Rapier.java @@ -0,0 +1,119 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.tools.Weapon; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class Rapier extends Weapon +{ + public Rapier(int itemID) + { + super(itemID, 2); + this.setUnlocalizedName("InfiTool.Rapier"); + } + + public EnumAction getItemUseAction (ItemStack par1ItemStack) + { + return EnumAction.none; + } + + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + { + if (player.onGround) + { + player.addExhaustion(0.1f); + player.motionY += 0.32; + float f = 0.5F; + player.motionX = (double) (MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * f); + player.motionZ = (double) (-MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * f); + } + return stack; + } + + @Override + public boolean hitEntity (ItemStack stack, EntityLivingBase mob, EntityLivingBase player) + { + //AbilityHelper.hitEntity(stack, mob, player, damageVsEntity); + //AbilityHelper.knockbackEntity(mob, 0.8f); + mob.motionY *= 0.8; + if (mob.hurtResistantTime > 18) + mob.hurtResistantTime -= 5; + return true; + } + + @Override + public float getDurabilityModifier () + { + return 0.7f; + } + + @Override + public float getDamageModifier () + { + return 0.8f; + } + + /*public float chargeAttack () + { + return 1.0f; + }*/ + + public boolean pierceArmor () + { + return true; + } + + @Override + public Item getHeadItem () + { + return TContent.swordBlade; + } + + @Override + public Item getAccessoryItem () + { + return TContent.crossbar; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_rapier_blade"; + case 1: + return "_rapier_blade_broken"; + case 2: + return "_rapier_handle"; + case 3: + return "_rapier_accessory"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_rapier_effect"; + } + + @Override + public String getDefaultFolder () + { + return "rapier"; + } + + protected Material[] getEffectiveMaterials () + { + return none; + } +} diff --git a/tconstruct/items/tools/Scythe.java b/tconstruct/items/tools/Scythe.java new file mode 100644 index 00000000..ca847bb6 --- /dev/null +++ b/tconstruct/items/tools/Scythe.java @@ -0,0 +1,217 @@ +package tconstruct.items.tools; + +import java.util.List; + +import tconstruct.common.TContent; +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.Weapon; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Scythe extends Weapon +{ + public Scythe(int itemID) + { + super(itemID, 4); + this.setUnlocalizedName("InfiTool.Scythe"); + } + + /*@Override + protected String getHarvestType() + { + return "sword"; + }*/ + + @Override + protected Material[] getEffectiveMaterials () + { + return materials; + } + + static Material[] materials = new Material[] { Material.web, Material.cactus, Material.pumpkin, Material.plants, Material.vine, Material.leaves }; + + @Override + public Item getHeadItem () + { + return TContent.scytheBlade; + } + + @Override + public Item getHandleItem () + { + return TContent.toughRod; + } + + @Override + public Item getAccessoryItem () + { + return TContent.toughBinding; + } + + @Override + public Item getExtraItem () + { + return TContent.toughRod; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 10; + } + + @Override + public int getPartAmount () + { + return 4; + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_scythe_head"; + case 1: + return "_scythe_head_broken"; + case 2: + return "_scythe_handle"; + case 3: + return "_scythe_binding"; + case 4: + return "_scythe_accessory"; + default: + return ""; + } + } + + public float getDurabilityModifier () + { + return 3.0f; + } + + @Override + public float getRepairCost () + { + return 4.0f; + } + + @Override + public String getEffectSuffix () + { + return "_scythe_effect"; + } + + @Override + public String getDefaultFolder () + { + return "scythe"; + } + + @Override + public int durabilityTypeAccessory () + { + return 1; + } + + @Override + public int durabilityTypeExtra () + { + return 1; + } + + @Override + public float getDamageModifier () + { + return 0.75f; + } + + @Override + public String[] toolCategories () + { + return new String[] { "weapon", "melee", "harvest" }; + } + + /* Scythe Specific */ + + @Override + public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) + { + World world = player.worldObj; + final int blockID = world.getBlockId(x, y, z); + final int meta = world.getBlockMetadata(x, y, z); + if (!stack.hasTagCompound()) + return false; + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + for (int xPos = x - 1; xPos <= x + 1; xPos++) + { + for (int yPos = y - 1; yPos <= y + 1; yPos++) + { + for (int zPos = z - 1; zPos <= z + 1; zPos++) + { + if (!(tags.getBoolean("Broken"))) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player)) + cancelHarvest = true; + } + + if (!cancelHarvest) + { + int localblockID = world.getBlockId(xPos, yPos, zPos); + Block block = Block.blocksList[localblockID]; + if (block != null)// && (block.blockMaterial == Material.leaves || block.isLeaves(world, xPos, yPos, zPos))) + { + for (int iter = 0; iter < materials.length; iter++) + { + if (materials[iter] == block.blockMaterial) + { + int localMeta = world.getBlockMetadata(xPos, yPos, zPos); + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, xPos, yPos, zPos, localMeta); + block.onBlockHarvested(world, x, y, z, localMeta, player); + onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); + } + world.setBlockToAir(xPos, yPos, zPos); + } + } + } + } + } + } + } + } + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, blockID + (meta << 12)); + return super.onBlockStartBreak(stack, x, y, z, player); + } + + public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity) + { + AxisAlignedBB box = AxisAlignedBB.getAABBPool().getAABB(entity.posX, entity.posY, entity.posZ, entity.posX + 1.0D, entity.posY + 1.0D, entity.posZ + 1.0D).expand(1.0D, 1.0D, 1.0D); + List list = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, box); + for (Object o : list) + { + AbilityHelper.onLeftClickEntity(stack, player, (Entity) o, this); + } + return true; + } + +} diff --git a/tconstruct/items/tools/Shortbow.java b/tconstruct/items/tools/Shortbow.java new file mode 100644 index 00000000..a1f77568 --- /dev/null +++ b/tconstruct/items/tools/Shortbow.java @@ -0,0 +1,195 @@ +package tconstruct.items.tools; + +import java.util.List; + +import tconstruct.common.TContent; +import tconstruct.library.tools.BowBase; + +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Shortbow extends BowBase +{ + public Shortbow(int itemID) + { + super(itemID); + this.setUnlocalizedName("InfiTool.Shortbow"); + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_bow_top"; + case 1: + return "_bowstring_broken"; + case 2: + return "_bowstring"; + case 3: + return "_bow_bottom"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_bow_effect"; + } + + @Override + public String getDefaultFolder () + { + return "shortbow"; + } + + @Override + public Item getHeadItem () + { + return TContent.toolRod; + } + + @Override + public Item getHandleItem () + { + return TContent.bowstring; + } + + @Override + public Item getAccessoryItem () + { + return TContent.toolRod; + } + + @Override + public String[] toolCategories () + { + return new String[] { "weapon", "ranged", "bow" }; + } + + @Override + @SideOnly(Side.CLIENT) + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayerSP) + { + EntityPlayerSP player = (EntityPlayerSP) entity; + ItemStack usingItem = player.getItemInUse(); + if (usingItem != null && usingItem.getItem() == this) + { + player.movementInput.moveForward *= 2.0F; + player.movementInput.moveStrafe *= 2.0F; + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + if (!stack.hasTagCompound()) + return; + + NBTTagCompound tags = stack.getTagCompound(); + if (tags.hasKey("charge")) + { + String color = ""; + //double joules = this.getJoules(stack); + int power = tags.getInteger("charge"); + + if (power != 0) + { + if (power <= this.getMaxCharge(stack) / 3) + color = "\u00a74"; + else if (power > this.getMaxCharge(stack) * 2 / 3) + color = "\u00a72"; + else + color = "\u00a76"; + } + + String charge = new StringBuilder().append(color).append(tags.getInteger("charge")).append("/").append(getMaxCharge(stack)).append(" EU").toString(); + list.add(charge); + } + if (tags.hasKey("InfiTool")) + { + boolean broken = tags.getCompoundTag("InfiTool").getBoolean("Broken"); + if (broken) + list.add("\u00A7oBroken"); + else + { + int head = tags.getCompoundTag("InfiTool").getInteger("Head"); + int handle = tags.getCompoundTag("InfiTool").getInteger("Handle"); + int binding = tags.getCompoundTag("InfiTool").getInteger("Accessory"); + int extra = tags.getCompoundTag("InfiTool").getInteger("Extra"); + + String headName = getAbilityNameForType(head); + if (!headName.equals("")) + list.add(getStyleForType(head) + headName); + + String handleName = getBowstringName(handle); + if (!handleName.equals("") && handle != head) + list.add(handleName); + + if (getPartAmount() >= 3) + { + String bindingName = getAbilityNameForType(binding); + if (!bindingName.equals("") && binding != head && binding != handle) + list.add(getStyleForType(binding) + bindingName); + } + + if (getPartAmount() >= 4) + { + String extraName = getAbilityNameForType(extra); + if (!extraName.equals("") && extra != head && extra != handle && extra != binding) + list.add(getStyleForType(extra) + extraName); + } + + int unbreaking = tags.getCompoundTag("InfiTool").getInteger("Unbreaking"); + String reinforced = getReinforcedName(head, handle, binding, extra, unbreaking); + if (!reinforced.equals("")) + list.add(reinforced); + + boolean displayToolTips = true; + int tipNum = 0; + while (displayToolTips) + { + tipNum++; + String tooltip = "Tooltip" + tipNum; + if (tags.getCompoundTag("InfiTool").hasKey(tooltip)) + { + String tipName = tags.getCompoundTag("InfiTool").getString(tooltip); + if (!tipName.equals("")) + list.add(tipName); + } + else + displayToolTips = false; + } + } + } + } + + public String getBowstringName (int type) + { + switch (type) + { + case 0: + return ""; + case 1: + return "\u00A7bEnchanted"; + default: + return ""; + } + //return TConstructRegistry.getMaterial(type).ability(); + } +} diff --git a/tconstruct/items/tools/Shovel.java b/tconstruct/items/tools/Shovel.java new file mode 100644 index 00000000..bc9d8a22 --- /dev/null +++ b/tconstruct/items/tools/Shovel.java @@ -0,0 +1,131 @@ +package tconstruct.items.tools; + +import tconstruct.common.TContent; +import tconstruct.library.tools.HarvestTool; +import net.minecraft.block.material.Material; +import net.minecraft.item.Item; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Shovel extends HarvestTool +{ + public Shovel(int itemID) + { + super(itemID, 2); + this.setUnlocalizedName("InfiTool.Shovel"); + } + + @Override + protected Material[] getEffectiveMaterials () + { + return materials; + } + + @Override + protected String getHarvestType () + { + return "shovel"; + } + + static Material[] materials = { Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay }; + + @Override + public Item getHeadItem () + { + return TContent.shovelHead; + } + + @Override + public Item getAccessoryItem () + { + return null; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 8; + } + + @Override + public int getPartAmount () + { + return 2; + } + + @Override + public void registerPartPaths (int index, String[] location) + { + headStrings.put(index, location[0]); + brokenPartStrings.put(index, location[1]); + handleStrings.put(index, location[2]); + } + + @Override + public String getIconSuffix (int partType) + { + switch (partType) + { + case 0: + return "_shovel_head"; + case 1: + return "_shovel_head_broken"; + case 2: + return "_shovel_handle"; + default: + return ""; + } + } + + @Override + public String getEffectSuffix () + { + return "_shovel_effect"; + } + + @Override + public String getDefaultFolder () + { + return "shovel"; + } + + /*@Override + public Icon getIcon (ItemStack stack, int renderPass) + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + + if (renderPass == 0) // Handle + { + return (handleIcons.get(tags.getInteger("RenderHandle"))); + } + + if (renderPass == 1) // Head + { + if (tags.getBoolean("Broken")) + return (brokenHeadIcons.get(tags.getInteger("RenderHead"))); + else + return (headIcons.get(tags.getInteger("RenderHead"))); + } + + if (renderPass == 2) + { + if (tags.hasKey("Effect1")) + return (effectIcons.get(tags.getInteger("Effect1"))); + } + + if (renderPass == 3) + { + if (tags.hasKey("Effect2")) + return (effectIcons.get(tags.getInteger("Effect2"))); + } + + if (renderPass == 4) + { + if (tags.hasKey("Effect3")) + return (effectIcons.get(tags.getInteger("Effect3"))); + } + + return TProxyClient.blankSprite; + }*/ +} diff --git a/tconstruct/library/ActiveToolMod.java b/tconstruct/library/ActiveToolMod.java new file mode 100644 index 00000000..a56bd530 --- /dev/null +++ b/tconstruct/library/ActiveToolMod.java @@ -0,0 +1,62 @@ +package tconstruct.library; + +import tconstruct.library.tools.ToolCore; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class ActiveToolMod +{ + /* Updating */ + public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity) + { + + } + + /* Harvesting */ + public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityLivingBase entity) + { + return false; + } + + public boolean afterBlockBreak () //Unfinished, not called + { + return false; + } + + /* Attacking */ + + public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) + { + return 0; + } + + //Calculated after sprinting and enchant bonuses + public float knockback (float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) + { + return 0f; + } + + public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) + { + return 0; + } + + public void lateAttackEntity () //Unfinished, not called + { + + } + + /* Damage tool */ + public boolean damageTool (ItemStack stack, int damage, EntityLivingBase entity) + { + return false; + } + + public boolean doesCriticalHit (ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) + { + return false; + } +} diff --git a/tconstruct/library/TConstructRegistry.java b/tconstruct/library/TConstructRegistry.java new file mode 100644 index 00000000..71884226 --- /dev/null +++ b/tconstruct/library/TConstructRegistry.java @@ -0,0 +1,706 @@ +package tconstruct.library; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import tconstruct.library.crafting.Detailing; +import tconstruct.library.crafting.LiquidCasting; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.tools.ArrowMaterial; +import tconstruct.library.tools.BowMaterial; +import tconstruct.library.tools.BowstringMaterial; +import tconstruct.library.tools.CustomMaterial; +import tconstruct.library.tools.FletchingMaterial; +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMaterial; +import tconstruct.library.util.TabTools; + + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** A registry to store any relevant API work + * + * @author mDiyo + */ + +public class TConstructRegistry +{ + public static TConstructRegistry instance = new TConstructRegistry(); + + /* Creative tabs */ + public static TabTools toolTab; + public static TabTools materialTab; + public static TabTools blockTab; + + /* Items */ + + /** A directory of crafting items and tools used by the mod. + * + * Tools: + * pickaxe, shovel, hatchet, broadsword, longsword, rapier, dagger, cutlass + * frypan, battlesign, mattock, chisel + * lumberaxe, cleaver, scythe, excavator, hammer, battleaxe + * + * Patterns: + * blankPattern, woodPattern, metalPattern + * + * Tool crafting parts: + * toolRod, toolShard, binding, toughBinding, toughRod, heavyPlate + * pickaxeHead, shovelhead, hatchetHead, swordBlade, wideguard, handGuard, crossbar, knifeBlade, + * fullGuard, frypanHead, signHead, chiselHead + * scytheBlade, broadAxeHead, excavatorHead, largeSwordBlade, hammerHead + * bowstring, fletching, arrowhead + */ + public static HashMap itemDirectory = new HashMap(); + + /** Adds an item to the directory + * + * @param name Associates the name with the stack + * @param itemstack The stack to add to the directory + */ + + public static void addItemToDirectory (String name, Item itemstack) + { + Item add = itemDirectory.get(name); + if (add != null) + System.out.println("[TCon API] " + name + " is already present in the Item directory"); + + itemDirectory.put(name, itemstack); + } + + /** Retrieves an itemstack from the directory + * + * @param name The name of the item to get + * @return Item associated with the name, or null if not present. + */ + + public static Item getItem (String name) + { + Item ret = itemDirectory.get(name); + if (ret == null) + System.out.println("[TCon API] Could not find " + name + " in the Item directory"); + + return ret; + } + + /** A directory of ItemStacks. Contains mostly crafting items + * + * Materials: + * paperStack, greenSlimeCrystal, blueSlimeCrystal, searedBrick, mossBall, lavaCrystal, necroticBone, silkyCloth, silkyJewel + * ingotCobalt, ingotArdite, ingotManyullyn, ingotCopper, ingotTin, ingotAluminum, rawAluminum, + * ingotBronze, ingotAluminumBrass, ingotAlumite, ingotSteel, ingotObsidian + * nuggetIron, nuggetCopper, nuggetTin, nuggetAluminum, nuggetSilver, nuggetAluminumBrass + * oreberryIron, oreberryGold, oreberryCopper, oreberryTin, oreberryTin, oreberrySilver, + * diamondApple, blueSlimeFood, canisterEmpty, miniRedHeart, canisterRedHeart + * + * Patterns - These have a suffix of Pattern or Cast. ex: hatchetHeadPattern + * ingot, toolRod, pickaxeHead, shovelHead, hatchetHead, swordBlade, wideGuard, handGuard, crossbar, binding, frypanHead, signHead, + * knifeBlade, chiselHead, toughRod, toughBinding, largePlate, broadAxeHead, scytheHead, excavatorHead, largeBlade, hammerHead, fullGuard, bowstring + */ + static HashMap itemstackDirectory = new HashMap(); + + /** Adds an itemstack to the directory + * + * @param name Associates the name with the stack + * @param itemstack The stack to add to the directory + */ + + public static void addItemStackToDirectory (String name, ItemStack itemstack) + { + ItemStack add = itemstackDirectory.get(name); + if (add != null) + System.out.println("[TCon API] " + name + " is already present in the ItemStack directory"); + + itemstackDirectory.put(name, itemstack); + } + + /** Retrieves an itemstack from the directory + * + * @param name The name of the item to get + * @return Item associated with the name, or null if not present. + */ + + public static ItemStack getItemStack (String name) + { + ItemStack ret = itemstackDirectory.get(name); + if (ret == null) + System.out.println("[TCon API] Could not find " + name + " in the ItemStack directory"); + + return ret; + } + + public static ArrayList tools = new ArrayList(20); + + //Parts + + /** List: Item ID, metadata, material ID + * ItemStack: Output. Ex: Cactus Binding + */ + public static HashMap patternPartMapping = new HashMap(); + + /** Maps an item and a material ID to an output part + * + * @param patternID ID to check against + * @param patternMeta Metadata to check against + * @param materialID Material that goes with the item + * @param output The resulting part + */ + public static void addPartMapping (int patternID, int patternMeta, int materialID, ItemStack output) + { + patternPartMapping.put(Arrays.asList(patternID, patternMeta, materialID), output); + } + + public static ItemStack getPartMapping (int itemID, int metadata, int materialID) + { + ItemStack stack = patternPartMapping.get(Arrays.asList(itemID, metadata, materialID)); + if (stack != null) + return stack.copy(); + return null; + } + + //Tools + + /** Internal tool mapping, used for adding textures + * + * @param tool + */ + + public static void addToolMapping (ToolCore tool) + { + tools.add(tool); + } + + /** Internal tool mapping, used for adding textures + * + * @return List of tools + */ + + public static ArrayList getToolMapping () + { + return tools; + } + + /** Registers a tool to its crafting parts. + * If an output is registered multiple times the parts are added to the recipe's input list + * Valid part amounts are 1, 2, and 4. Part counts of 1 and 2 assume a Tool Rod as a handle. + * Null items are valid as placeholders. ex: Hatchet + * + * @see ToolBuidler + * @param output The ToolCore to craft + * @param parts Pieces to make the tool with + */ + public static void addToolRecipe (ToolCore output, Item... parts) + { + ToolBuilder tb = ToolBuilder.instance; + if (parts.length < 1 || parts.length > 4 || parts.length == 3) + System.out.println("[TCon API] Wrong amount of items to craft into a tool"); + + tb.addToolRecipe(output, parts); + } + + //Materials + public static HashMap toolMaterials = new HashMap(40); + public static HashMap toolMaterialStrings = new HashMap(40); + + /** Adds a tool material to the registry + * + * @param materialID Unique ID, stored for each part + * @exception materialID must be unique + * @param materialName Unique name for data lookup purposes + * @param harvestLevel The materials which the tool can harvest. Pickaxe levels - 0: Wood, 1: Stone, 2: Redstone/Diamond, 3: Obsidian, 4: Cobalt/Ardite, 5: Manyullyn + * @param durability Base durability of the tool, affects tool heads. + * @param miningspeed Base mining speed, divided by 100 in use + * @param attack Base attack + * @param handleModifier Durability multiplier on the tool + * @param reinforced Reinforced level + * @param stonebound Amount of Stonebound to put on the tool. Negative numbers are Spiny. + */ + + public static void addToolMaterial (int materialID, String materialName, int harvestLevel, int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, + String style, String ability) + { + ToolMaterial mat = toolMaterials.get(materialID); + if (mat == null) + { + mat = new ToolMaterial(materialName, harvestLevel, durability, miningspeed, attack, handleModifier, reinforced, stonebound, style, ability); + toolMaterials.put(materialID, mat); + toolMaterialStrings.put(materialName, mat); + } + else + throw new IllegalArgumentException("[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName); + } + + /** Adds a tool material to the registry + * + * @param materialID Unique ID, stored for each part + * @exception materialID must be unique + * @param materialName Unique name for data lookup purposes + * @param displayName Prefix for creative mode tools + * @param harvestLevel The materials which the tool can harvest. Pickaxe levels - 0: Wood, 1: Stone, 2: Redstone/Diamond, 3: Obsidian, 4: Cobalt/Ardite, 5: Manyullyn + * @param durability Base durability of the tool, affects tool heads. + * @param miningspeed Base mining speed, divided by 100 in use + * @param attack Base attack + * @param handleModifier Durability multiplier on the tool + * @param reinforced Reinforced level + * @param stonebound Amount of Stonebound to put on the tool. Negative numbers are Spiny. + */ + + public static void addToolMaterial (int materialID, String materialName, String displayName, int harvestLevel, int durability, int miningspeed, int attack, float handleModifier, int reinforced, + float stonebound, String style, String ability) + { + ToolMaterial mat = toolMaterials.get(materialID); + if (mat == null) + { + mat = new ToolMaterial(materialName, displayName, harvestLevel, durability, miningspeed, attack, handleModifier, reinforced, stonebound, style, ability); + toolMaterials.put(materialID, mat); + toolMaterialStrings.put(materialName, mat); + } + else + throw new IllegalArgumentException("[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName); + } + + /** Adds a tool material to the registry + * + * @param materialID Unique ID, stored for each part + * @exception materialID must be unique + * @param material Complete tool material to add. Uses the name in the material for lookup purposes. + */ + + public static void addtoolMaterial (int materialID, ToolMaterial material) + { + ToolMaterial mat = toolMaterials.get(materialID); + if (mat == null) + { + toolMaterials.put(materialID, mat); + toolMaterialStrings.put(material.name(), mat); + } + else + throw new IllegalArgumentException("[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName); + } + + /** Looks up a tool material by ID + * + * @param key The ID to look up + * @return Tool Material + */ + + public static ToolMaterial getMaterial (int key) + { + return (toolMaterials.get(key)); + } + + /** Looks up a tool material by name + * + * @param key the name to look up + * @return Tool Material + */ + + public static ToolMaterial getMaterial (String key) + { + return (toolMaterialStrings.get(key)); + } + + //Bow materials + public static HashMap bowMaterials = new HashMap(40); + + public static void addBowMaterial (int materialID, int durability, int drawSpeed, float speedMax) + { + BowMaterial mat = bowMaterials.get(materialID); + if (mat == null) + { + mat = new BowMaterial(durability, drawSpeed, speedMax); + bowMaterials.put(materialID, mat); + } + else + throw new IllegalArgumentException("[TCon API] Bow Material ID " + materialID + " is already occupied"); + } + + public static boolean validBowMaterial (int materialID) + { + return bowMaterials.containsKey(materialID); + } + + public static BowMaterial getBowMaterial (int materialID) + { + return bowMaterials.get(materialID); + } + + public static HashMap arrowMaterials = new HashMap(40); + + public static void addArrowMaterial (int materialID, float mass, float breakChance, float accuracy) + { + ArrowMaterial mat = arrowMaterials.get(materialID); + if (mat == null) + { + mat = new ArrowMaterial(mass, breakChance, accuracy); + arrowMaterials.put(materialID, mat); + } + else + throw new IllegalArgumentException("[TCon API] Arrow Material ID " + materialID + " is already occupied"); + } + + public static boolean validArrowMaterial (int materialID) + { + return arrowMaterials.containsKey(materialID); + } + + public static ArrowMaterial getArrowMaterial (int materialID) + { + return arrowMaterials.get(materialID); + } + + //Custom materials - bowstrings, fletching, etc + public static ArrayList customMaterials = new ArrayList(); + + public static void addCustomMaterial (CustomMaterial mat) + { + if (mat != null) + customMaterials.add(mat); + } + + public static void addBowstringMaterial (int materialID, int value, ItemStack input, ItemStack craftingMaterial, float durability, float drawSpeed, float flightSpeed) + { + BowstringMaterial mat = new BowstringMaterial(materialID, value, input, craftingMaterial, durability, drawSpeed, flightSpeed); + customMaterials.add(mat); + } + + public static void addFletchingMaterial (int materialID, int value, ItemStack input, ItemStack craftingMaterial, float accuracy, float breakChance, float mass) + { + FletchingMaterial mat = new FletchingMaterial(materialID, value, input, craftingMaterial, accuracy, breakChance, mass); + customMaterials.add(mat); + } + + public static CustomMaterial getCustomMaterial (int materialID, Class clazz) + { + for (CustomMaterial mat : customMaterials) + { + if (mat.getClass().equals(clazz) && mat.materialID == materialID) + return mat; + } + return null; + } + + public static CustomMaterial getCustomMaterial (ItemStack input, Class clazz) + { + for (CustomMaterial mat : customMaterials) + { + if (mat.getClass().equals(clazz) && input.isItemEqual(mat.input)) + return mat; + } + return null; + } + + /*public static CustomMaterial getCustomMaterial(ItemStack input, ItemStack pattern) + { + for (CustomMaterial mat : customMaterials) + { + if (mat.matches(input, pattern)) + return mat; + } + return null; + }*/ + + /*public static ItemStack craftBowString(ItemStack stack) + { + if (stack.stackSize < 3) + return null; + + for (BowstringMaterial mat : bowstringMaterials) + { + if (stack.isItemEqual(mat.input)) + return mat.craftingItem.copy(); + } + return null; + } + + public static BowstringMaterial getBowstringMaterial(ItemStack stack) + { + if (stack.stackSize < 3) + return null; + + for (BowstringMaterial mat : bowstringMaterials) + { + if (stack.isItemEqual(mat.input)) + return mat; + } + return null; + }*/ + + public static LiquidCasting getTableCasting () + { + return instance.tableCasting(); + } + + LiquidCasting tableCasting () + { + try + { + Class clazz = Class.forName("tconstruct.TConstruct"); + Method method = clazz.getMethod("getTableCasting"); + LiquidCasting lc = (LiquidCasting) method.invoke(this); + return lc; + } + catch (Exception e) + { + System.out.println("[TCon API] Could not find casting table recipes."); + return null; + } + } + + public static LiquidCasting getBasinCasting () + { + return instance.basinCasting(); + } + + LiquidCasting basinCasting () + { + try + { + Class clazz = Class.forName("tconstruct.TConstruct"); + Method method = clazz.getMethod("getBasinCasting"); + LiquidCasting lc = (LiquidCasting) method.invoke(this); + return lc; + } + catch (Exception e) + { + System.out.println("[TCon API] Could not find casting basin recipes."); + return null; + } + } + + public static Detailing getChiselDetailing () + { + return instance.chiselDetailing(); + } + + Detailing chiselDetailing () + { + try + { + Class clazz = Class.forName("tconstruct.TConstruct"); + Method method = clazz.getMethod("getChiselDetailing"); + Detailing lc = (Detailing) method.invoke(this); + return lc; + } + catch (Exception e) + { + System.out.println("[TCon API] Could not find chisel detailing recipes."); + return null; + } + } + + public static ArrayList activeModifiers = new ArrayList(); + + public static void registerActiveToolMod (ActiveToolMod mod) + { + activeModifiers.add(mod); + } + + /* Used to determine how blocks are laid out in the drawbridge + * 0: Metadata has to match + * 1: Metadata has no meaning + * 2: Should not be placed + * 3: Has rotational metadata + * 4: Rails + * 5: Has rotational TileEntity data + * 6: Custom placement logic + */ + public static int[] drawbridgeState = new int[Block.blocksList.length]; + /** Blocks that are interchangable with each other. Ex: Still and flowing water */ + public static int[] interchangableBlockMapping = new int[Block.blocksList.length]; + /** Blocks that place items, and vice versa */ + public static int[] blockToItemMapping = new int[Item.itemsList.length]; + + static void initializeDrawbridgeState () + { + drawbridgeState[Block.stone.blockID] = 1; + drawbridgeState[Block.grass.blockID] = 1; + drawbridgeState[Block.dirt.blockID] = 1; + drawbridgeState[Block.cobblestone.blockID] = 1; + drawbridgeState[Block.bedrock.blockID] = 2; + drawbridgeState[Block.waterMoving.blockID] = 1; + drawbridgeState[Block.waterStill.blockID] = 1; + interchangableBlockMapping[Block.waterStill.blockID] = Block.waterMoving.blockID; + interchangableBlockMapping[Block.waterMoving.blockID] = Block.waterStill.blockID; + drawbridgeState[Block.lavaMoving.blockID] = 1; + drawbridgeState[Block.lavaStill.blockID] = 1; + interchangableBlockMapping[Block.lavaStill.blockID] = Block.lavaMoving.blockID; + interchangableBlockMapping[Block.lavaMoving.blockID] = Block.lavaStill.blockID; + drawbridgeState[Block.sand.blockID] = 1; + drawbridgeState[Block.gravel.blockID] = 1; + drawbridgeState[Block.oreGold.blockID] = 1; + drawbridgeState[Block.oreIron.blockID] = 1; + drawbridgeState[Block.oreCoal.blockID] = 1; + drawbridgeState[Block.sponge.blockID] = 1; + drawbridgeState[Block.oreLapis.blockID] = 1; + drawbridgeState[Block.blockLapis.blockID] = 1; + drawbridgeState[Block.dispenser.blockID] = 3; + drawbridgeState[Block.music.blockID] = 1; + drawbridgeState[Block.bed.blockID] = 2; + drawbridgeState[Block.railPowered.blockID] = 4; + drawbridgeState[Block.railDetector.blockID] = 4; + drawbridgeState[Block.pistonStickyBase.blockID] = 3; + drawbridgeState[Block.web.blockID] = 1; + drawbridgeState[Block.pistonBase.blockID] = 3; + drawbridgeState[Block.pistonExtension.blockID] = 2; + drawbridgeState[Block.plantYellow.blockID] = 1; + drawbridgeState[Block.plantRed.blockID] = 1; + drawbridgeState[Block.mushroomBrown.blockID] = 1; + drawbridgeState[Block.mushroomRed.blockID] = 1; + drawbridgeState[Block.blockGold.blockID] = 1; + drawbridgeState[Block.blockIron.blockID] = 1; + drawbridgeState[Block.brick.blockID] = 1; + drawbridgeState[Block.tnt.blockID] = 1; + drawbridgeState[Block.bookShelf.blockID] = 1; + drawbridgeState[Block.cobblestoneMossy.blockID] = 1; + drawbridgeState[Block.obsidian.blockID] = 1; + drawbridgeState[Block.torchWood.blockID] = 1; + drawbridgeState[Block.fire.blockID] = 1; + drawbridgeState[Block.mobSpawner.blockID] = 2; + drawbridgeState[Block.stairsWoodOak.blockID] = 3; + drawbridgeState[Block.chest.blockID] = 5; + drawbridgeState[Block.redstoneWire.blockID] = 1; + blockToItemMapping[Block.redstoneWire.blockID] = Item.redstone.itemID; + blockToItemMapping[Item.redstone.itemID] = Block.redstoneWire.blockID; + drawbridgeState[Block.oreDiamond.blockID] = 1; + drawbridgeState[Block.blockDiamond.blockID] = 1; + drawbridgeState[Block.workbench.blockID] = 1; + drawbridgeState[Block.crops.blockID] = 2; + drawbridgeState[Block.tilledField.blockID] = 1; + drawbridgeState[Block.furnaceIdle.blockID] = 3; + drawbridgeState[Block.furnaceBurning.blockID] = 3; + interchangableBlockMapping[Block.furnaceIdle.blockID] = Block.furnaceBurning.blockID; + interchangableBlockMapping[Block.furnaceBurning.blockID] = Block.furnaceIdle.blockID; + drawbridgeState[Block.tilledField.blockID] = 1; + drawbridgeState[Block.signPost.blockID] = 3; + drawbridgeState[Block.doorWood.blockID] = 2; + drawbridgeState[Block.ladder.blockID] = 1; + drawbridgeState[Block.rail.blockID] = 4; + drawbridgeState[Block.stairsCobblestone.blockID] = 3; + drawbridgeState[Block.signWall.blockID] = 3; + drawbridgeState[Block.lever.blockID] = 3; + drawbridgeState[Block.pressurePlateStone.blockID] = 1; + drawbridgeState[Block.doorIron.blockID] = 2; + drawbridgeState[Block.pressurePlatePlanks.blockID] = 1; + drawbridgeState[Block.oreRedstone.blockID] = 1; + drawbridgeState[Block.oreRedstoneGlowing.blockID] = 1; + drawbridgeState[Block.torchRedstoneIdle.blockID] = 1; + drawbridgeState[Block.torchRedstoneActive.blockID] = 1; + drawbridgeState[Block.stoneButton.blockID] = 3; + drawbridgeState[Block.snow.blockID] = 1; + drawbridgeState[Block.ice.blockID] = 1; + drawbridgeState[Block.blockSnow.blockID] = 1; + drawbridgeState[Block.cactus.blockID] = 2; + drawbridgeState[Block.blockClay.blockID] = 1; + drawbridgeState[Block.reed.blockID] = 1; + drawbridgeState[Block.jukebox.blockID] = 1; + drawbridgeState[Block.fence.blockID] = 1; + drawbridgeState[Block.pumpkin.blockID] = 1; + drawbridgeState[Block.netherrack.blockID] = 1; + drawbridgeState[Block.slowSand.blockID] = 1; + drawbridgeState[Block.glowStone.blockID] = 1; + drawbridgeState[Block.portal.blockID] = 2; + drawbridgeState[Block.pumpkinLantern.blockID] = 1; + drawbridgeState[Block.cake.blockID] = 2; + drawbridgeState[Block.redstoneRepeaterIdle.blockID] = 3; + drawbridgeState[Block.redstoneRepeaterActive.blockID] = 3; + interchangableBlockMapping[Block.redstoneRepeaterIdle.blockID] = Block.redstoneRepeaterActive.blockID; + interchangableBlockMapping[Block.redstoneRepeaterActive.blockID] = Block.redstoneRepeaterIdle.blockID; + blockToItemMapping[Block.redstoneRepeaterIdle.blockID] = Item.redstoneRepeater.itemID; + blockToItemMapping[Block.redstoneRepeaterActive.blockID] = Item.redstoneRepeater.itemID; + blockToItemMapping[Item.redstoneRepeater.itemID] = Block.redstoneRepeaterIdle.blockID; + drawbridgeState[Block.lockedChest.blockID] = 5; + drawbridgeState[Block.trapdoor.blockID] = 3; + drawbridgeState[Block.mushroomCapBrown.blockID] = 1; + drawbridgeState[Block.mushroomCapRed.blockID] = 1; + drawbridgeState[Block.fenceIron.blockID] = 1; + drawbridgeState[Block.thinGlass.blockID] = 1; + drawbridgeState[Block.melon.blockID] = 1; + drawbridgeState[Block.pumpkinStem.blockID] = 2; + drawbridgeState[Block.melonStem.blockID] = 2; + drawbridgeState[Block.vine.blockID] = 3; + drawbridgeState[Block.fenceGate.blockID] = 3; + drawbridgeState[Block.stairsBrick.blockID] = 3; + drawbridgeState[Block.stairsStoneBrick.blockID] = 3; + drawbridgeState[Block.mycelium.blockID] = 1; + drawbridgeState[Block.waterlily.blockID] = 1; + drawbridgeState[Block.netherBrick.blockID] = 1; + drawbridgeState[Block.netherFence.blockID] = 1; + drawbridgeState[Block.netherFence.blockID] = 3; + drawbridgeState[Block.netherStalk.blockID] = 2; + drawbridgeState[Block.enchantmentTable.blockID] = 1; + drawbridgeState[Block.brewingStand.blockID] = 1; + drawbridgeState[Block.cauldron.blockID] = 1; + drawbridgeState[Block.endPortal.blockID] = 2; + drawbridgeState[Block.dragonEgg.blockID] = 1; + drawbridgeState[Block.redstoneLampIdle.blockID] = 1; + drawbridgeState[Block.redstoneLampActive.blockID] = 1; + drawbridgeState[Block.cocoaPlant.blockID] = 2; + drawbridgeState[Block.stairsSandStone.blockID] = 3; + drawbridgeState[Block.oreEmerald.blockID] = 1; + drawbridgeState[Block.enderChest.blockID] = 5; + drawbridgeState[Block.tripWireSource.blockID] = 1; + drawbridgeState[Block.tripWire.blockID] = 1; + drawbridgeState[Block.blockEmerald.blockID] = 1; + drawbridgeState[Block.stairsWoodSpruce.blockID] = 3; + drawbridgeState[Block.stairsWoodBirch.blockID] = 3; + drawbridgeState[Block.stairsWoodJungle.blockID] = 3; + drawbridgeState[Block.commandBlock.blockID] = 1; + drawbridgeState[Block.beacon.blockID] = 1; + drawbridgeState[Block.cobblestoneWall.blockID] = 1; + drawbridgeState[Block.flowerPot.blockID] = 1; + drawbridgeState[Block.carrot.blockID] = 2; + drawbridgeState[Block.potato.blockID] = 1; + drawbridgeState[Block.woodenButton.blockID] = 3; + drawbridgeState[Block.skull.blockID] = 2; + drawbridgeState[Block.chestTrapped.blockID] = 5; + drawbridgeState[Block.pressurePlateGold.blockID] = 1; + drawbridgeState[Block.pressurePlateIron.blockID] = 1; + drawbridgeState[Block.redstoneComparatorIdle.blockID] = 1; + drawbridgeState[Block.redstoneComparatorActive.blockID] = 1; + interchangableBlockMapping[Block.redstoneComparatorIdle.blockID] = Block.redstoneComparatorActive.blockID; + interchangableBlockMapping[Block.redstoneComparatorActive.blockID] = Block.redstoneComparatorIdle.blockID; + blockToItemMapping[Block.redstoneComparatorIdle.blockID] = Item.comparator.itemID; + blockToItemMapping[Block.redstoneComparatorActive.blockID] = Item.comparator.itemID; + blockToItemMapping[Item.comparator.itemID] = Block.redstoneComparatorIdle.blockID; + drawbridgeState[Block.daylightSensor.blockID] = 1; + drawbridgeState[Block.blockRedstone.blockID] = 1; + drawbridgeState[Block.oreNetherQuartz.blockID] = 1; + drawbridgeState[Block.hopperBlock.blockID] = 3; + drawbridgeState[Block.blockNetherQuartz.blockID] = 1; + drawbridgeState[Block.stairsNetherQuartz.blockID] = 3; + drawbridgeState[Block.railActivator.blockID] = 4; + drawbridgeState[Block.dropper.blockID] = 3; + } + + static + { + initializeDrawbridgeState(); + } + + /** Default Material Index + * 0: Wood + * 1: Stone + * 2: Iron + * 3: Flint + * 4: Cactus + * 5: Bone + * 6: Obsidian + * 7: Netherrack + * 8: Green Slime + * 9: Paper + * 10: Cobalt + * 11: Ardite + * 12: Manyullyn + * 13: Copper + * 14: Bronze + * 15: Alumite + * 16: Steel + * 17: Blue Slime + */ +} diff --git a/tconstruct/library/blocks/InventoryBlock.java b/tconstruct/library/blocks/InventoryBlock.java new file mode 100644 index 00000000..9e651044 --- /dev/null +++ b/tconstruct/library/blocks/InventoryBlock.java @@ -0,0 +1,175 @@ +package tconstruct.library.blocks; + +import java.util.Random; + +import tconstruct.library.util.IActiveLogic; +import tconstruct.library.util.IFacingLogic; + + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class InventoryBlock extends BlockContainer +{ + protected Random rand = new Random(); + + protected InventoryBlock(int id, Material material) + { + super(id, material); + } + + /* Logic backend */ + public TileEntity createNewTileEntity (World var1) + { + return null; + } + + public abstract TileEntity createTileEntity (World world, int metadata); + + public abstract Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer); + + public abstract Object getModInstance (); + + @Override + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ) + { + if (player.isSneaking()) + return false; + + Integer integer = getGui(world, x, y, z, player); + if (integer == null || integer == -1) + { + return false; + } + else + { + if (!world.isRemote) + player.openGui(getModInstance(), integer, world, x, y, z); + return true; + } + } + + /* Inventory */ + + @Override + public void breakBlock (World par1World, int x, int y, int z, int par5, int meta) + { + TileEntity te = par1World.getBlockTileEntity(x, y, z); + + if (te != null && te instanceof InventoryLogic) + { + InventoryLogic logic = (InventoryLogic) te; + for (int iter = 0; iter < logic.getSizeInventory(); ++iter) + { + ItemStack stack = logic.getStackInSlot(iter); + + if (stack != null && logic.canDropInventorySlot(iter)) + { + float jumpX = rand.nextFloat() * 0.8F + 0.1F; + float jumpY = rand.nextFloat() * 0.8F + 0.1F; + float jumpZ = rand.nextFloat() * 0.8F + 0.1F; + + while (stack.stackSize > 0) + { + int itemSize = rand.nextInt(21) + 10; + + if (itemSize > stack.stackSize) + { + itemSize = stack.stackSize; + } + + stack.stackSize -= itemSize; + EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ), new ItemStack(stack.itemID, + itemSize, stack.getItemDamage())); + + if (stack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); + } + + float offset = 0.05F; + entityitem.motionX = (double) ((float) rand.nextGaussian() * offset); + entityitem.motionY = (double) ((float) rand.nextGaussian() * offset + 0.2F); + entityitem.motionZ = (double) ((float) rand.nextGaussian() * offset); + par1World.spawnEntityInWorld(entityitem); + } + } + } + } + + super.breakBlock(par1World, x, y, z, par5, meta); + } + + /* Placement */ + + public int onBlockPlaced (World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + if (logic instanceof IFacingLogic) + { + IFacingLogic direction = (IFacingLogic) logic; + direction.setDirection(side); + } + return meta; + } + + @Override + public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + if (logic instanceof IFacingLogic) + { + IFacingLogic direction = (IFacingLogic) logic; + if (entityliving == null) + { + direction.setDirection(0F, 0F, null); + } + else + { + direction.setDirection(entityliving.rotationYaw * 4F, entityliving.rotationPitch, entityliving); + } + } + } + + public static boolean isActive (IBlockAccess world, int x, int y, int z) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + if (logic instanceof IActiveLogic) + { + return ((IActiveLogic) logic).getActive(); + } + return false; + } + + public int damageDropped (int meta) + { + return meta; + } + + /* Textures */ + public Icon[] icons; + + public abstract String[] getTextureNames (); + + @Override + public void registerIcons (IconRegister iconRegister) + { + String[] textureNames = getTextureNames(); + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]); + } + } +} diff --git a/tconstruct/library/blocks/InventoryLogic.java b/tconstruct/library/blocks/InventoryLogic.java new file mode 100644 index 00000000..4ea51da8 --- /dev/null +++ b/tconstruct/library/blocks/InventoryLogic.java @@ -0,0 +1,182 @@ +package tconstruct.library.blocks; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +/* + * A simple logic class for storing items + * Abstract to avoid instantiation + */ + +public abstract class InventoryLogic extends TileEntity implements IInventory +{ + protected ItemStack[] inventory; + protected String invName; + + public InventoryLogic(int invSize) + { + inventory = new ItemStack[invSize]; + } + + /* Inventory management */ + + @Override + public ItemStack getStackInSlot (int slot) + { + return inventory[slot]; + } + + public boolean isStackInSlot (int slot) + { + return inventory[slot] != null; + } + + @Override + public int getSizeInventory () + { + return inventory.length; + } + + @Override + public int getInventoryStackLimit () + { + return 64; + } + + public boolean canDropInventorySlot (int slot) + { + return true; + } + + @Override + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + inventory[slot] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); + } + } + + @Override + public ItemStack decrStackSize (int slot, int quantity) + { + if (inventory[slot] != null) + { + if (inventory[slot].stackSize <= quantity) + { + ItemStack stack = inventory[slot]; + inventory[slot] = null; + return stack; + } + ItemStack split = inventory[slot].splitStack(quantity); + if (inventory[slot].stackSize == 0) + { + inventory[slot] = null; + } + return split; + } + else + { + return null; + } + } + + /* Supporting methods */ + @Override + public boolean isUseableByPlayer (EntityPlayer entityplayer) + { + if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) + return false; + + else + return entityplayer.getDistance((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; + + } + + public abstract Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z); + + /* NBT */ + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + this.invName = tags.getString("InvName"); + NBTTagList nbttaglist = tags.getTagList("Items"); + inventory = new ItemStack[getSizeInventory()]; + for (int iter = 0; iter < nbttaglist.tagCount(); iter++) + { + NBTTagCompound tagList = (NBTTagCompound) nbttaglist.tagAt(iter); + byte slotID = tagList.getByte("Slot"); + if (slotID >= 0 && slotID < inventory.length) + { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList); + } + } + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + if (invName != null) + tags.setString("InvName", invName); + NBTTagList nbttaglist = new NBTTagList(); + for (int iter = 0; iter < inventory.length; iter++) + { + if (inventory[iter] != null) + { + NBTTagCompound tagList = new NBTTagCompound(); + tagList.setByte("Slot", (byte) iter); + inventory[iter].writeToNBT(tagList); + nbttaglist.appendTag(tagList); + } + } + + tags.setTag("Items", nbttaglist); + } + + /* Default implementations of hardly used methods */ + public ItemStack getStackInSlotOnClosing (int slot) + { + return null; + } + + public void openChest () + { + } + + public void closeChest () + { + } + + protected abstract String getDefaultName (); + + public String getInvName () + { + return this.isInvNameLocalized() ? this.invName : getDefaultName(); + } + + public boolean isInvNameLocalized () + { + return this.invName != null && this.invName.length() > 0; + } + + @Override + public boolean isItemValidForSlot (int slot, ItemStack itemstack) + { + if (slot < getSizeInventory()) + { + if (inventory[slot] == null || itemstack.stackSize + inventory[slot].stackSize <= getInventoryStackLimit()) + return true; + } + return false; + } +} diff --git a/tconstruct/library/client/TConstructClientRegistry.java b/tconstruct/library/client/TConstructClientRegistry.java new file mode 100644 index 00000000..f400ded5 --- /dev/null +++ b/tconstruct/library/client/TConstructClientRegistry.java @@ -0,0 +1,174 @@ +package tconstruct.library.client; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.tools.ToolCore; + + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class TConstructClientRegistry +{ + public static ArrayList toolButtons = new ArrayList(20); + public static ArrayList tierTwoButtons = new ArrayList(); + public static Map manualIcons = new HashMap(); + public static Map recipeIcons = new HashMap(); + public static ItemStack defaultStack = new ItemStack(Item.ingotIron); + + public static void addMaterialRenderMapping (int materialID, String domain, String renderName, boolean useDefaultFolder) + { + for (ToolCore tool : TConstructRegistry.getToolMapping()) + { + String[] toolIcons = new String[tool.getPartAmount() + 1]; + for (int i = 0; i < tool.getPartAmount() + 1; i++) + { + String icon = domain + ":"; + if (useDefaultFolder) + icon += tool.getDefaultFolder() + "/"; + icon += renderName + tool.getIconSuffix(i); + toolIcons[i] = icon; + } + tool.registerPartPaths(materialID, toolIcons); + } + } + + public static void addAlternateMaterialRenderMapping (ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder) + { + String[] toolIcons = new String[tool.getPartAmount() + 1]; + for (int i = 0; i < tool.getPartAmount() + 1; i++) + { + String icon = domain + ":"; + if (useDefaultFolder) + icon += tool.getDefaultFolder() + "/"; + icon += renderName + tool.getIconSuffix(i); + toolIcons[i] = icon; + } + tool.registerAlternatePartPaths(materialID, toolIcons); + } + + public static void addEffectRenderMapping (ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder) + { + String icon = domain + ":"; + if (useDefaultFolder) + icon += tool.getDefaultFolder() + "/"; + icon += renderName + tool.getEffectSuffix(); + tool.registerEffectPath(materialID, icon); + } + + public static void addEffectRenderMapping (int materialID, String domain, String renderName, boolean useDefaultFolder) + { + for (ToolCore tool : TConstructRegistry.getToolMapping()) + { + String icon = domain + ":"; + if (useDefaultFolder) + icon += tool.getDefaultFolder() + "/"; + icon += renderName + tool.getEffectSuffix(); + tool.registerEffectPath(materialID, icon); + } + } + + public static void addSingleEffectRenderMapping (ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder) + { + String icon = domain + ":"; + if (useDefaultFolder) + icon += tool.getDefaultFolder() + "/"; + icon += renderName + tool.getEffectSuffix(); + tool.registerEffectPath(materialID, icon); + } + + public static void registerManualIcon (String name, ItemStack stack) + { + manualIcons.put(name, stack); + } + + public static ItemStack getManualIcon (String textContent) + { + ItemStack stack = manualIcons.get(textContent); + if (stack != null) + return stack; + return defaultStack; + } + + public static void registerManualSmallRecipe (String name, ItemStack output, ItemStack... stacks) + { + ItemStack[] recipe = new ItemStack[5]; + recipe[0] = output; + System.arraycopy(stacks, 0, recipe, 1, 4); + recipeIcons.put(name, recipe); + } + + public static void registerManualLargeRecipe (String name, ItemStack output, ItemStack... stacks) + { + ItemStack[] recipe = new ItemStack[10]; + recipe[0] = output; + System.arraycopy(stacks, 0, recipe, 1, 9); + recipeIcons.put(name, recipe); + } + + public static void registerManualFurnaceRecipe (String name, ItemStack output, ItemStack input) + { + ItemStack[] recipe = new ItemStack[2]; + recipe[0] = output; + recipe[1] = input; + recipeIcons.put(name, recipe); + } + + public static void registerManualModifier (String name, ItemStack output, ItemStack topinput) + { + registerManualModifier(name, output, topinput, null); + } + + public static void registerManualModifier (String name, ItemStack output, ItemStack topinput, ItemStack bottominput) + { + ItemStack[] recipe = new ItemStack[3]; + recipe[0] = ToolBuilder.instance.buildTool(output, topinput, bottominput, ""); + recipe[1] = topinput; + recipe[2] = bottominput; + recipeIcons.put(name, recipe); + } + + public static void registerManualSmeltery (String name, ItemStack output, ItemStack liquid, ItemStack cast) + { + ItemStack[] recipe = new ItemStack[3]; + recipe[0] = output; + recipe[1] = liquid; + recipe[2] = cast; + recipeIcons.put(name, recipe); + } + + public static ItemStack[] getRecipeIcons (String recipeName) + { + return recipeIcons.get(recipeName); + } + + //Gui + public static void addToolButton (ToolGuiElement element) + { + toolButtons.add(element); + } + + public static void addToolButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body, String domain, String texture) + { + toolButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture)); + } + + public static void addTierTwoButton (ToolGuiElement element) + { + tierTwoButtons.add(element); + } + + public static void addTierTwoButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body, String domain, String texture) + { + tierTwoButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture)); + } + + public static ArrayList getToolButtons () + { + return toolButtons; + } +} diff --git a/tconstruct/library/client/ToolGuiElement.java b/tconstruct/library/client/ToolGuiElement.java new file mode 100644 index 00000000..640ef286 --- /dev/null +++ b/tconstruct/library/client/ToolGuiElement.java @@ -0,0 +1,27 @@ +package tconstruct.library.client; + +public class ToolGuiElement +{ + public final int slotType; + public final int buttonIconX; + public final int buttonIconY; + public final int[] iconsX; + public final int[] iconsY; + public final String title; + public final String body; + public final String domain; + public final String texture; + + public ToolGuiElement(int st, int bx, int by, int[] xi, int[] yi, String t, String b, String d, String tex) + { + slotType = st; + buttonIconX = bx; + buttonIconY = by; + iconsX = xi; + iconsY = yi; + title = t; + body = b; + domain = d; + texture = tex; + } +} diff --git a/tconstruct/library/crafting/AlloyMix.java b/tconstruct/library/crafting/AlloyMix.java new file mode 100644 index 00000000..b30d6d3b --- /dev/null +++ b/tconstruct/library/crafting/AlloyMix.java @@ -0,0 +1,97 @@ +package tconstruct.library.crafting; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraftforge.fluids.FluidStack; + +public class AlloyMix +{ + public final FluidStack result; + public final List mixers; + + public AlloyMix(FluidStack output, List inputs) + { + result = output; + mixers = inputs; + } + + /*public boolean matches(List liquids) + { + ArrayList list = new ArrayList(mixers); + return false; + }*/ + + public FluidStack mix (ArrayList liquids) + { + ArrayList copyMix = new ArrayList(mixers); + ArrayList effectiveAmount = new ArrayList(); + + for (int i = 0; i < liquids.size(); i++) + { + FluidStack liquid = liquids.get(i); + Iterator iter = copyMix.iterator(); + while (iter.hasNext()) + { + FluidStack mixer = (FluidStack) iter.next(); + //if (mixer.itemID == liquid.itemID && mixer.itemMeta == liquid.itemMeta) + if (mixer.isFluidEqual(liquid)) + { + int eAmt = liquid.amount / mixer.amount; + effectiveAmount.add(eAmt); + copyMix.remove(mixer); + //inputs.add(liquid); + break; + } + } + } + //} + + if (copyMix.size() > 0) + return null; + + //Remove old liquids + int low = getLowestAmount(effectiveAmount); + ArrayList copyMix2 = new ArrayList(mixers); + + for (int i = 0; i < liquids.size(); i++) + { + FluidStack liquid = liquids.get(i); + Iterator iter = copyMix2.iterator(); + while (iter.hasNext()) + { + FluidStack mixer = (FluidStack) iter.next(); + //if (mixer.itemID == liquid.itemID && mixer.itemMeta == liquid.itemMeta) + if (mixer.isFluidEqual(liquid)) + { + int eAmt = low * mixer.amount; + liquid.amount -= eAmt; + if (liquid.amount <= 0) + { + liquids.remove(liquid); + i--; + } + copyMix2.remove(mixer); + break; + } + } + } + + FluidStack ret = result.copy(); + ret.amount *= low; + return ret; + } + + int getLowestAmount (ArrayList list) + { + int frist = (Integer) list.get(0); //FRIST!!! + for (int i = 1; i < list.size(); i++) + { + int compare = (Integer) list.get(i); + if (frist > compare) + frist = compare; + } + return frist; + } +} diff --git a/tconstruct/library/crafting/CastingRecipe.java b/tconstruct/library/crafting/CastingRecipe.java new file mode 100644 index 00000000..d2065da7 --- /dev/null +++ b/tconstruct/library/crafting/CastingRecipe.java @@ -0,0 +1,38 @@ +package tconstruct.library.crafting; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class CastingRecipe +{ + public ItemStack output; + public FluidStack castingMetal; + public ItemStack cast; + public boolean consumeCast; + public int coolTime; + + public CastingRecipe(ItemStack replacement, FluidStack metal, ItemStack cast, boolean consume, int delay) + { + castingMetal = metal; + this.cast = cast; + output = replacement; + consumeCast = consume; + coolTime = delay; + } + + public boolean matches (FluidStack metal, ItemStack inputCast) + { + if (castingMetal.isFluidEqual(metal) + && ((cast != null && cast.getItemDamage() == Short.MAX_VALUE && inputCast.getItem() == cast.getItem()) || ItemStack.areItemStacksEqual(this.cast, inputCast))) + { + return true; + } + else + return false; + } + + public ItemStack getResult () + { + return output.copy(); + } +} \ No newline at end of file diff --git a/tconstruct/library/crafting/Detailing.java b/tconstruct/library/crafting/Detailing.java new file mode 100644 index 00000000..71685837 --- /dev/null +++ b/tconstruct/library/crafting/Detailing.java @@ -0,0 +1,127 @@ +package tconstruct.library.crafting; + +import java.util.ArrayList; +import java.util.List; + +import tconstruct.library.tools.ToolCore; + + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.common.registry.GameRegistry; + +public class Detailing +{ + public List detailing = new ArrayList(); + + public void addDetailing (Object input, int inputMeta, Object output, int outputMeta, ToolCore tool) + { + int iID, iMeta = inputMeta, oID, oMeta = outputMeta; + + if (input instanceof Block) + iID = ((Block) input).blockID; + + else if (input instanceof Item) + iID = ((Item) input).itemID; + + else if (input instanceof Integer) + iID = (Integer) input; + + else + throw new RuntimeException("Invalid detail input!"); + + if (output instanceof Block) + oID = ((Block) output).blockID; + + else if (output instanceof Item) + oID = ((Item) output).itemID; + + else if (output instanceof Integer) + oID = (Integer) output; + + else + throw new RuntimeException("Invalid detail output!"); + + this.addDetailing(new DetailInput(iID, iMeta, oID, oMeta), tool); + } + + public void addDetailing (DetailInput details, ToolCore tool) + { + detailing.add(details); + ItemStack toolstack = new ItemStack(tool, 1, Short.MAX_VALUE); + + NBTTagCompound compound = new NBTTagCompound(); + NBTTagCompound toolTag = new NBTTagCompound(); + toolTag.setInteger("RenderHandle", 0); + toolTag.setInteger("RenderHead", 2); + toolTag.setInteger("RenderAccessory", 2); + toolTag.setInteger("Damage", 0); + toolTag.setInteger("TotalDurability", 100); + compound.setCompoundTag("InfiTool", toolTag); + toolstack.setTagCompound(compound); + addShapelessToolRecipe(new ItemStack(details.outputID, 1, details.outputMeta), toolstack, new ItemStack(details.inputID, 1, details.inputMeta)); + } + + public void addShapelessToolRecipe (ItemStack par1ItemStack, Object... par2ArrayOfObj) + { + ArrayList arraylist = new ArrayList(); + Object[] aobject = par2ArrayOfObj; + int i = par2ArrayOfObj.length; + + for (int j = 0; j < i; ++j) + { + Object object1 = aobject[j]; + + if (object1 instanceof ItemStack) + { + arraylist.add(((ItemStack) object1).copy()); + } + else if (object1 instanceof Item) + { + arraylist.add(new ItemStack((Item) object1)); + } + else + { + if (!(object1 instanceof Block)) + { + throw new RuntimeException("Invalid shapeless tool recipe!"); + } + + arraylist.add(new ItemStack((Block) object1)); + } + } + + GameRegistry.addRecipe(new ShapelessToolRecipe(par1ItemStack, arraylist)); + } + + public DetailInput getDetailing (int inputID, int inputMeta) + { + for (int i = 0; i < detailing.size(); i++) + { + DetailInput detail = (DetailInput) detailing.get(i); + if (inputID == detail.inputID && inputMeta == detail.inputMeta) + { + return detail; + } + } + return null; + } + + public class DetailInput + { + public int inputID; + public int inputMeta; + public int outputID; + public int outputMeta; + + public DetailInput(int inputID, int inputMeta, int outputID, int outputMeta) + { + this.inputID = inputID; + this.inputMeta = inputMeta; + this.outputID = outputID; + this.outputMeta = outputMeta; + } + } +} diff --git a/tconstruct/library/crafting/DryingRackRecipes.java b/tconstruct/library/crafting/DryingRackRecipes.java new file mode 100644 index 00000000..4e8ff632 --- /dev/null +++ b/tconstruct/library/crafting/DryingRackRecipes.java @@ -0,0 +1,84 @@ +package tconstruct.library.crafting; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class DryingRackRecipes +{ + public static ArrayList recipes = new ArrayList(); + + public static void addDryingRecipe (Object input, int time, Object output) + { + ItemStack inputItem = null; + ItemStack outputItem = null; + + if (input instanceof ItemStack) + inputItem = (ItemStack) input; + else if (input instanceof Item) + inputItem = new ItemStack((Item) input, 1, 0); + else if (input instanceof Block) + inputItem = new ItemStack((Block) input, 1, 0); + else + throw new RuntimeException("Drying recipe input is invalid!"); + + if (output instanceof ItemStack) + outputItem = (ItemStack) output; + else if (output instanceof Item) + outputItem = new ItemStack((Item) output, 1, 0); + else if (output instanceof Block) + outputItem = new ItemStack((Block) output, 1, 0); + else + throw new RuntimeException("Drying recipe output is invalid!"); + + recipes.add(new DryingRecipe(inputItem, time, outputItem)); + } + + public static int getDryingTime (ItemStack input) + { + for (DryingRecipe r : recipes) + { + if (r.matches(input)) + return r.time; + } + + return -1; + } + + public static ItemStack getDryingResult (ItemStack input) + { + for (DryingRecipe r : recipes) + { + if (r.matches(input)) + return r.getResult(); + } + + return null; + } + + static class DryingRecipe + { + public final int time; + public final ItemStack input; + public final ItemStack result; + + DryingRecipe(ItemStack input, int time, ItemStack result) + { + this.time = time; + this.input = input; + this.result = result; + } + + public boolean matches (ItemStack input) + { + return ItemStack.areItemStacksEqual(this.input, input); + } + + public ItemStack getResult () + { + return result.copy(); + } + } +} diff --git a/tconstruct/library/crafting/LiquidCasting.java b/tconstruct/library/crafting/LiquidCasting.java new file mode 100644 index 00000000..b3bf536f --- /dev/null +++ b/tconstruct/library/crafting/LiquidCasting.java @@ -0,0 +1,86 @@ +package tconstruct.library.crafting; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +/* Melting becomes hardened */ +public class LiquidCasting +{ + //public static LiquidCasting instance = new LiquidCasting(); + private ArrayList casts = new ArrayList(); + + /** Adds a casting recipe + * + * @param output Result of the cast + * @param metal Liquid to be used in casting. This also decides how much metal is consumed + * @param cast The empty item to cast with. ex Ingot Cast + * @param consume Whether the item should be consumed while casting + * @param delay Time to cast in ticks + */ + public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay) + { + casts.add(new CastingRecipe(output, metal, cast, consume, delay)); + } + + /** Adds a casting recipe. Does not consume the cast + * + * @param output Result of the cast + * @param metal Liquid to be used in casting. This also decides how much metal is consumed + * @param cast The empty item to cast with. ex Ingot Cast + * @param delay Time to cast in ticks + */ + public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, int delay) + { + addCastingRecipe(output, metal, cast, false, delay); + } + + /** Adds a casting recipe. Does not consume the cast or have an item to cast against + * + * @param output Result of the cast + * @param metal Liquid to be used in casting. This also decides how much metal is consumed + * @param delay Time to cast in ticks + */ + public void addCastingRecipe (ItemStack output, FluidStack metal, int delay) + { + addCastingRecipe(output, metal, null, false, delay); + } + + public void addCustomCastingRecipe (CastingRecipe recipe) + { + casts.add(recipe); + } + + public int getCastingDelay (FluidStack metal, ItemStack cast) + { + CastingRecipe recipe = getCastingRecipe(metal, cast); + if (recipe != null) + return recipe.coolTime; + return -1; + } + + public int getCastingAmount (FluidStack metal, ItemStack cast) + { + CastingRecipe recipe = getCastingRecipe(metal, cast); + if (recipe != null) + return recipe.castingMetal.amount; + return 0; + } + + public CastingRecipe getCastingRecipe (FluidStack metal, ItemStack cast) + { + for (CastingRecipe recipe : casts) + { + if (recipe.matches(metal, cast)) + return recipe; + } + return null; + } + + //Getter for public viewing + public ArrayList getCastingRecipes () + { + return casts; + } +} diff --git a/tconstruct/library/crafting/PatternBuilder.java b/tconstruct/library/crafting/PatternBuilder.java new file mode 100644 index 00000000..eca8f72f --- /dev/null +++ b/tconstruct/library/crafting/PatternBuilder.java @@ -0,0 +1,252 @@ +package tconstruct.library.crafting; + +/** How to build tool parts? With patterns! */ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import tconstruct.library.TConstructRegistry; +import tconstruct.library.event.PartBuilderEvent; +import tconstruct.library.tools.CustomMaterial; +import tconstruct.library.util.IPattern; + + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.Event.Result; + +public class PatternBuilder +{ + public static PatternBuilder instance = new PatternBuilder(); + //Map items to their parts with a hashmap + public List materials = new ArrayList(); + public HashMap materialSets = new HashMap(); + + //We could use IRecipe if it wasn't tied to InventoryCrafting + public List toolPatterns = new ArrayList(); + + /* Register methods */ + public void registerMaterial (ItemStack material, int value, String key) + { + materials.add(new ItemKey(material.getItem(), material.getItemDamage(), value, key)); + } + + public void registerMaterialSet (String key, ItemStack shard, ItemStack rod, int materialID) + { + materialSets.put(key, new MaterialSet(shard, rod, materialID)); + materials.add(new ItemKey(shard.getItem(), shard.getItemDamage(), 1, key)); + } + + public void registerFullMaterial (ItemStack material, int value, String key, ItemStack shard, ItemStack rod, int materialID) + { + materials.add(new ItemKey(material.getItem(), material.getItemDamage(), value, key)); + materials.add(new ItemKey(shard.getItem(), shard.getItemDamage(), 1, key)); + materialSets.put(key, new MaterialSet(shard, rod, materialID)); + } + + public void addToolPattern (IPattern item) + { + toolPatterns.add(item); + } + + /* Build tool parts from patterns */ + public ItemStack[] getToolPart (ItemStack material, ItemStack pattern, ItemStack otherPattern) + { + if (material != null && pattern != null) + { + PartBuilderEvent.NormalPart event = new PartBuilderEvent.NormalPart(material, pattern, otherPattern); + MinecraftForge.EVENT_BUS.post(event); + + if (event.getResult() == Result.ALLOW) + { + return event.getResultStacks(); + } + else if (event.getResult() == Result.DENY) + { + return null; + } + + ItemKey key = getItemKey(material); + if (key != null) + { + MaterialSet mat = (MaterialSet) materialSets.get(key.key); + ItemStack toolPart = getMatchingPattern(pattern, material, mat); + + if (toolPart != null) + { + int patternValue = ((IPattern) pattern.getItem()).getPatternCost(pattern); + int totalMaterial = key.value * material.stackSize; + + if (totalMaterial < patternValue) // Not enough material + return null; + + else if (patternValue == key.value) //Material only + return new ItemStack[] { toolPart, null }; + + else + { + if (patternValue % 2 == 1) + { + return new ItemStack[] { toolPart, mat.shard.copy() }; //Material + shard + } + else + return new ItemStack[] { toolPart, null }; + } + /*if ( patternValue < totalMaterial ) + { + if (otherPattern != null) + { + int otherValue = ((IPattern)otherPattern.getItem()).getPatternCost(otherPattern.getItemDamage()); + if (patternValue + otherValue <= key.value) + { + ItemStack otherPart = getMatchingPattern(otherPattern, mat); + return new ItemStack[] { toolPart, otherPart }; //Material + Material + } + } + } + + else if ( patternValue == key.value ) + return new ItemStack[] { new ItemStack(toolPart, 1, mat.materialID), null }; //Material only + + else + return null; //Not a valid match*/ + } + } + } + return null; + } + + public int getPartID (ItemStack material) + { + if (material != null) + { + ItemKey key = getItemKey(material); + if (key != null) + { + MaterialSet set = (MaterialSet) materialSets.get(key.key); + return set.materialID; + } + } + return Short.MAX_VALUE; + } + + public int getPartValue (ItemStack material) + { + if (material != null) + { + ItemKey key = getItemKey(material); + if (key != null) + return key.value; + + for (CustomMaterial mat : TConstructRegistry.customMaterials) + { + if (material.isItemEqual(mat.input)) + return mat.value; + } + } + return 0; + } + + public ItemKey getItemKey (ItemStack material) + { + Item mat = material.getItem(); + int damage = material.getItemDamage(); + for (ItemKey ik : materials) + { + if (mat == ik.item && (ik.damage == Short.MAX_VALUE || damage == ik.damage)) + return ik; + } + return null; + } + + public ItemStack getMatchingPattern (ItemStack stack, ItemStack input, MaterialSet set) + { + Item item = stack.getItem(); + for (IPattern pattern : toolPatterns) + { + if (pattern == item) + return pattern.getPatternOutput(stack, input, set); + } + return null; + } + + public ItemStack getShardFromSet (String materialset) + { + MaterialSet set = (MaterialSet) materialSets.get(materialset); + if (set != null) + return set.shard.copy(); + return null; + } + + public ItemStack getRodFromSet (String materialset) + { + MaterialSet set = (MaterialSet) materialSets.get(materialset); + if (set != null) + return set.rod.copy(); + return null; + } + + //Small data classes. I would prefer the struct from C#, but we do what we can. + public class ItemKey + { + public final Item item; + public final int damage; + public final int value; + public final String key; + + public ItemKey(Item i, int d, int v, String s) + { + item = i; + damage = d; + value = v; + key = s; + } + } + + public class MaterialSet + { + public final ItemStack shard; + public final ItemStack rod; + public final int materialID; + + public MaterialSet(ItemStack s, ItemStack r, int id) + { + shard = s; + rod = r; + materialID = id; + } + } + + //Helper Methods + public void registerMaterial (Block material, int value, String key) + { + registerMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key); + } + + public void registerMaterial (Item material, int value, String key) + { + registerMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key); + } + + public void registerFullMaterial (Block material, int value, String key, ItemStack shard, ItemStack rod, int materialID) + { + registerFullMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key, shard, rod, materialID); + } + + public void registerFullMaterial (Item material, int value, String key, ItemStack shard, ItemStack rod, int materialID) + { + registerFullMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key, shard, rod, materialID); + } + + /*public void registerFullMaterial (Block material, int value, String key, int materialID) + { + registerFullMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key, new ItemStack(TContent.toolShard, 1, materialID), new ItemStack(TContent.toolRod, 1, materialID), materialID); + } + + public void registerFullMaterial (Item material, int value, String key, int materialID) + { + registerFullMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key, new ItemStack(TContent.toolShard, 1, materialID), new ItemStack(TContent.toolRod, 1, materialID), materialID); + }*/ +} \ No newline at end of file diff --git a/tconstruct/library/crafting/ShapelessToolRecipe.java b/tconstruct/library/crafting/ShapelessToolRecipe.java new file mode 100644 index 00000000..27e88ddc --- /dev/null +++ b/tconstruct/library/crafting/ShapelessToolRecipe.java @@ -0,0 +1,70 @@ +package tconstruct.library.crafting; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import tconstruct.library.tools.ToolCore; + + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class ShapelessToolRecipe extends ShapelessRecipes +{ + + public ShapelessToolRecipe(ItemStack par1ItemStack, List par2List) + { + super(par1ItemStack, par2List); + } + + @Override + public boolean matches (InventoryCrafting par1InventoryCrafting, World par2World) + { + ArrayList arraylist = new ArrayList(this.recipeItems); + + for (int i = 0; i < 3; ++i) + { + for (int j = 0; j < 3; ++j) + { + ItemStack itemstack = par1InventoryCrafting.getStackInRowAndColumn(j, i); + + if (itemstack != null) + { + boolean flag = false; + Iterator iterator = arraylist.iterator(); + + while (iterator.hasNext()) + { + ItemStack itemstack1 = (ItemStack) iterator.next(); + + //System.out.println("Rawr! "+itemstack1.getItemDamage()); + if (itemstack.itemID == itemstack1.itemID && (itemstack1.getItemDamage() == Short.MAX_VALUE || itemstack.getItemDamage() == itemstack1.getItemDamage())) + { + if (itemstack.getItem() instanceof ToolCore) + { + NBTTagCompound tags = itemstack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return false; + } + flag = true; + arraylist.remove(itemstack1); + break; + } + } + + if (!flag) + { + return false; + } + } + } + } + + return arraylist.isEmpty(); + } + +} diff --git a/tconstruct/library/crafting/Smeltery.java b/tconstruct/library/crafting/Smeltery.java new file mode 100644 index 00000000..473a808b --- /dev/null +++ b/tconstruct/library/crafting/Smeltery.java @@ -0,0 +1,172 @@ +package tconstruct.library.crafting; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +/** Melting and hacking, churn and burn */ +public class Smeltery +{ + public static Smeltery instance = new Smeltery(); + + private HashMap, FluidStack> smeltingList = new HashMap, FluidStack>(); + private HashMap, Integer> temperatureList = new HashMap, Integer>(); + private HashMap, ItemStack> renderIndex = new HashMap, ItemStack>(); + private ArrayList alloys = new ArrayList(); + + /** Adds mappings between an itemstack and an output liquid + * Example: Smeltery.addMelting(Block.oreIron, 0, 600, new FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0)); + * + * @param stack The itemstack to liquify + * @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary + * @param output The result of the process in liquid form + */ + public static void addMelting (ItemStack stack, int temperature, FluidStack output) + { + addMelting(stack, stack.itemID, stack.getItemDamage(), temperature, output); + } + + /** Adds mappings between a block and its liquid + * Example: Smeltery.addMelting(Block.oreIron, 0, 600, new FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0)); + * + * @param blockID The ID of the block to liquify and render + * @param metadata The metadata of the block to liquify and render + * @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary + * @param output The result of the process in liquid form + */ + public static void addMelting (Block block, int metadata, int temperature, FluidStack output) + { + addMelting(new ItemStack(block, 1, metadata), block.blockID, metadata, temperature, output); + } + + /** Adds mappings between an input and its liquid. + * Renders with the given input's block ID and metadata + * Example: Smeltery.addMelting(Block.oreIron, 0, 600, new FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0)); + * + * @param input The item to liquify + * @param blockID The ID of the block to render + * @param metadata The metadata of the block to render + * @param temperature How hot the block should be before liquifying + * @param liquid The result of the process + */ + public static void addMelting (ItemStack input, int blockID, int metadata, int temperature, FluidStack liquid) + { + instance.smeltingList.put(Arrays.asList(input.itemID, input.getItemDamage()), liquid); + instance.temperatureList.put(Arrays.asList(input.itemID, input.getItemDamage()), temperature); + instance.renderIndex.put(Arrays.asList(input.itemID, input.getItemDamage()), new ItemStack(blockID, input.stackSize, metadata)); + } + + /** Adds an alloy mixing recipe. + * Example: Smeltery.addAlloyMixing(new FluidStack(bronzeID, 2, 0), new FluidStack(copperID, 3, 0), new FluidStack(tinID, 1, 0)); + * The example mixes 3 copper with 1 tin to make 2 bronze + * + * @param result The output of the combination of mixers. The quantity is used for amount of a successful mix + * @param mixers the liquids to be mixed. Quantities are used as ratios + */ + public static void addAlloyMixing (FluidStack result, FluidStack... mixers) + { + ArrayList inputs = new ArrayList(); + for (FluidStack liquid : mixers) + inputs.add(liquid); + + instance.alloys.add(new AlloyMix(result, inputs)); + } + + /** + * Used to get the resulting temperature from a source ItemStack + * @param item The Source ItemStack + * @return The result temperature + */ + public static Integer getLiquifyTemperature (ItemStack item) + { + if (item == null) + return 20; + + Integer temp = instance.temperatureList.get(Arrays.asList(item.itemID, item.getItemDamage())); + if (temp == null) + return 20; + else + return temp; + } + + /** + * Used to get the resulting temperature from a source Block + * @param item The Source ItemStack + * @return The result ItemStack + */ + public static Integer getLiquifyTemperature (int blockID, int metadata) + { + return instance.temperatureList.get(Arrays.asList(blockID, metadata)); + } + + /** + * Used to get the resulting ItemStack from a source ItemStack + * @param item The Source ItemStack + * @return The result ItemStack + */ + public static FluidStack getSmelteryResult (ItemStack item) + { + if (item == null) + return null; + + FluidStack stack = (FluidStack) instance.smeltingList.get(Arrays.asList(item.itemID, item.getItemDamage())); + if (stack == null) + return null; + return stack.copy(); + } + + /** + * Used to get the resulting ItemStack from a source Block + * @param item The Source ItemStack + * @return The result ItemStack + */ + public static FluidStack getSmelteryResult (int blockID, int metadata) + { + FluidStack stack = (FluidStack) instance.smeltingList.get(Arrays.asList(blockID, metadata)); + if (stack == null) + return null; + return stack.copy(); + } + + public static ItemStack getRenderIndex (ItemStack input) + { + return instance.renderIndex.get(Arrays.asList(input.itemID, input.getItemDamage())); + } + + public static ArrayList mixMetals (ArrayList moltenMetal) + { + ArrayList liquids = new ArrayList(); + for (AlloyMix alloy : instance.alloys) + { + FluidStack liquid = alloy.mix(moltenMetal); + if (liquid != null) + liquids.add(liquid); + } + return liquids; + } + + public static HashMap, FluidStack> getSmeltingList () + { + return instance.smeltingList; + } + + public static HashMap, Integer> getTemperatureList () + { + return instance.temperatureList; + } + + public static HashMap, ItemStack> getRenderIndex () + { + return instance.renderIndex; + } + + public static ArrayList getAlloyList () + { + return instance.alloys; + } +} diff --git a/tconstruct/library/crafting/ToolBuilder.java b/tconstruct/library/crafting/ToolBuilder.java new file mode 100644 index 00000000..f10c7c33 --- /dev/null +++ b/tconstruct/library/crafting/ToolBuilder.java @@ -0,0 +1,411 @@ +package tconstruct.library.crafting; + +/** Once upon a time, too many tools to count. Let's put them together automatically */ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import tconstruct.library.TConstructRegistry; +import tconstruct.library.event.ToolCraftEvent; +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMaterial; +import tconstruct.library.tools.ToolMod; +import tconstruct.library.util.IToolPart; + + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.Event.Result; + +public class ToolBuilder +{ + public static ToolBuilder instance = new ToolBuilder(); + + public HashMap recipeList = new HashMap(); + public List combos = new ArrayList(); + public HashMap modifiers = new HashMap(); + public List toolMods = new ArrayList(); + + /* Build tools */ + public static void addNormalToolRecipe (ToolCore output, Item head, Item handle) + { + ToolRecipe recipe = instance.recipeList.get(output.getToolName()); + if (recipe != null) + { + recipe.addHeadItem(head); + recipe.addHandleItem(handle); + } + else + { + recipe = new ToolRecipe(head, handle, output); + instance.combos.add(recipe); + instance.recipeList.put(output.getToolName(), recipe); + } + } + + public static void addNormalToolRecipe (ToolCore output, Item head, Item handle, Item accessory) + { + //instance.combos.add(new ToolRecipe(head, accessory, output)); + ToolRecipe recipe = instance.recipeList.get(output.getToolName()); + if (recipe != null) + { + recipe.addHeadItem(head); + recipe.addHandleItem(handle); + recipe.addAccessoryItem(accessory); + } + else + { + recipe = new ToolRecipe(head, handle, accessory, output); + instance.combos.add(recipe); + instance.recipeList.put(output.getToolName(), recipe); + } + } + + public static void addNormalToolRecipe (ToolCore output, Item head, Item handle, Item accessory, Item extra) + { + ToolRecipe recipe = instance.recipeList.get(output.getToolName()); + if (recipe != null) + { + recipe.addHeadItem(head); + recipe.addHandleItem(handle); + recipe.addAccessoryItem(accessory); + recipe.addExtraItem(accessory); + } + else + { + recipe = new ToolRecipe(head, handle, accessory, extra, output); + instance.combos.add(recipe); + instance.recipeList.put(output.getToolName(), recipe); + } + } + + public static void addCustomToolRecipe (ToolRecipe recipe) + { + instance.combos.add(recipe); + } + + public static void addToolRecipe (ToolCore output, Item... items) + { + if (items.length == 2) + addNormalToolRecipe(output, items[0], items[1]); + if (items.length == 3) + addNormalToolRecipe(output, items[0], items[1], items[2]); + if (items.length == 4) + addNormalToolRecipe(output, items[0], items[1], items[2], items[3]); + } + + public ToolCore getMatchingRecipe (Item head, Item handle, Item accessory, Item extra) + { + for (ToolRecipe recipe : combos) + { + if (recipe.validHead(head) && recipe.validHandle(handle) && recipe.validAccessory(accessory) && recipe.validExtra(extra)) + return recipe.getType(); + } + return null; + } + + //Builds a tool from the parts given + public ItemStack buildTool (ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, String name) + { + return buildTool(headStack, handleStack, accessoryStack, null, name); + } + + public ItemStack buildTool (ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, ItemStack extraStack, String name) + { + if (headStack != null && headStack.getItem() instanceof ToolCore) + return modifyTool(headStack, handleStack, accessoryStack, extraStack); + + if (headStack == null || handleStack == null) //Nothing to build without these. All tools need at least two parts! + return null; + + ToolCore item; + boolean validMaterials = true; + int head = -1, handle = -1, accessory = -1, extra = -1; + if (headStack.getItem() instanceof IToolPart) + { + head = ((IToolPart) headStack.getItem()).getMaterialID(headStack); + } + else + validMaterials = false; + + Item handleItem = handleStack.getItem(); + + if (handleItem == Item.stick) + handle = 0; + else if (handleItem == Item.bone) + handle = 5; + else if (handleItem instanceof IToolPart) + handle = ((IToolPart) handleItem).getMaterialID(handleStack); + else + validMaterials = false; + + if (!validMaterials) + return null; + + if (accessoryStack == null) + { + item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), null, null); + } + else + { + if (accessoryStack.getItem() instanceof IToolPart) + accessory = ((IToolPart) accessoryStack.getItem()).getMaterialID(accessoryStack); + else + return null; + + if (extraStack != null) + { + if (extraStack.getItem() instanceof IToolPart) + extra = ((IToolPart) extraStack.getItem()).getMaterialID(extraStack); + else + return null; + + item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), extraStack.getItem()); + } + else + { + item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), null); + } + } + + //System.out.println("Valid: "+item); + + if (item == null) + return null; + + ToolMaterial headMat = null, handleMat = null, accessoryMat = null, extraMat = null; + headMat = TConstructRegistry.getMaterial(head); + handleMat = TConstructRegistry.getMaterial(handle); + + if (accessory != -1) + accessoryMat = TConstructRegistry.getMaterial(accessory); + + if (extra != -1) + extraMat = TConstructRegistry.getMaterial(extra); + + int durability = headMat.durability(); + int heads = 1; + int handles = 0; + float modifier = 1f; + int attack = headMat.attack(); + + if (item.durabilityTypeHandle() == 2) + { + heads++; + durability += handleMat.durability(); + attack += handleMat.attack(); + } + else if (item.durabilityTypeHandle() == 1) + { + handles++; + modifier = handleMat.handleDurability(); + } + + if (accessory != -1) + { + if (item.durabilityTypeAccessory() == 2) + { + heads++; + durability += accessoryMat.durability(); + attack += accessoryMat.attack(); + } + else if (item.durabilityTypeAccessory() == 1) + { + handles++; + modifier += accessoryMat.handleDurability(); + } + } + + if (extra != -1) + { + if (item.durabilityTypeExtra() == 2) + { + heads++; + durability += extraMat.durability(); + attack += extraMat.attack(); + } + else if (item.durabilityTypeExtra() == 1) + { + handles++; + modifier += extraMat.handleDurability(); + } + } + + if (handles > 0) + { + modifier *= (0.5 + handles * 0.5); + modifier /= handles; + } + + durability = (int) (durability / heads * (0.5 + heads * 0.5) * modifier * item.getDurabilityModifier()); + attack = attack / heads + item.getDamageVsEntity(null); + if (attack % heads != 0) + attack++; + + ItemStack tool = new ItemStack(item); + NBTTagCompound compound = new NBTTagCompound(); + + compound.setCompoundTag("InfiTool", new NBTTagCompound()); + compound.getCompoundTag("InfiTool").setInteger("Head", head); + compound.getCompoundTag("InfiTool").setInteger("RenderHead", head); + + compound.getCompoundTag("InfiTool").setInteger("Handle", handle); + compound.getCompoundTag("InfiTool").setInteger("RenderHandle", handle); + + if (accessory != -1) + { + compound.getCompoundTag("InfiTool").setInteger("Accessory", accessory); + compound.getCompoundTag("InfiTool").setInteger("RenderAccessory", accessory); + } + if (extra != -1) + { + compound.getCompoundTag("InfiTool").setInteger("Extra", extra); + compound.getCompoundTag("InfiTool").setInteger("RenderExtra", extra); + } + + compound.getCompoundTag("InfiTool").setInteger("Damage", 0); //Damage is damage to the tool + compound.getCompoundTag("InfiTool").setInteger("TotalDurability", durability); + compound.getCompoundTag("InfiTool").setInteger("BaseDurability", durability); + compound.getCompoundTag("InfiTool").setInteger("BonusDurability", 0); //Modifier + compound.getCompoundTag("InfiTool").setFloat("ModDurability", 0f); //Modifier + compound.getCompoundTag("InfiTool").setBoolean("Broken", false); + compound.getCompoundTag("InfiTool").setInteger("Attack", attack); + + compound.getCompoundTag("InfiTool").setInteger("MiningSpeed", headMat.toolSpeed()); + compound.getCompoundTag("InfiTool").setInteger("HarvestLevel", headMat.harvestLevel()); + if (item.durabilityTypeHandle() == 2) + { + compound.getCompoundTag("InfiTool").setInteger("MiningSpeedHandle", handleMat.toolSpeed()); + compound.getCompoundTag("InfiTool").setInteger("HarvestLevelHandle", handleMat.harvestLevel()); + } + if (accessory != -1 && item.durabilityTypeAccessory() == 2) + { + compound.getCompoundTag("InfiTool").setInteger("MiningSpeed2", accessoryMat.toolSpeed()); + compound.getCompoundTag("InfiTool").setInteger("HarvestLevel2", accessoryMat.harvestLevel()); + } + + if (extra != -1 && item.durabilityTypeExtra() == 2) + { + compound.getCompoundTag("InfiTool").setInteger("MiningSpeedExtra", extraMat.toolSpeed()); + compound.getCompoundTag("InfiTool").setInteger("HarvestLevelExtra", extraMat.harvestLevel()); + } + + compound.getCompoundTag("InfiTool").setInteger("Unbreaking", buildReinforced(headMat, handleMat, accessoryMat, extraMat)); + compound.getCompoundTag("InfiTool").setFloat("Shoddy", buildShoddy(headMat, handleMat, accessoryMat, extraMat)); + + int modifiers = item.getModifierAmount(); + if (accessory == -1) + modifiers += (head == 9 ? 2 : 0); + else + modifiers += (head == 9 ? 1 : 0) + (accessory == 9 ? 1 : 0); + modifiers += +(handle == 9 ? 1 : 0); + modifiers += +(extra == 9 ? 1 : 0); + + compound.getCompoundTag("InfiTool").setInteger("Modifiers", modifiers); + + if (name != null && !name.equals("")) + { + compound.setCompoundTag("display", new NBTTagCompound()); + compound.getCompoundTag("display").setString("Name", "\u00A7f" + name); + } + + ToolCraftEvent.NormalTool event = new ToolCraftEvent.NormalTool(item, compound, new ToolMaterial[] { headMat, handleMat, accessoryMat, extraMat }); + MinecraftForge.EVENT_BUS.post(event); + + if (event.getResult() == Result.DEFAULT) + { + tool.setTagCompound(compound); + } + else if (event.getResult() == Result.ALLOW) + { + tool = event.getResultStack(); + } + else + { + tool = null; + } + + return tool; + } + + public ItemStack modifyTool (ItemStack input, ItemStack topSlot, ItemStack bottomSlot, ItemStack extraStack) + { + if (extraStack != null) + return null; + + ItemStack tool = input.copy(); + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + tags.removeTag("Built"); + + if (topSlot == null && bottomSlot == null) + return tool; + + boolean built = false; + for (ToolMod mod : toolMods) + { + ItemStack[] slots = new ItemStack[] { topSlot, bottomSlot }; + if (mod.matches(slots, tool)) + { + built = true; + mod.addMatchingEffect(tool); + mod.modify(slots, tool); + } + } + + if (built) + return tool; + else + return null; + } + + int buildReinforced (ToolMaterial headMat, ToolMaterial handleMat, ToolMaterial accessoryMat, ToolMaterial extraMat) + { + int reinforced = 0; + + int dHead = headMat.reinforced(); + int dHandle = handleMat.reinforced(); + int dAccessory = 0; + if (accessoryMat != null) + dAccessory = accessoryMat.reinforced(); + int dExtra = 0; + if (extraMat != null) + dExtra = extraMat.reinforced(); + + if (dHead > reinforced) + reinforced = dHead; + if (dHandle > reinforced) + reinforced = dHandle; + if (dAccessory > reinforced) + reinforced = dAccessory; + if (dExtra > reinforced) + reinforced = dExtra; + + return reinforced; + } + + float buildShoddy (ToolMaterial headMat, ToolMaterial handleMat, ToolMaterial accessoryMat, ToolMaterial extraMat) + { + float sHead = headMat.shoddy(); + float sHandle = handleMat.shoddy(); + if (extraMat != null) + { + float sAccessory = accessoryMat.shoddy(); + float sExtra = extraMat.shoddy(); + return (sHead + sHandle + sAccessory + sExtra) / 4f; + } + + if (accessoryMat != null) + { + float sAccessory = accessoryMat.shoddy(); + return (sHead + sHandle + sAccessory) / 3f; + } + return (sHead + sHandle) / 2f; + } + + public static void registerToolMod (ToolMod mod) + { + instance.toolMods.add(mod); + } +} diff --git a/tconstruct/library/crafting/ToolRecipe.java b/tconstruct/library/crafting/ToolRecipe.java new file mode 100644 index 00000000..b49869cc --- /dev/null +++ b/tconstruct/library/crafting/ToolRecipe.java @@ -0,0 +1,132 @@ +package tconstruct.library.crafting; + +import java.util.LinkedList; + +import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.ToolCore; + + +import net.minecraft.item.Item; + +/* + * Small class for checking if a particular tool combination is this one + */ + +public class ToolRecipe +{ + LinkedList headList = new LinkedList(); + LinkedList handleList = new LinkedList(); + LinkedList accessoryList = new LinkedList(); + LinkedList extraList = new LinkedList(); + ToolCore result; + Item toolRod = TConstructRegistry.getItem("toolRod"); + + /*public ToolRecipe(Item head, ToolCore tool) + { + this(head, TContent.toolRod, null, null, tool); + }*/ + + public ToolRecipe(Item head, Item handle, ToolCore tool) + { + this(head, handle, null, null, tool); + } + + public ToolRecipe(Item head, Item handle, Item accessory, ToolCore tool) + { + this(head, handle, accessory, null, tool); + } + + public ToolRecipe(Item head, Item handle, Item accessory, Item extra, ToolCore tool) + { + this.headList.add(head); + this.handleList.add(handle); + if (accessory != null) + this.accessoryList.add(accessory); + if (extra != null) + this.extraList.add(extra); + result = tool; + } + + public void addHeadItem (Item head) + { + this.headList.add(head); + } + + public void addHandleItem (Item head) + { + this.handleList.add(head); + } + + public void addAccessoryItem (Item head) + { + this.accessoryList.add(head); + } + + public void addExtraItem (Item head) + { + this.extraList.add(head); + } + + public boolean validHead (Item input) + { + for (Item part : headList) + { + if (part == input) + return true; + } + return false; + } + + public boolean validHandle (Item input) + { + for (Item part : handleList) + { + if (part == input) + return true; + if (toolRod != null && part == toolRod && (input == Item.stick || input == Item.bone)) + return true; + } + return false; + } + + public boolean validAccessory (Item input) + { + if (input == null) + { + if (accessoryList.size() < 1) + return true; + return false; + } + for (Item part : accessoryList) + { + if (part == input) + return true; + if (toolRod != null && part == toolRod && (input == Item.stick || input == Item.bone)) + return true; + } + return false; + } + + public boolean validExtra (Item input) + { + if (input == null) + { + if (extraList.size() < 1) + return true; + return false; + } + for (Item part : extraList) + { + if (part == input) + return true; + if (toolRod != null && part == toolRod && (input == Item.stick || input == Item.bone)) + return true; + } + return false; + } + + public ToolCore getType () + { + return result; + } +} diff --git a/tconstruct/library/event/PartBuilderEvent.java b/tconstruct/library/event/PartBuilderEvent.java new file mode 100644 index 00000000..248ec1a1 --- /dev/null +++ b/tconstruct/library/event/PartBuilderEvent.java @@ -0,0 +1,51 @@ +package tconstruct.library.event; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.Event; + +/* This event fires after all of the other construction. The resulting nbttag is added to the tool + * Note: The tag is the base tag. toolTag.getCompoundTag("InfiTool") will have all of the tool's data. + */ + +public class PartBuilderEvent extends Event +{ + public final ItemStack material; + public final ItemStack pattern; + public final ItemStack otherPattern; + protected ItemStack[] resultStacks; + + public PartBuilderEvent(ItemStack material, ItemStack pattern, ItemStack otherPattern) + { + this.material = material; + this.pattern = pattern; + this.otherPattern = otherPattern; + } + + @HasResult + public static class NormalPart extends PartBuilderEvent + { + public NormalPart(ItemStack material, ItemStack pattern, ItemStack otherPattern) + { + super(material, pattern, otherPattern); + } + + /** Fires before other processing is done + * + * Result is significant: + * DEFAULT: Allows part to be crafted normally + * ALLOW: Uses resultStack instead + * DENY: Stops part crafting altogether + */ + + public void overrideResult (ItemStack[] result) + { + resultStacks = result; + this.setResult(Result.ALLOW); + } + + public ItemStack[] getResultStacks () + { + return resultStacks; + } + } +} diff --git a/tconstruct/library/event/ToolCraftEvent.java b/tconstruct/library/event/ToolCraftEvent.java new file mode 100644 index 00000000..effb6294 --- /dev/null +++ b/tconstruct/library/event/ToolCraftEvent.java @@ -0,0 +1,54 @@ +package tconstruct.library.event; + +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMaterial; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.event.Event; + +/* This event fires after all of the other construction. The resulting nbttag is added to the tool + * Note: The tag is the base tag. toolTag.getCompoundTag("InfiTool") will have all of the tool's data. + */ + +public class ToolCraftEvent extends Event +{ + public final ToolCore tool; + public final NBTTagCompound toolTag; + public final ToolMaterial[] materials; + protected ItemStack resultStack; + + public ToolCraftEvent(ToolCore tool, NBTTagCompound toolTag, ToolMaterial[] materials) + { + this.tool = tool; + this.toolTag = toolTag; + this.materials = materials; + } + + @HasResult + public static class NormalTool extends ToolCraftEvent + { + public NormalTool(ToolCore tool, NBTTagCompound toolTag, ToolMaterial[] materials) + { + super(tool, toolTag, materials); + } + + /** Fires just before the tool is put together + * + * Result is significant: + * DEFAULT: Allows tool to be crafted normally + * ALLOW: Uses resultStack instead + * DENY: Stops tool crafting altogether + */ + + public void overrideResult (ItemStack result) + { + resultStack = result; + this.setResult(Result.ALLOW); + } + + public ItemStack getResultStack () + { + return resultStack; + } + } +} diff --git a/tconstruct/library/tools/AbilityHelper.java b/tconstruct/library/tools/AbilityHelper.java new file mode 100644 index 00000000..7496e5c5 --- /dev/null +++ b/tconstruct/library/tools/AbilityHelper.java @@ -0,0 +1,720 @@ +package tconstruct.library.tools; + +import ic2.api.item.ICustomElectricItem; +import ic2.api.item.IElectricItem; + +import java.util.Iterator; +import java.util.List; +import java.util.Random; + +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.util.PiercingEntityDamage; + + +import net.minecraft.block.Block; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.EnchantmentThorns; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraftforge.common.FakePlayer; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.Event.Result; +import net.minecraftforge.event.entity.player.UseHoeEvent; + +public class AbilityHelper +{ + public static Random random = new Random(); + + /* Normal interactions */ + public static boolean onBlockChanged (ItemStack stack, World world, int bID, int x, int y, int z, EntityLivingBase player, Random random) + { + if (!stack.hasTagCompound()) + return false; + + int reinforced = 0; + NBTTagCompound tags = stack.getTagCompound(); + + if (tags.getCompoundTag("InfiTool").hasKey("Unbreaking")) + reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking"); + + if (random.nextInt(10) < 10 - reinforced) + { + damageTool(stack, 1, tags, player, false); + } + + return true; + } + + public static boolean onLeftClickEntity (ItemStack stack, EntityLivingBase player, Entity entity, ToolCore tool) + { + return onLeftClickEntity(stack, player, entity, tool, 0); + } + + public static boolean onLeftClickEntity (ItemStack stack, EntityLivingBase player, Entity entity, ToolCore tool, int baseDamage) + { + if (entity.canAttackWithItem() && stack.hasTagCompound()) + { + if (!entity.func_85031_j(player)) // can't attack this entity + { + NBTTagCompound tags = stack.getTagCompound(); + NBTTagCompound toolTags = stack.getTagCompound().getCompoundTag("InfiTool"); + int damage = toolTags.getInteger("Attack") + baseDamage; + boolean broken = toolTags.getBoolean("Broken"); + + int durability = tags.getCompoundTag("InfiTool").getInteger("Damage"); + float stonebound = tags.getCompoundTag("InfiTool").getFloat("Shoddy"); + + float stoneboundDamage = (float) Math.log(durability / 72f + 1) * -2 * stonebound; + + int earlyModDamage = 0; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + earlyModDamage = mod.baseAttackDamage(earlyModDamage, damage, tool, tags, toolTags, stack, player, entity); + } + damage += earlyModDamage; + + if (player.isPotionActive(Potion.damageBoost)) + { + damage += 3 << player.getActivePotionEffect(Potion.damageBoost).getAmplifier(); + } + + if (player.isPotionActive(Potion.weakness)) + { + damage -= 2 << player.getActivePotionEffect(Potion.weakness).getAmplifier(); + } + + float knockback = 0; + float enchantDamage = 0; + + if (entity instanceof EntityLivingBase) + { + enchantDamage = EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLivingBase) entity); + knockback += EnchantmentHelper.getKnockbackModifier(player, (EntityLivingBase) entity); + } + + damage += stoneboundDamage; + if (damage < 1) + damage = 1; + + if (player.isSprinting()) + { + knockback++; + float lunge = tool.chargeAttack(); + if (lunge > 1f) + { + knockback += lunge - 1.0f; + damage *= lunge; + } + } + + float modKnockback = 0f; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + modKnockback = mod.knockback(modKnockback, knockback, tool, tags, toolTags, stack, player, entity); + } + knockback += modKnockback; + + int modDamage = 0; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + modDamage = mod.attackDamage(modDamage, damage, tool, tags, toolTags, stack, player, entity); + } + damage += modDamage; + + if (damage > 0 || enchantDamage > 0) + { + boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) + && player.ridingEntity == null && entity instanceof EntityLivingBase; + + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.doesCriticalHit(tool, tags, toolTags, stack, player, entity)) + criticalHit = true; + } + + if (criticalHit) + { + damage += random.nextInt(damage / 2 + 2); + } + + damage += enchantDamage; + + if (tool.getDamageModifier() != 1f) + { + damage *= tool.getDamageModifier(); + } + boolean var6 = false; + int fireAspect = EnchantmentHelper.getFireAspectModifier(player); + + if (entity instanceof EntityLivingBase && fireAspect > 0 && !entity.isBurning()) + { + var6 = true; + entity.setFire(1); + } + + if (broken) + { + if (baseDamage > 0) + damage = baseDamage; + else + damage = 1; + } + boolean causedDamage = false; + if (tool.pierceArmor() && !broken) + { + if (player instanceof EntityPlayer) + causedDamage = entity.attackEntityFrom(causePlayerPiercingDamage((EntityPlayer) player), damage); + else + causedDamage = entity.attackEntityFrom(causePiercingDamage(player), damage); + } + else + { + if (player instanceof EntityPlayer) + causedDamage = entity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) player), damage); + else + causedDamage = entity.attackEntityFrom(DamageSource.causeMobDamage(player), damage); + } + + if (causedDamage) + { + int reinforced = 0; + if (toolTags.hasKey("Unbreaking")) + reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking"); + + if (random.nextInt(10) < 10 - reinforced) + { + damageTool(stack, 1, tags, player, false); + } + //damageTool(stack, 1, player, false); + tool.onEntityDamaged(player.worldObj, player, entity); + int drain = toolTags.getInteger("Necrotic") * 2; + if (drain > 0) + player.heal(random.nextInt(drain + 1)); + + if (knockback > 0) + { + entity.addVelocity((double) (-MathHelper.sin(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F), 0.1D, + (double) (MathHelper.cos(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F)); + player.motionX *= 0.6D; + player.motionZ *= 0.6D; + player.setSprinting(false); + } + + if (player instanceof EntityPlayer) + { + if (criticalHit) + { + ((EntityPlayer) player).onCriticalHit(entity); + } + + if (enchantDamage > 0) + { + ((EntityPlayer) player).onEnchantmentCritical(entity); + } + + if (damage >= 18) + { + ((EntityPlayer) player).triggerAchievement(AchievementList.overkill); + } + } + + player.func_130011_c(entity); + + if (entity instanceof EntityLivingBase) + { + EnchantmentThorns.func_92096_a(player, (EntityLivingBase) entity, random); + } + } + + if (entity instanceof EntityLivingBase) + { + if (entity instanceof EntityPlayer) + { + stack.hitEntity((EntityLivingBase) entity, (EntityPlayer) player); + if (entity.isEntityAlive()) + { + alertPlayerWolves((EntityPlayer) player, (EntityLivingBase) entity, true); + } + + ((EntityPlayer) player).addStat(StatList.damageDealtStat, damage); + } + else + { + Item.itemsList[stack.itemID].hitEntity(stack, (EntityLivingBase) entity, player); + } + + if ((fireAspect > 0 || toolTags.hasKey("Fiery") || toolTags.hasKey("Lava")) && causedDamage) + { + fireAspect *= 4; + if (toolTags.hasKey("Fiery")) + { + fireAspect += toolTags.getInteger("Fiery") / 5 + 1; + } + if (toolTags.getBoolean("Lava")) + { + fireAspect += 3; + } + entity.setFire(fireAspect); + } + else if (var6) + { + entity.extinguish(); + } + } + + if (entity instanceof EntityPlayer) + ((EntityPlayer) player).addExhaustion(0.3F); + if (causedDamage) + return true; + } + } + } + return false; + } + + static void alertPlayerWolves (EntityPlayer player, EntityLivingBase living, boolean par2) + { + if (!(living instanceof EntityCreeper) && !(living instanceof EntityGhast)) + { + if (living instanceof EntityWolf) + { + EntityWolf var3 = (EntityWolf) living; + + if (var3.isTamed() && player.username.equals(var3.getOwnerName())) + { + return; + } + } + + if (!(living instanceof EntityPlayer) || player.func_96122_a((EntityPlayer) living)) + { + List var6 = player.worldObj.getEntitiesWithinAABB(EntityWolf.class, + AxisAlignedBB.getAABBPool().getAABB(player.posX, player.posY, player.posZ, player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D)); + Iterator var4 = var6.iterator(); + + while (var4.hasNext()) + { + EntityWolf var5 = (EntityWolf) var4.next(); + + if (var5.isTamed() && var5.getEntityToAttack() == null && player.username.equals(var5.getOwnerName()) && (!par2 || !var5.isSitting())) + { + var5.setSitting(false); + var5.setTarget(living); + } + } + } + } + } + + /* Tool specific */ + public static void damageTool (ItemStack stack, int dam, EntityLivingBase entity, boolean ignoreCharge) + { + NBTTagCompound tags = stack.getTagCompound(); + damageTool(stack, dam, tags, entity, ignoreCharge); + } + + public static void healTool (ItemStack stack, int dam, EntityLivingBase entity, boolean ignoreCharge) + { + NBTTagCompound tags = stack.getTagCompound(); + damageTool(stack, -dam, tags, entity, ignoreCharge); + } + + public static void damageTool (ItemStack stack, int dam, NBTTagCompound tags, EntityLivingBase entity, boolean ignoreCharge) + { + if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode || tags == null) + return; + + if (ignoreCharge || !damageElectricTool(stack, tags, entity)) + { + boolean damagedTool = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.damageTool(stack, dam, entity)) + damagedTool = true; + } + + if (damagedTool) + return; + + int damage = tags.getCompoundTag("InfiTool").getInteger("Damage"); + int damageTrue = damage + dam; + int maxDamage = tags.getCompoundTag("InfiTool").getInteger("TotalDurability"); + if (damageTrue <= 0) + { + tags.getCompoundTag("InfiTool").setInteger("Damage", 0); + stack.setItemDamage(0); + } + + else if (damageTrue > maxDamage) + { + breakTool(stack, tags, entity); + stack.setItemDamage(0); + } + + else + { + tags.getCompoundTag("InfiTool").setInteger("Damage", damage + dam); + int toolDamage = (damage * 100 / maxDamage) + 1; + int stackDamage = stack.getItemDamage(); + if (toolDamage != stackDamage) + { + stack.setItemDamage((damage * 100 / maxDamage) + 1); + } + } + } + } + + public static boolean damageElectricTool (ItemStack stack, NBTTagCompound tags, Entity entity) + { + if (!tags.hasKey("charge")) + return false; + + int charge = tags.getInteger("charge"); + + int durability = tags.getInteger("Damage"); + float shoddy = tags.getFloat("Shoddy"); + + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } + + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } + + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + float trueSpeed = mineSpeed / (heads * 100f); + float stonebound = tags.getFloat("Shoddy"); + float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; + trueSpeed += bonusLog; + + /*mineSpeed += shoddy * durability / 100f; + mineSpeed /= 15;*/ + + if (charge < trueSpeed) + { + if (charge > 0) + tags.setInteger("charge", 0); + return false; + } + /*if (entity instanceof EntityPlayer && ElectricItem.use(stack, mineSpeed, (EntityPlayer) entity)) + return true;*/ + + charge -= mineSpeed; + ToolCore tool = (ToolCore) stack.getItem(); + stack.setItemDamage(1 + (tool.getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 1) / tool.getMaxCharge(stack)); + tags.setInteger("charge", charge); + if (entity instanceof EntityPlayer) + chargeFromArmor(stack, (EntityPlayer) entity); + return true; + } + + static void chargeFromArmor (ItemStack stack, EntityPlayer player) + { + boolean inContainer = false; + + for (int armorIter = 0; armorIter < 4; ++armorIter) + { + ItemStack armor = player.inventory.armorInventory[armorIter]; + + if (armor != null && armor.getItem() instanceof IElectricItem) + { + IElectricItem electricArmor = (IElectricItem) armor.getItem(); + ToolCore tool = (ToolCore) stack.getItem(); + + if (electricArmor.canProvideEnergy(stack) && electricArmor.getTier(stack) >= ((IElectricItem) stack.getItem()).getTier(stack)) + { + int chargeAmount = tool.charge(stack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true); + chargeAmount = discharge(armor, chargeAmount, Integer.MAX_VALUE, true, false); + + if (chargeAmount > 0) + { + tool.charge(stack, chargeAmount, Integer.MAX_VALUE, true, false); + inContainer = true; + } + } + } + } + + if (inContainer) + { + player.openContainer.detectAndSendChanges(); + } + } + + public static int discharge (ItemStack stack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) + { + IElectricItem ielectricitem = (IElectricItem) stack.getItem(); + + if (ielectricitem instanceof ICustomElectricItem) + { + return ((ICustomElectricItem) ielectricitem).discharge(stack, amount, tier, ignoreTransferLimit, simulate); + } + else if (amount >= 0 && stack.stackSize <= 1 && ielectricitem.getTier(stack) <= tier) + { + if (amount > ielectricitem.getTransferLimit(stack) && !ignoreTransferLimit) + { + amount = ielectricitem.getTransferLimit(stack); + } + + NBTTagCompound tags = stack.getTagCompound(); + int charge = tags.getInteger("charge"); + + if (amount > charge) + { + amount = charge; + } + + charge -= amount; + + if (!simulate) + { + tags.setInteger("charge", charge); + stack.itemID = charge > 0 ? ielectricitem.getChargedItemId(stack) : ielectricitem.getEmptyItemId(stack); + + if (stack.getItem() instanceof IElectricItem) + { + ielectricitem = (IElectricItem) stack.getItem(); + + if (stack.getMaxDamage() > 2) + { + if (stack.getItemDamage() + 1 < stack.getMaxDamage()) + stack.setItemDamage(1 + (ielectricitem.getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 2) / ielectricitem.getMaxCharge(stack)); + } + else + { + stack.setItemDamage(0); + } + } + else + { + stack.setItemDamage(0); + } + } + + return amount; + } + else + { + return 0; + } + + } + + public static void breakTool (ItemStack stack, NBTTagCompound tags, Entity entity) + { + tags.getCompoundTag("InfiTool").setBoolean("Broken", true); + if (entity != null) + entity.worldObj.playSound(entity.posX, entity.posY, entity.posZ, "random.break", 1f, 1f, true); + } + + public static void repairTool (ItemStack stack, NBTTagCompound tags) + { + tags.getCompoundTag("InfiTool").setBoolean("Broken", false); + tags.getCompoundTag("InfiTool").setInteger("Damage", 0); + } + + public static DamageSource causePiercingDamage (EntityLivingBase mob) + { + return new PiercingEntityDamage("mob", mob); + } + + public static DamageSource causePlayerPiercingDamage (EntityPlayer player) + { + return new PiercingEntityDamage("player", player); + } + + public static void knockbackEntity (EntityLivingBase living, double boost) + { + living.motionX *= boost; + //living.motionY *= boost/2; + living.motionZ *= boost; + } + + public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random) + { + if (!player.canPlayerEdit(x, y, z, side, stack)) + { + return false; + } + else + { + UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return false; + } + + if (event.getResult() == Result.ALLOW) + { + onBlockChanged(stack, world, 0, x, y, z, player, random); + return true; + } + + int bID = world.getBlockId(x, y, z); + int bIDabove = world.getBlockId(x, y + 1, z); + + if ((side == 0 || bIDabove != 0 || bID != Block.grass.blockID) && bID != Block.dirt.blockID) + { + return false; + } + else + { + Block block = Block.tilledField; + world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getStepSound(), + (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + + if (world.isRemote) + { + return true; + } + else + { + world.setBlock(x, y, z, block.blockID); + onBlockChanged(stack, world, 0, x, y, z, player, random); + return true; + } + } + } + } + + public static void spawnItemAtPlayer (EntityPlayer player, ItemStack stack) + { + EntityItem entityitem = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack); + player.worldObj.spawnEntityInWorld(entityitem); + if (!(player instanceof FakePlayer)) + entityitem.onCollideWithPlayer(player); + /*if (!player.inventory.addItemStackToInventory(stack)) + { + if (!player.worldObj.isRemote) + { + EntityItem entityitem = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack); + player.worldObj.spawnEntityInWorld(entityitem); + entityitem.onCollideWithPlayer(player); + } + } + else + { + player.worldObj.playSoundAtEntity(player, "random.pop", 0.2F, ((random.nextFloat() - random.nextFloat()) * 0.7F + 1.0F) * 2.0F); + }*/ + } + + /* Ranged weapons */ + + public static void forceAddToInv (EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag) + { + ItemStack itemstack1 = entityplayer.inventory.getStackInSlot(i); + entityplayer.inventory.setInventorySlotContents(i, itemstack); + if (itemstack1 != null) + { + addToInv(entityplayer, itemstack1, flag); + } + } + + public static boolean addToInv (EntityPlayer entityplayer, ItemStack itemstack, boolean flag) + { + return addToInv(entityplayer, itemstack, entityplayer.inventory.currentItem, flag); + } + + public static boolean addToInv (EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag) + { + ItemStack itemstack1 = entityplayer.inventory.getStackInSlot(i); + boolean flag1; + if (itemstack1 == null) + { + entityplayer.inventory.setInventorySlotContents(i, itemstack); + flag1 = true; + } + else + { + flag1 = entityplayer.inventory.addItemStackToInventory(itemstack); + } + if (flag && !flag1) + { + addItemStackToWorld(entityplayer.worldObj, (float) Math.floor(entityplayer.posX), (float) Math.floor(entityplayer.posY), (float) Math.floor(entityplayer.posZ), itemstack); + return true; + } + else + { + return flag1; + } + } + + public static EntityItem addItemStackToWorld (World world, float f, float f1, float f2, ItemStack itemstack) + { + return addItemStackToWorld(world, f, f1, f2, itemstack, false); + } + + public static EntityItem addItemStackToWorld (World world, float f, float f1, float f2, ItemStack itemstack, boolean flag) + { + EntityItem entityitem; + if (flag) + { + entityitem = new EntityItem(world, f, f1, f2, itemstack); + } + else + { + float f3 = 0.7F; + float f4 = random.nextFloat() * f3 + (1.0F - f3) * 0.5F; + float f5 = 1.2F; + float f6 = random.nextFloat() * f3 + (1.0F - f3) * 0.5F; + entityitem = new EntityItem(world, f + f4, f1 + f5, f2 + f6, itemstack); + } + entityitem.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(entityitem); + return entityitem; + } + + public static MovingObjectPosition raytraceFromEntity (World world, Entity player, boolean par3, double range) + { + float f = 1.0F; + float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; + float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; + double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f; + double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f + 1.62D - (double) player.yOffset; + double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f; + Vec3 vec3 = world.getWorldVec3Pool().getVecFromPool(d0, d1, d2); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; + double d3 = range; + if (player instanceof EntityPlayerMP) + { + d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); + } + Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); + return world.rayTraceBlocks_do_do(vec3, vec31, par3, !par3); + } +} diff --git a/tconstruct/library/tools/ArrowMaterial.java b/tconstruct/library/tools/ArrowMaterial.java new file mode 100644 index 00000000..884e3edc --- /dev/null +++ b/tconstruct/library/tools/ArrowMaterial.java @@ -0,0 +1,15 @@ +package tconstruct.library.tools; + +public class ArrowMaterial +{ + public final float mass; + public final float breakChance; + public final float accuracy; + + public ArrowMaterial(float weight, float breakChance, float accuracy) + { + this.mass = weight; + this.breakChance = breakChance; + this.accuracy = accuracy; + } +} diff --git a/tconstruct/library/tools/BowBase.java b/tconstruct/library/tools/BowBase.java new file mode 100644 index 00000000..4550bea9 --- /dev/null +++ b/tconstruct/library/tools/BowBase.java @@ -0,0 +1,780 @@ +package tconstruct.library.tools; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import tconstruct.common.TContent; +import tconstruct.entity.projectile.ArrowEntity; +import tconstruct.library.crafting.ToolBuilder; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.ArrowLooseEvent; +import net.minecraftforge.event.entity.player.ArrowNockEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class BowBase extends ToolCore +{ + public BowBase(int itemID) + { + super(itemID, 0); + } + + public int durabilityTypeAccessory () + { + return 2; + } + + /*@SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 7; + }*/ + + /* Bow usage */ + public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int useRemaining) + { + int time = this.getMaxItemUseDuration(stack) - useRemaining; + + ArrowLooseEvent event = new ArrowLooseEvent(player, stack, time); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) + { + return; + } + time = event.charge; + + boolean creative = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0; + int slotID = getInventorySlotContainItem(TContent.arrow.itemID, player.inventory); + int arrowID = getInventorySlotContainItem(Item.arrow.itemID, player.inventory); + int arrowState = 0; + ItemStack tinkerArrow = null; + if (slotID != -1) + tinkerArrow = player.inventory.getStackInSlot(slotID); + + if (creative || tinkerArrow != null || arrowID != -1) + { + NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool"); + float drawTime = toolTag.getInteger("DrawSpeed"); + float flightSpeed = toolTag.getFloat("FlightSpeed"); + float speedBase = (float) time / drawTime; + speedBase = (speedBase * speedBase + speedBase * 2.0F) / 3.0F; + + if ((double) speedBase < 0.1D) + { + return; + } + + if (speedBase > flightSpeed) + { + speedBase = flightSpeed; + } + + EntityArrow arrowEntity = null; + //if (tinkerArrow != null) + if (slotID != -1 && (arrowID == -1 || slotID < arrowID)) + { + ItemStack arrowStack = tinkerArrow.copy(); + arrowStack.stackSize = 1; + arrowEntity = new ArrowEntity(world, player, speedBase * 2.0F, arrowStack); + } + else + { + arrowEntity = new EntityArrow(world, player, speedBase * 2.0F); + } + + if (speedBase >= 1.0F) + { + arrowEntity.setIsCritical(true); + } + + int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack); + + if (var9 > 0) + { + arrowEntity.setDamage(arrowEntity.getDamage() + (double) var9 * 0.5D + 0.5D); + } + + int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack); + + if (slotID != -1 && (arrowID == -1 || slotID < arrowID)) + ((ArrowEntity) arrowEntity).setKnockbackModStrength(toolTag.getFloat("Knockback")); + //var10 += toolTag.getFloat("Knockback"); + + if (var10 > 0) + { + arrowEntity.setKnockbackStrength(var10); + } + + if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0) + { + arrowEntity.setFire(100); + } + + int reinforced = 0; + + if (toolTag.hasKey("Unbreaking")) + reinforced = toolTag.getInteger("Unbreaking"); + + if (random.nextInt(10) < 10 - reinforced) + { + AbilityHelper.damageTool(stack, 1, player, false); + } + world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + speedBase * 0.5F); + + if (creative) + { + arrowEntity.canBePickedUp = 2; + } + else + { + //if (tinkerArrow != null) + if (slotID != -1 && (arrowID == -1 || slotID < arrowID)) + { + player.inventory.consumeInventoryItem(TContent.arrow.itemID); + } + else + { + player.inventory.consumeInventoryItem(Item.arrow.itemID); + } + } + + if (!world.isRemote) + { + world.spawnEntityInWorld(arrowEntity); + } + } + } + + int getInventorySlotContainItem (int itemID, InventoryPlayer inventory) + { + for (int j = 0; j < inventory.mainInventory.length; ++j) + { + if (inventory.mainInventory[j] != null && inventory.mainInventory[j].itemID == itemID) + { + return j; + } + } + + return -1; + } + + public ItemStack onFoodEaten (ItemStack stack, World par2World, EntityPlayer par3EntityPlayer) + { + return stack; + } + + /** + * How long it takes to use or consume an item + */ + public int getMaxItemUseDuration (ItemStack par1ItemStack) + { + return 72000; + } + + /** + * returns the action that specifies what animation to play when the items is being used + */ + public EnumAction getItemUseAction (ItemStack par1ItemStack) + { + return EnumAction.bow; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick (ItemStack stack, World par2World, EntityPlayer player) + { + if (stack.hasTagCompound()) + { + NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool"); + if (!toolTag.getBoolean("Broken")) + { + ArrowNockEvent event = new ArrowNockEvent(player, stack); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) + { + return event.result; + } + + if (player.capabilities.isCreativeMode || player.inventory.hasItem(Item.arrow.itemID) || player.inventory.hasItem(TContent.arrow.itemID)) + { + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + } + } + } + + return stack; + } + + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ) + { + return false; + } + + @SideOnly(Side.CLIENT) + @Override + public boolean requiresMultipleRenderPasses () + { + return true; + } + + /* Rendering */ + @Override + public void registerIcons (IconRegister iconRegister) + { + super.registerIcons(iconRegister); + headIcons1.clear(); + handleIcons1.clear(); + accessoryIcons1.clear(); + extraIcons1.clear(); + effectIcons1.clear(); + Iterator iterOne = headStrings.entrySet().iterator(); + while (iterOne.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterOne.next(); + headIcons1.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_1")); + } + + iterOne = handleStrings.entrySet().iterator(); + while (iterOne.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterOne.next(); + handleIcons1.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_1")); + } + + if (getPartAmount() > 2) + { + iterOne = accessoryStrings.entrySet().iterator(); + while (iterOne.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterOne.next(); + accessoryIcons1.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_1")); + } + } + + if (getPartAmount() > 3) + { + iterOne = extraStrings.entrySet().iterator(); + while (iterOne.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterOne.next(); + extraIcons1.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_1")); + } + } + + iterOne = effectStrings.entrySet().iterator(); + while (iterOne.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterOne.next(); + effectIcons1.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_1")); + } + + headIcons2.clear(); + handleIcons2.clear(); + accessoryIcons2.clear(); + extraIcons2.clear(); + effectIcons2.clear(); + Iterator iterTwo = headStrings.entrySet().iterator(); + while (iterTwo.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterTwo.next(); + headIcons2.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_2")); + } + + iterTwo = handleStrings.entrySet().iterator(); + while (iterTwo.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterTwo.next(); + handleIcons2.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_2")); + } + + if (getPartAmount() > 2) + { + iterTwo = accessoryStrings.entrySet().iterator(); + while (iterTwo.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterTwo.next(); + accessoryIcons2.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_2")); + } + } + + if (getPartAmount() > 3) + { + iterTwo = extraStrings.entrySet().iterator(); + while (iterTwo.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterTwo.next(); + extraIcons2.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_2")); + } + } + + iterTwo = effectStrings.entrySet().iterator(); + while (iterTwo.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterTwo.next(); + effectIcons2.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_2")); + } + + headIcons3.clear(); + handleIcons3.clear(); + accessoryIcons3.clear(); + extraIcons3.clear(); + effectIcons3.clear(); + Iterator iterThree = headStrings.entrySet().iterator(); + while (iterThree.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterThree.next(); + headIcons3.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_3")); + } + + iterThree = handleStrings.entrySet().iterator(); + while (iterThree.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterThree.next(); + handleIcons3.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_3")); + } + + if (getPartAmount() > 2) + { + iterThree = accessoryStrings.entrySet().iterator(); + while (iterThree.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterThree.next(); + accessoryIcons3.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_3")); + } + } + + if (getPartAmount() > 3) + { + iterThree = extraStrings.entrySet().iterator(); + while (iterThree.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterThree.next(); + extraIcons3.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_3")); + } + } + + iterThree = effectStrings.entrySet().iterator(); + while (iterThree.hasNext()) + { + Map.Entry pairs = (Map.Entry) iterThree.next(); + effectIcons3.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue() + "_3")); + } + + registerArrows(iconRegister); + } + + void registerArrows (IconRegister iconRegister) + { + arrow1 = iconRegister.registerIcon("tinker:" + getDefaultFolder() + "/arrow_1"); + arrow2 = iconRegister.registerIcon("tinker:" + getDefaultFolder() + "/arrow_2"); + arrow3 = iconRegister.registerIcon("tinker:" + getDefaultFolder() + "/arrow_3"); + } + + @Override + public Icon getIcon (ItemStack stack, int renderPass) + { + NBTTagCompound tags = stack.getTagCompound(); + + if (tags != null) + { + tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (renderPass < getPartAmount()) + { + if (renderPass == 0) // Handle + { + if (tags.getBoolean("Broken")) + return (brokenIcons.get(tags.getInteger("RenderHandle"))); + return handleIcons.get(tags.getInteger("RenderHandle")); + } + + else if (renderPass == 1) // Head + { + return (headIcons.get(tags.getInteger("RenderHead"))); + } + + else if (renderPass == 2) // Accessory + { + return (accessoryIcons.get(tags.getInteger("RenderAccessory"))); + } + + else if (renderPass == 3) // Extra + { + return (extraIcons.get(tags.getInteger("RenderExtra"))); + } + } + + else + { + if (renderPass == getPartAmount()) + { + if (tags.hasKey("Effect1")) + return (effectIcons.get(tags.getInteger("Effect1"))); + } + + else if (renderPass == getPartAmount() + 1) + { + if (tags.hasKey("Effect2")) + return (effectIcons.get(tags.getInteger("Effect2"))); + } + + else if (renderPass == getPartAmount() + 2) + { + if (tags.hasKey("Effect3")) + return (effectIcons.get(tags.getInteger("Effect3"))); + } + + else if (renderPass == getPartAmount() + 3) + { + if (tags.hasKey("Effect4")) + return (effectIcons.get(tags.getInteger("Effect4"))); + } + + else if (renderPass == getPartAmount() + 4) + { + if (tags.hasKey("Effect5")) + return (effectIcons.get(tags.getInteger("Effect5"))); + } + + else if (renderPass == getPartAmount() + 5) + { + if (tags.hasKey("Effect6")) + return (effectIcons.get(tags.getInteger("Effect6"))); + } + } + return blankSprite; + } + return emptyIcon; + } + + /* Animations */ + @Override + public void registerPartPaths (int index, String[] location) + { + headStrings.put(index, location[0]); + //brokenHeadStrings.put(index, location[1]); + //handleStrings.put(index, location[2]); + if (location.length > 3) + accessoryStrings.put(index, location[3]); + if (location.length > 4) + extraStrings.put(index, location[4]); + } + + @Override + public void registerAlternatePartPaths (int index, String[] location) + { + brokenPartStrings.put(index, location[1]); + handleStrings.put(index, location[2]); + } + + public Icon arrow1; + public Icon arrow2; + public Icon arrow3; + + public HashMap headIcons1 = new HashMap(); + public HashMap handleIcons1 = new HashMap(); + public HashMap accessoryIcons1 = new HashMap(); + public HashMap extraIcons1 = new HashMap(); + public HashMap effectIcons1 = new HashMap(); + + public HashMap headIcons2 = new HashMap(); + public HashMap handleIcons2 = new HashMap(); + public HashMap accessoryIcons2 = new HashMap(); + public HashMap extraIcons2 = new HashMap(); + public HashMap effectIcons2 = new HashMap(); + + public HashMap headIcons3 = new HashMap(); + public HashMap handleIcons3 = new HashMap(); + public HashMap accessoryIcons3 = new HashMap(); + public HashMap extraIcons3 = new HashMap(); + public HashMap effectIcons3 = new HashMap(); + + @Override + public Icon getIcon (ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) + { + int useTime = stack.getMaxItemUseDuration() - useRemaining; + if (!stack.hasTagCompound()) + return emptyIcon; + + NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool"); + int drawTime = toolTag.getInteger("DrawSpeed"); + float flightSpeed = toolTag.getFloat("FlightSpeed"); + drawTime *= flightSpeed; + if (useTime >= drawTime - 2) + { + return getIcon3(stack, renderPass); + } + if (useTime >= (drawTime * 2 / 3)) + { + return getIcon2(stack, renderPass); + } + return getIcon1(stack, renderPass); + } + + public Icon getIcon1 (ItemStack stack, int renderPass) + { + NBTTagCompound tags = stack.getTagCompound(); + + if (tags != null) + { + tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (renderPass < getPartAmount()) + { + if (renderPass == 0) // Handle + { + return handleIcons1.get(tags.getInteger("RenderHandle")); + } + + else if (renderPass == 1) // Head + { + return (headIcons1.get(tags.getInteger("RenderHead"))); + } + + else if (renderPass == 2) // Accessory + { + return (accessoryIcons1.get(tags.getInteger("RenderAccessory"))); + } + + else if (renderPass == 3) // Extra + { + return (extraIcons1.get(tags.getInteger("RenderExtra"))); + } + } + + else + { + if (renderPass == getPartAmount()) + { + if (tags.hasKey("Effect1")) + return (effectIcons1.get(tags.getInteger("Effect1"))); + } + + else if (renderPass == getPartAmount() + 1) + { + if (tags.hasKey("Effect2")) + return (effectIcons1.get(tags.getInteger("Effect2"))); + } + + else if (renderPass == getPartAmount() + 2) + { + if (tags.hasKey("Effect3")) + return (effectIcons1.get(tags.getInteger("Effect3"))); + } + + else if (renderPass == getPartAmount() + 3) + { + if (tags.hasKey("Effect4")) + return (effectIcons1.get(tags.getInteger("Effect4"))); + } + + else if (renderPass == getPartAmount() + 4) + { + if (tags.hasKey("Effect5")) + return (effectIcons1.get(tags.getInteger("Effect5"))); + } + + else if (renderPass == getPartAmount() + 5) + { + if (tags.hasKey("Effect6")) + return (effectIcons1.get(tags.getInteger("Effect6"))); + } + else + { + return arrow1; + } + } + return blankSprite; + } + return emptyIcon; + } + + public Icon getIcon2 (ItemStack stack, int renderPass) + { + NBTTagCompound tags = stack.getTagCompound(); + + if (tags != null) + { + tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (renderPass < getPartAmount()) + { + if (renderPass == 0) // Handle + { + return handleIcons2.get(tags.getInteger("RenderHandle")); + } + + else if (renderPass == 1) // Head + { + return (headIcons2.get(tags.getInteger("RenderHead"))); + } + + else if (renderPass == 2) // Accessory + { + return (accessoryIcons2.get(tags.getInteger("RenderAccessory"))); + } + + else if (renderPass == 3) // Extra + { + return (extraIcons2.get(tags.getInteger("RenderExtra"))); + } + } + + else + { + if (renderPass == getPartAmount()) + { + if (tags.hasKey("Effect1")) + return (effectIcons2.get(tags.getInteger("Effect1"))); + } + + else if (renderPass == getPartAmount() + 1) + { + if (tags.hasKey("Effect2")) + return (effectIcons2.get(tags.getInteger("Effect2"))); + } + + else if (renderPass == getPartAmount() + 2) + { + if (tags.hasKey("Effect3")) + return (effectIcons2.get(tags.getInteger("Effect3"))); + } + + else if (renderPass == getPartAmount() + 3) + { + if (tags.hasKey("Effect4")) + return (effectIcons2.get(tags.getInteger("Effect4"))); + } + + else if (renderPass == getPartAmount() + 4) + { + if (tags.hasKey("Effect5")) + return (effectIcons2.get(tags.getInteger("Effect5"))); + } + + else if (renderPass == getPartAmount() + 5) + { + if (tags.hasKey("Effect6")) + return (effectIcons2.get(tags.getInteger("Effect6"))); + } + else + { + return arrow2; + } + } + return blankSprite; + } + return emptyIcon; + } + + public Icon getIcon3 (ItemStack stack, int renderPass) + { + NBTTagCompound tags = stack.getTagCompound(); + + if (tags != null) + { + tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (renderPass < getPartAmount()) + { + if (renderPass == 0) // Handle + { + return handleIcons3.get(tags.getInteger("RenderHandle")); + } + + else if (renderPass == 1) // Head + { + return (headIcons3.get(tags.getInteger("RenderHead"))); + } + + else if (renderPass == 2) // Accessory + { + return (accessoryIcons3.get(tags.getInteger("RenderAccessory"))); + } + + else if (renderPass == 3) // Extra + { + return (extraIcons3.get(tags.getInteger("RenderExtra"))); + } + } + + else + { + if (renderPass == getPartAmount()) + { + if (tags.hasKey("Effect1")) + return (effectIcons3.get(tags.getInteger("Effect1"))); + } + + else if (renderPass == getPartAmount() + 1) + { + if (tags.hasKey("Effect2")) + return (effectIcons3.get(tags.getInteger("Effect2"))); + } + + else if (renderPass == getPartAmount() + 2) + { + if (tags.hasKey("Effect3")) + return (effectIcons3.get(tags.getInteger("Effect3"))); + } + + else if (renderPass == getPartAmount() + 3) + { + if (tags.hasKey("Effect4")) + return (effectIcons3.get(tags.getInteger("Effect4"))); + } + + else if (renderPass == getPartAmount() + 4) + { + if (tags.hasKey("Effect5")) + return (effectIcons3.get(tags.getInteger("Effect5"))); + } + + else if (renderPass == getPartAmount() + 5) + { + if (tags.hasKey("Effect6")) + return (effectIcons3.get(tags.getInteger("Effect6"))); + } + else + { + return arrow3; + } + } + return blankSprite; + } + return emptyIcon; + } + + @Override + public void buildTool (int id, String name, List list) + { + Item accessory = getAccessoryItem(); + ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, id) : null; + Item extra = getExtraItem(); + ItemStack extraStack = extra != null ? new ItemStack(getExtraItem(), 1, id) : null; + ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), new ItemStack(getHandleItem(), 1, 0), accessoryStack, extraStack, name + getToolName()); + if (tool == null) + { + System.out.println("Creative builder failed tool for " + name + this.getToolName()); + System.out.println("Make sure you do not have item ID conflicts"); + } + else + { + tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true); + list.add(tool); + } + } +} diff --git a/tconstruct/library/tools/BowMaterial.java b/tconstruct/library/tools/BowMaterial.java new file mode 100644 index 00000000..89d0c80e --- /dev/null +++ b/tconstruct/library/tools/BowMaterial.java @@ -0,0 +1,15 @@ +package tconstruct.library.tools; + +public class BowMaterial +{ + public final int durability; + public final int drawspeed; + public final float flightSpeedMax; + + public BowMaterial(int durability, int drawspeed, float attack) + { + this.durability = durability; + this.drawspeed = drawspeed; + this.flightSpeedMax = attack; + } +} diff --git a/tconstruct/library/tools/BowstringMaterial.java b/tconstruct/library/tools/BowstringMaterial.java new file mode 100644 index 00000000..6a2443f9 --- /dev/null +++ b/tconstruct/library/tools/BowstringMaterial.java @@ -0,0 +1,18 @@ +package tconstruct.library.tools; + +import net.minecraft.item.ItemStack; + +public class BowstringMaterial extends CustomMaterial +{ + public final float durabilityModifier; + public final float drawspeedModifier; + public final float flightSpeedModifier; + + public BowstringMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float durability, float drawspeed, float flightspeed) + { + super(materialID, value, input, craftingItem); + this.durabilityModifier = durability; + this.drawspeedModifier = drawspeed; + this.flightSpeedModifier = flightspeed; + } +} diff --git a/tconstruct/library/tools/CustomMaterial.java b/tconstruct/library/tools/CustomMaterial.java new file mode 100644 index 00000000..51147255 --- /dev/null +++ b/tconstruct/library/tools/CustomMaterial.java @@ -0,0 +1,26 @@ +package tconstruct.library.tools; + +import net.minecraft.item.ItemStack; + +public abstract class CustomMaterial +{ + public final int materialID; + public final int value; + public final ItemStack input; + public final ItemStack craftingItem; + + public CustomMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem) + { + this.materialID = materialID; + this.value = value; + this.input = input; + this.craftingItem = craftingItem; + } + + /*public boolean matches(ItemStack input, ItemStack pattern) + { + if (ItemStack.areItemStacksEqual(this.input, input) && ItemStack.areItemStacksEqual(this.craftingPattern, pattern)) + return true; + return false; + }*/ +} diff --git a/tconstruct/library/tools/DualHarvestTool.java b/tconstruct/library/tools/DualHarvestTool.java new file mode 100644 index 00000000..93550acf --- /dev/null +++ b/tconstruct/library/tools/DualHarvestTool.java @@ -0,0 +1,132 @@ +package tconstruct.library.tools; + +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; + +/* Base class for harvest tools with each head having a different purpose */ + +public abstract class DualHarvestTool extends HarvestTool +{ + public DualHarvestTool(int itemID, int baseDamage) + { + super(itemID, baseDamage); + } + + @Override + public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + World world = player.worldObj; + int bID = player.worldObj.getBlockId(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + Block block = Block.blocksList[bID]; + if (block == null || bID < 1) + return false; + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int shlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getSecondHarvestType()); + + if (hlvl <= tags.getInteger("HarvestLevel") && shlvl <= tags.getInteger("HarvestLevel2")) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, x, y, z, player)) + cancelHarvest = true; + } + + return cancelHarvest; + } + else + { + if (!player.capabilities.isCreativeMode) + onBlockDestroyed(stack, world, bID, x, y, z, player); + world.setBlockToAir(x, y, z); + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, bID + (meta << 12)); + return true; + } + } + + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return 0.1f; + + Material[] materials = getEffectiveMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float speed = tags.getInteger("MiningSpeed"); + speed /= 100f; + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); + + float shoddy = tags.getFloat("Shoddy"); + speed += shoddy * durability / 100f; + + if (hlvl <= tags.getInteger("HarvestLevel")) + return speed; + return 0.1f; + } + } + materials = getEffectiveSecondaryMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float speed = tags.getInteger("MiningSpeed2"); + speed /= 100f; + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); + + float shoddy = tags.getFloat("Shoddy"); + speed += shoddy * durability / 100f; + + if (hlvl <= tags.getInteger("HarvestLevel2")) + return speed; + return 0.1f; + } + } + return super.getStrVsBlock(stack, block, meta); + } + + public boolean canHarvestBlock (Block block) + { + if (block.blockMaterial.isToolNotRequired()) + { + return true; + } + for (Material m : getEffectiveMaterials()) + { + if (m == block.blockMaterial) + return true; + } + for (Material m : getEffectiveSecondaryMaterials()) + { + if (m == block.blockMaterial) + return true; + } + return false; + } + + @Override + public String[] toolCategories () + { + return new String[] { "harvest", "dualharvest" }; + } + + protected abstract Material[] getEffectiveSecondaryMaterials (); + + protected abstract String getSecondHarvestType (); +} diff --git a/tconstruct/library/tools/FletchingMaterial.java b/tconstruct/library/tools/FletchingMaterial.java new file mode 100644 index 00000000..5383b39b --- /dev/null +++ b/tconstruct/library/tools/FletchingMaterial.java @@ -0,0 +1,18 @@ +package tconstruct.library.tools; + +import net.minecraft.item.ItemStack; + +public class FletchingMaterial extends CustomMaterial +{ + public final float accuracy; + public final float breakChance; + public final float mass; + + public FletchingMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float accuracy, float breakChance, float mass) + { + super(materialID, value, input, craftingItem); + this.accuracy = accuracy; + this.breakChance = breakChance; + this.mass = mass; + } +} diff --git a/tconstruct/library/tools/HarvestTool.java b/tconstruct/library/tools/HarvestTool.java new file mode 100644 index 00000000..514cbf43 --- /dev/null +++ b/tconstruct/library/tools/HarvestTool.java @@ -0,0 +1,128 @@ +package tconstruct.library.tools; + +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; + +/* Base class for tools that should be harvesting blocks */ + +public abstract class HarvestTool extends ToolCore +{ + public HarvestTool(int itemID, int baseDamage) + { + super(itemID, baseDamage); + } + + @Override + public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + World world = player.worldObj; + int bID = player.worldObj.getBlockId(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + Block block = Block.blocksList[bID]; + if (block == null || bID < 1) + return false; + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + + if (hlvl <= tags.getInteger("HarvestLevel")) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, x, y, z, player)) + cancelHarvest = true; + } + return cancelHarvest; + } + else + { + world.setBlockToAir(x, y, z); + if (!player.capabilities.isCreativeMode) + onBlockDestroyed(stack, world, bID, x, y, z, player); + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, bID + (meta << 12)); + return true; + } + } + + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + if (!stack.hasTagCompound()) + return 1.0f; + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return 0.1f; + + Material[] materials = getEffectiveMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } + + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } + + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + float trueSpeed = mineSpeed / (heads * 100f); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); + + float stonebound = tags.getFloat("Shoddy"); + float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; + trueSpeed += bonusLog; + + if (hlvl <= tags.getInteger("HarvestLevel")) + return trueSpeed; + return 0.1f; + } + } + return super.getStrVsBlock(stack, block, meta); + } + + public boolean canHarvestBlock (Block block) + { + if (block.blockMaterial.isToolNotRequired()) + { + return true; + } + for (Material m : getEffectiveMaterials()) + { + if (m == block.blockMaterial) + return true; + } + return false; + } + + @Override + public String[] toolCategories () + { + return new String[] { "harvest" }; + } + + protected abstract Material[] getEffectiveMaterials (); + + protected abstract String getHarvestType (); +} diff --git a/tconstruct/library/tools/ToolCore.java b/tconstruct/library/tools/ToolCore.java new file mode 100644 index 00000000..ab5d122e --- /dev/null +++ b/tconstruct/library/tools/ToolCore.java @@ -0,0 +1,929 @@ +package tconstruct.library.tools; + +import ic2.api.item.IBoxable; +import ic2.api.item.ICustomElectricItem; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.ToolBuilder; + + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** NBTTags + * Main tag - InfiTool + * @see ToolBuilder + * + * Required: + * Head: Base and render tag, above the handle + * Handle: Base and render tag, bottom layer + * + * Damage: Replacement for metadata + * MaxDamage: ItemStacks only read setMaxDamage() + * Broken: Represents whether the tool is broken (boolean) + * Attack: How much damage a mob will take + * MiningSpeed: The speed at which a tool mines + * + * Others: + * Accessory: Base and tag, above head. Sword guards, binding, etc + * Effects: Render tag, top layer. Fancy effects like moss or diamond edge. + * Render order: Handle > Head > Accessory > Effect1 > Effect2 > Effect3 > etc + * Unbreaking: Reinforced in-game, 10% chance to not use durability per level + * Stonebound: Mines faster as the tool takes damage, but has less attack + * Spiny: Opposite of stonebound + * + * Modifiers have their own tags. + * @see ToolMod + */ + +public abstract class ToolCore extends Item implements ICustomElectricItem, IBoxable +{ + protected Random random = new Random(); + protected int damageVsEntity; + public static Icon blankSprite; + public static Icon emptyIcon; + + public ToolCore(int id, int baseDamage) + { + super(id); + this.maxStackSize = 1; + this.setMaxDamage(100); + this.setUnlocalizedName("InfiTool"); + this.setCreativeTab(TConstructRegistry.toolTab); + damageVsEntity = baseDamage; + TConstructRegistry.addToolMapping(this); + setNoRepair(); + canRepair = false; + } + + /** Determines crafting behavior with regards to durability + * 0: None + * 1: Adds handle modifier + * 2: Averages part with the rest of the tool (head) + * @return type + */ + + public int durabilityTypeHandle () + { + return 1; + } + + public int durabilityTypeAccessory () + { + return 0; + } + + public int durabilityTypeExtra () + { + return 0; + } + + public int getModifierAmount () + { + return 3; + } + + public String getToolName () + { + return this.getClass().getSimpleName(); + } + + /* Rendering */ + + public HashMap headIcons = new HashMap(); + public HashMap brokenIcons = new HashMap(); + public HashMap handleIcons = new HashMap(); + public HashMap accessoryIcons = new HashMap(); + public HashMap effectIcons = new HashMap(); + public HashMap extraIcons = new HashMap(); + + //Not liking this + public HashMap headStrings = new HashMap(); + public HashMap brokenPartStrings = new HashMap(); + public HashMap handleStrings = new HashMap(); + public HashMap accessoryStrings = new HashMap(); + public HashMap effectStrings = new HashMap(); + public HashMap extraStrings = new HashMap(); + + @SideOnly(Side.CLIENT) + @Override + public boolean requiresMultipleRenderPasses () + { + return true; + } + + @SideOnly(Side.CLIENT) + @Override + public int getRenderPasses (int metadata) + { + return 9; + } + + //Override me please! + public int getPartAmount () + { + return 3; + } + + public abstract String getIconSuffix (int partType); + + public abstract String getEffectSuffix (); + + public abstract String getDefaultFolder (); + + public void registerPartPaths (int index, String[] location) + { + headStrings.put(index, location[0]); + brokenPartStrings.put(index, location[1]); + handleStrings.put(index, location[2]); + if (location.length > 3) + accessoryStrings.put(index, location[3]); + if (location.length > 4) + extraStrings.put(index, location[4]); + } + + public void registerAlternatePartPaths (int index, String[] location) + { + + } + + public void registerEffectPath (int index, String location) + { + effectStrings.put(index, location); + } + + @Override + public void registerIcons (IconRegister iconRegister) + { + headIcons.clear(); + brokenIcons.clear(); + handleIcons.clear(); + accessoryIcons.clear(); + extraIcons.clear(); + effectIcons.clear(); + Iterator iter = headStrings.entrySet().iterator(); + while (iter.hasNext()) + { + Map.Entry pairs = (Map.Entry) iter.next(); + headIcons.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue())); + } + + iter = brokenPartStrings.entrySet().iterator(); + while (iter.hasNext()) + { + Map.Entry pairs = (Map.Entry) iter.next(); + brokenIcons.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue())); + } + + iter = handleStrings.entrySet().iterator(); + while (iter.hasNext()) + { + Map.Entry pairs = (Map.Entry) iter.next(); + handleIcons.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue())); + } + + if (getPartAmount() > 2) + { + iter = accessoryStrings.entrySet().iterator(); + while (iter.hasNext()) + { + Map.Entry pairs = (Map.Entry) iter.next(); + accessoryIcons.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue())); + } + } + + if (getPartAmount() > 3) + { + iter = extraStrings.entrySet().iterator(); + while (iter.hasNext()) + { + Map.Entry pairs = (Map.Entry) iter.next(); + extraIcons.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue())); + } + } + + iter = effectStrings.entrySet().iterator(); + while (iter.hasNext()) + { + Map.Entry pairs = (Map.Entry) iter.next(); + effectIcons.put((Integer) pairs.getKey(), iconRegister.registerIcon((String) pairs.getValue())); + } + + emptyIcon = iconRegister.registerIcon("tinker:blankface"); + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIconFromDamage (int meta) + { + return blankSprite; + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon (ItemStack stack, int renderPass) + { + NBTTagCompound tags = stack.getTagCompound(); + + if (tags != null) + { + tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (renderPass < getPartAmount()) + { + if (renderPass == 0) // Handle + { + return handleIcons.get(tags.getInteger("RenderHandle")); + } + + else if (renderPass == 1) // Head + { + if (tags.getBoolean("Broken")) + return (brokenIcons.get(tags.getInteger("RenderHead"))); + else + return (headIcons.get(tags.getInteger("RenderHead"))); + } + + else if (renderPass == 2) // Accessory + { + return (accessoryIcons.get(tags.getInteger("RenderAccessory"))); + } + + else if (renderPass == 3) // Extra + { + return (extraIcons.get(tags.getInteger("RenderExtra"))); + } + } + + else + { + if (renderPass == getPartAmount()) + { + if (tags.hasKey("Effect1")) + return (effectIcons.get(tags.getInteger("Effect1"))); + } + + else if (renderPass == getPartAmount() + 1) + { + if (tags.hasKey("Effect2")) + return (effectIcons.get(tags.getInteger("Effect2"))); + } + + else if (renderPass == getPartAmount() + 2) + { + if (tags.hasKey("Effect3")) + return (effectIcons.get(tags.getInteger("Effect3"))); + } + + else if (renderPass == getPartAmount() + 3) + { + if (tags.hasKey("Effect4")) + return (effectIcons.get(tags.getInteger("Effect4"))); + } + + else if (renderPass == getPartAmount() + 4) + { + if (tags.hasKey("Effect5")) + return (effectIcons.get(tags.getInteger("Effect5"))); + } + + else if (renderPass == getPartAmount() + 5) + { + if (tags.hasKey("Effect6")) + return (effectIcons.get(tags.getInteger("Effect6"))); + } + } + return blankSprite; + } + return emptyIcon; + } + + /* Tags and information about the tool */ + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + { + if (!stack.hasTagCompound()) + return; + + NBTTagCompound tags = stack.getTagCompound(); + if (tags.hasKey("charge")) + { + String color = ""; + //double joules = this.getJoules(stack); + int power = tags.getInteger("charge"); + + if (power != 0) + { + if (power <= this.getMaxCharge(stack) / 3) + color = "\u00a74"; + else if (power > this.getMaxCharge(stack) * 2 / 3) + color = "\u00a72"; + else + color = "\u00a76"; + } + + String charge = new StringBuilder().append(color).append(tags.getInteger("charge")).append("/").append(getMaxCharge(stack)).append(" EU").toString(); + list.add(charge); + } + if (tags.hasKey("InfiTool")) + { + boolean broken = tags.getCompoundTag("InfiTool").getBoolean("Broken"); + if (broken) + list.add("\u00A7oBroken"); + else + { + int head = tags.getCompoundTag("InfiTool").getInteger("Head"); + int handle = tags.getCompoundTag("InfiTool").getInteger("Handle"); + int binding = tags.getCompoundTag("InfiTool").getInteger("Accessory"); + int extra = tags.getCompoundTag("InfiTool").getInteger("Extra"); + + String headName = getAbilityNameForType(head); + if (!headName.equals("")) + list.add(getStyleForType(head) + headName); + + String handleName = getAbilityNameForType(handle); + if (!handleName.equals("") && handle != head) + list.add(getStyleForType(handle) + handleName); + + if (getPartAmount() >= 3) + { + String bindingName = getAbilityNameForType(binding); + if (!bindingName.equals("") && binding != head && binding != handle) + list.add(getStyleForType(binding) + bindingName); + } + + if (getPartAmount() >= 4) + { + String extraName = getAbilityNameForType(extra); + if (!extraName.equals("") && extra != head && extra != handle && extra != binding) + list.add(getStyleForType(extra) + extraName); + } + + int unbreaking = tags.getCompoundTag("InfiTool").getInteger("Unbreaking"); + String reinforced = getReinforcedName(head, handle, binding, extra, unbreaking); + if (!reinforced.equals("")) + list.add(reinforced); + + boolean displayToolTips = true; + int tipNum = 0; + while (displayToolTips) + { + tipNum++; + String tooltip = "Tooltip" + tipNum; + if (tags.getCompoundTag("InfiTool").hasKey(tooltip)) + { + String tipName = tags.getCompoundTag("InfiTool").getString(tooltip); + if (!tipName.equals("")) + list.add(tipName); + } + else + displayToolTips = false; + } + } + } + } + + public static String getStyleForType (int type) + { + return TConstructRegistry.getMaterial(type).style(); + } + + public String getAbilityNameForType (int type) + { + return TConstructRegistry.getMaterial(type).ability(); + } + + public String getReinforcedName (int head, int handle, int accessory, int extra, int unbreaking) + { + ToolMaterial headMat = TConstructRegistry.getMaterial(head); + ToolMaterial handleMat = TConstructRegistry.getMaterial(handle); + ToolMaterial accessoryMat = TConstructRegistry.getMaterial(accessory); + ToolMaterial extraMat = TConstructRegistry.getMaterial(extra); + + int reinforced = 0; + String style = ""; + int current = headMat.reinforced(); + if (current > 0) + { + style = headMat.style(); + reinforced = current; + } + current = handleMat.reinforced(); + if (current > 0 && current > reinforced) + { + style = handleMat.style(); + reinforced = current; + } + if (getPartAmount() >= 3) + { + current = accessoryMat.reinforced(); + if (current > 0 && current > reinforced) + { + style = accessoryMat.style(); + reinforced = current; + } + } + if (getPartAmount() >= 4) + { + current = extraMat.reinforced(); + if (current > 0 && current > reinforced) + { + style = extraMat.style(); + reinforced = current; + } + } + + reinforced += unbreaking - reinforced; + + if (reinforced > 0) + { + return style + getReinforcedString(reinforced); + } + return ""; + } + + String getReinforcedString (int reinforced) + { + if (reinforced > 9) + return "Unbreakable"; + String ret = "Reinforced "; + switch (reinforced) + { + case 1: + ret += "I"; + break; + case 2: + ret += "II"; + break; + case 3: + ret += "III"; + break; + case 4: + ret += "IV"; + break; + case 5: + ret += "V"; + break; + case 6: + ret += "VI"; + break; + case 7: + ret += "VII"; + break; + case 8: + ret += "VIII"; + break; + case 9: + ret += "IX"; + break; + default: + ret += "X"; + break; + } + return ret; + } + + //Used for sounds and the like + public void onEntityDamaged (World world, EntityLivingBase player, Entity entity) + { + + } + + /* Creative mode tools */ + + public void getSubItems (int id, CreativeTabs tab, List list) + { + Iterator iter = TConstructRegistry.toolMaterials.entrySet().iterator(); + while (iter.hasNext()) + { + Map.Entry pairs = (Map.Entry) iter.next(); + ToolMaterial material = (ToolMaterial) pairs.getValue(); + buildTool((Integer) pairs.getKey(), material.displayName, list); + } + } + + public void buildTool (int id, String name, List list) + { + Item accessory = getAccessoryItem(); + ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, id) : null; + Item extra = getExtraItem(); + ItemStack extraStack = extra != null ? new ItemStack(extra, 1, id) : null; + ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), new ItemStack(getHandleItem(), 1, id), accessoryStack, extraStack, name + getToolName()); + if (tool == null) + { + System.out.println("Creative builder failed tool for " + name + this.getToolName()); + System.out.println("Make sure you do not have item ID conflicts"); + } + else + { + tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true); + list.add(tool); + } + } + + public abstract Item getHeadItem (); + + public abstract Item getAccessoryItem (); + + public Item getExtraItem () + { + return null; + } + + public Item getHandleItem () + { + return TConstructRegistry.getItem("toolRod");//TContent.toolRod; + } + + /* Updating */ + + @Override + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + mod.updateTool(this, stack, world, entity); + } + } + + /* Tool uses */ + + //Types + public abstract String[] toolCategories (); + + //Mining + @Override + public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, x, y, z, player)) + cancelHarvest = true; + } + + return cancelHarvest; + } + + @Override + public boolean onBlockDestroyed (ItemStack itemstack, World world, int blockID, int x, int y, int z, EntityLivingBase player) + { + Block block = Block.blocksList[blockID]; + if (block != null && (double) block.getBlockHardness(world, x, y, z) != 0.0D) + { + return AbilityHelper.onBlockChanged(itemstack, world, blockID, x, y, z, player, random); + } + return true; + } + + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + NBTTagCompound tags = stack.getTagCompound(); + if (tags.getCompoundTag("InfiTool").getBoolean("Broken")) + return 0.1f; + return 1f; + } + + // Attacking + @Override + public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity) + { + AbilityHelper.onLeftClickEntity(stack, player, entity, this, 0); + return true; + } + + @Override + public boolean hitEntity (ItemStack stack, EntityLivingBase mob, EntityLivingBase player) + { + return true; + } + + public boolean pierceArmor () + { + return false; + } + + public float chargeAttack () + { + return 1f; + } + + public int getDamageVsEntity (Entity par1Entity) + { + return this.damageVsEntity; + } + + //Changes how much durability the base tool has + public float getDurabilityModifier () + { + return 1f; + } + + public float getRepairCost () + { + return getDurabilityModifier(); + } + + public float getDamageModifier () + { + return 1.0f; + } + + //Right-click + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ) + { + /*if (world.isRemote) + return true;*/ + + int posX = x; + int posY = y; + int posZ = z; + int playerPosX = (int) Math.floor(player.posX); + int playerPosY = (int) Math.floor(player.posY); + int playerPosZ = (int) Math.floor(player.posZ); + if (side == 0) + { + --posY; + } + + if (side == 1) + { + ++posY; + } + + if (side == 2) + { + --posZ; + } + + if (side == 3) + { + ++posZ; + } + + if (side == 4) + { + --posX; + } + + if (side == 5) + { + ++posX; + } + if (posX == playerPosX && (posY == playerPosY || posY == playerPosY + 1 || posY == playerPosY - 1) && posZ == playerPosZ) + { + return false; + } + + boolean used = false; + int hotbarSlot = player.inventory.currentItem; + int itemSlot = hotbarSlot == 0 ? 8 : hotbarSlot + 1; + ItemStack nearbyStack = null; + + if (hotbarSlot < 8) + { + nearbyStack = player.inventory.getStackInSlot(itemSlot); + if (nearbyStack != null && nearbyStack.getItem() instanceof ItemBlock) + { + used = nearbyStack.getItem().onItemUse(nearbyStack, player, world, x, y, z, side, clickX, clickY, clickZ); + if (nearbyStack.stackSize < 1) + { + nearbyStack = null; + player.inventory.setInventorySlotContents(itemSlot, null); + } + } + } + + /*if (used) //Update client + { + Packet103SetSlot packet = new Packet103SetSlot(player.openContainer.windowId, itemSlot, nearbyStack); + ((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet); + }*/ + return used; + } + + /* IC2 Support + * Every tool can be an electric tool if you modify it right + */ + @Override + public boolean canBeStoredInToolbox (ItemStack stack) + { + return true; + } + + @Override + public boolean canProvideEnergy (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.hasKey("charge")) + return false; + + return true; + } + + @Override + public int getChargedItemId (ItemStack stack) + { + return this.itemID; + } + + @Override + public int getEmptyItemId (ItemStack stack) + { + return this.itemID; + } + + @Override + public int getMaxCharge (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.hasKey("charge")) + return 0; + + return 10000; + } + + @Override + public int getTier (ItemStack itemStack) + { + return 0; + } + + @Override + public int getTransferLimit (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.hasKey("charge")) + return 0; + + return 32; + } + + @Override + public int charge (ItemStack stack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) + { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.hasKey("charge")) + return 0; + + if (amount > 0) + { + if (amount > getTransferLimit(stack) && !ignoreTransferLimit) + { + amount = getTransferLimit(stack); + } + + int charge = tags.getInteger("charge"); + + if (amount > getMaxCharge(stack) - charge) + { + amount = getMaxCharge(stack) - charge; + } + + charge += amount; + + if (!simulate) + { + tags.setInteger("charge", charge); + stack.setItemDamage(1 + (getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 2) / getMaxCharge(stack)); + } + + return amount; + } + + else + return 0; + } + + @Override + public int discharge (ItemStack stack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) + { + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.hasKey("charge")) + return 0; + + if (amount > 0) + { + if (amount > getTransferLimit(stack) && !ignoreTransferLimit) + { + amount = getTransferLimit(stack); + } + + int charge = tags.getInteger("charge"); + + if (amount > charge) + { + amount = charge; + } + + charge -= amount; + + if (!simulate) + { + tags.setInteger("charge", charge); + stack.setItemDamage(1 + (getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 1) / getMaxCharge(stack)); + } + + return amount; + } + + else + return 0; + } + + @Override + public boolean canShowChargeToolTip (ItemStack itemStack) + { + return false; + } + + @Override + public boolean canUse (ItemStack itemStack, int amount) + { + return false; + } + + //Vanilla overrides + public boolean isItemTool (ItemStack par1ItemStack) + { + return false; + } + + @Override + public boolean getIsRepairable (ItemStack par1ItemStack, ItemStack par2ItemStack) + { + return false; + } + + public boolean isRepairable () + { + return false; + } + + public int getItemEnchantability () + { + return 0; + } + + public boolean isFull3D () + { + return true; + } + + /* Proper stack damage */ + public int getItemMaxDamageFromStack (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (tags == null) + { + return 0; + } + + if (tags.hasKey("charge")) + { + int charge = tags.getInteger("charge"); + if (charge > 0) + return this.getMaxCharge(stack); + } + return tags.getCompoundTag("InfiTool").getInteger("TotalDurability"); + } + + public int getItemDamageFromStackForDisplay (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (tags == null) + { + return 0; + } + + if (tags.hasKey("charge")) + { + int charge = tags.getInteger("charge"); + if (charge > 0) + return getMaxCharge(stack) - charge; + } + return tags.getCompoundTag("InfiTool").getInteger("Damage"); + } + +} diff --git a/tconstruct/library/tools/ToolMaterial.java b/tconstruct/library/tools/ToolMaterial.java new file mode 100644 index 00000000..69bb32f4 --- /dev/null +++ b/tconstruct/library/tools/ToolMaterial.java @@ -0,0 +1,91 @@ +package tconstruct.library.tools; + +/* + * Dynamic substitute for an enum. It carries a lot of information + */ +public class ToolMaterial +{ + //mining level, durability, mining speed, baseDamage, handle modifier, Reinforced level, shoddy/spiny level, color/style on name + + public final String materialName; + public final String displayName; + public final int harvestLevel; + public final int durability; + public final int miningspeed; // <-- divided by 100 + public final int attack; + public final float handleModifier; + public final int reinforced; + public final float stonebound; + public final String tipStyle; + public final String ability; + + public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, String ability) + { + this(name, name + " ", level, durability, speed, damage, handle, reinforced, stonebound, style, ability); + } + + public ToolMaterial(String name, String displayName, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, String ability) + { + this.materialName = name; + this.displayName = displayName; + this.harvestLevel = level; + this.durability = durability; + this.miningspeed = speed; + this.attack = damage; + this.handleModifier = handle; + this.reinforced = reinforced; + this.stonebound = stonebound; + this.tipStyle = style; + this.ability = ability; + } + + public String name () + { + return materialName; + } + + public int durability () + { + return this.durability; + } + + public int toolSpeed () + { + return this.miningspeed; + } + + public int attack () + { + return this.attack; + } + + public int harvestLevel () + { + return this.harvestLevel; + } + + public float handleDurability () + { + return this.handleModifier; + } + + public int reinforced () + { + return this.reinforced; + } + + public float shoddy () + { + return this.stonebound; + } + + public String style () + { + return this.tipStyle; + } + + public String ability () + { + return this.ability; + } +} diff --git a/tconstruct/library/tools/ToolMod.java b/tconstruct/library/tools/ToolMod.java new file mode 100644 index 00000000..9932c2e7 --- /dev/null +++ b/tconstruct/library/tools/ToolMod.java @@ -0,0 +1,209 @@ +package tconstruct.library.tools; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public abstract class ToolMod +{ + public final String key; + public final List stacks; + public final int effectIndex; + public static Random random = new Random(); + + public ToolMod(ItemStack[] items, int effect, String dataKey) + { + //recipeItems = items; + List itemstacks = new ArrayList(); + for (int iter = 0; iter < items.length; iter++) + itemstacks.add(items[iter]); + stacks = itemstacks; + effectIndex = effect; + key = dataKey; + } + + /** Checks to see if the inputs match the stored items + * Note: Works like ShapelessRecipes + * + * @param input The ItemStacks to compare against + * @param tool Item to modify, used for restrictions + * @return Whether the recipe matches the input + */ + public boolean matches (ItemStack[] input, ItemStack tool) + { + if (!canModify(tool, input)) + return false; + + ArrayList list = new ArrayList(this.stacks); + + for (int iter = 0; iter < input.length; ++iter) + { + ItemStack craftingStack = input[iter]; + + if (craftingStack != null) + { + boolean canCraft = false; + Iterator iterate = list.iterator(); + + while (iterate.hasNext()) + { + ItemStack removeStack = (ItemStack) iterate.next(); + + if (craftingStack.itemID == removeStack.itemID && (removeStack.getItemDamage() == Short.MAX_VALUE || craftingStack.getItemDamage() == removeStack.getItemDamage())) + { + canCraft = true; + list.remove(removeStack); + break; + } + } + + if (!canCraft) + { + return false; + } + } + } + + return list.isEmpty(); + } + + /** + * + * @param tool Tool to compare against + * @return Whether the tool can be modified + */ + + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + return tags.getInteger("Modifiers") > 0; + } + + /** Modifies the tool. Adds nbttags, changes existing ones, ticks down modification counter, etc + * + * @param input ItemStacks to pull info from + * @param tool The tool to modify + */ + public abstract void modify (ItemStack[] input, ItemStack tool); + + public void addMatchingEffect (ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey("Effect6") || tags.hasKey(key)) + return; + + else if (tags.hasKey("Effect5")) + { + tags.setInteger("Effect6", effectIndex); + } + else if (tags.hasKey("Effect4")) + { + tags.setInteger("Effect5", effectIndex); + } + else if (tags.hasKey("Effect3")) + { + tags.setInteger("Effect4", effectIndex); + } + else if (tags.hasKey("Effect2")) + { + tags.setInteger("Effect3", effectIndex); + } + else if (tags.hasKey("Effect1")) + { + tags.setInteger("Effect2", effectIndex); + } + else + { + tags.setInteger("Effect1", effectIndex); + } + } + + protected int addModifierTip (ItemStack tool, String modifierTip) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + int tipNum = 0; + while (true) + { + tipNum++; + String tip = "Tooltip" + tipNum; + if (!tags.hasKey(tip)) + { + tags.setString(tip, ""); + String modTip = "ModifierTip" + tipNum; + tags.setString(modTip, modifierTip); + return tipNum; + } + } + } + + protected int addToolTip (ItemStack tool, String tooltip, String modifierTip) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + int tipNum = 0; + while (true) + { + tipNum++; + String tip = "Tooltip" + tipNum; + if (!tags.hasKey(tip)) + { + tags.setString(tip, tooltip); + String modTip = "ModifierTip" + tipNum; + tags.setString(modTip, modifierTip); + return tipNum; + } + else + { + String tag = tags.getString(tip); + if (tag.contains(tooltip)) + { + tags.setString(tip, getProperName(tooltip, tag)); + String modTip = "ModifierTip" + tipNum; + tag = tags.getString(modTip); + tags.setString(modTip, getProperName(modifierTip, tag)); + return tipNum; + } + } + } + } + + protected String getProperName (String tooltip, String tag) + { + if (tag.equals(tooltip)) + return tooltip + " II"; + + if (tag.equals(tooltip + " II")) + return tooltip + " III"; + + if (tag.equals(tooltip + " III")) + return tooltip + " IV"; + + if (tag.equals(tooltip + " IV")) + return tooltip + " V"; + + if (tag.equals(tooltip + " V")) + return tooltip + " VI"; + + if (tag.equals(tooltip + " VI")) + return tooltip + " VII"; + + if (tag.equals(tooltip + " VII")) + return tooltip + " VIII"; + + if (tag.equals(tooltip + " VIII")) + return tooltip + " IX"; + + if (tag.equals(tooltip + " IX")) + return tooltip + " X"; + + return tooltip + " X+"; + } + + public boolean validType (ToolCore tool) + { + return true; + } +} diff --git a/tconstruct/library/tools/Weapon.java b/tconstruct/library/tools/Weapon.java new file mode 100644 index 00000000..ed95c69d --- /dev/null +++ b/tconstruct/library/tools/Weapon.java @@ -0,0 +1,128 @@ +package tconstruct.library.tools; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class Weapon extends ToolCore +{ + + public Weapon(int itemID, int baseDamage) + { + super(itemID, baseDamage); + } + + protected float baseSpeed () + { + return 1.5f; + } + + protected float effectiveSpeed () + { + return 15f; + } + + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + if (stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken")) + return 0.1f; + + for (int i = 0; i < web.length; i++) + { + if (web[i] == block.blockMaterial) + { + return effectiveSpeed(); + } + } + return baseSpeed(); + } + + /** + * returns the action that specifies what animation to play when the items is being used + */ + public EnumAction getItemUseAction (ItemStack par1ItemStack) + { + return EnumAction.block; + } + + /** + * How long it takes to use or consume an item + */ + public int getMaxItemUseDuration (ItemStack par1ItemStack) + { + return 72000; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + { + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + return stack; + } + + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ) + { + return false; + } + + /** + * Returns if the item (tool) can harvest results from the block type. + */ + public boolean canHarvestBlock (Block block) + { + for (int i = 0; i < web.length; i++) + { + if (block.blockMaterial == web[i]) + return true; + } + return super.canHarvestBlock(block); + } + + protected Material[] getEffectiveMaterials () + { + return web; + } + + @Override + @SideOnly(Side.CLIENT) + public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + super.onUpdate(stack, world, entity, par4, par5); + if (entity instanceof EntityPlayerSP) + { + EntityPlayerSP player = (EntityPlayerSP) entity; + ItemStack usingItem = player.getItemInUse(); + if (usingItem != null && usingItem.getItem() == this) + { + player.movementInput.moveForward *= 2.5F; + player.movementInput.moveStrafe *= 2.5F; + } + } + } + + /*@Override + public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity) + { + TContent.modL.midStreamModify(stack); + return super.onLeftClickEntity(stack, player, entity); + }*/ + + @Override + public String[] toolCategories () + { + return new String[] { "weapon", "melee" }; + } + + public static Material[] web = new Material[] { Material.web }; + public static Material[] none = new Material[0]; +} diff --git a/tconstruct/library/util/CoordTuple.java b/tconstruct/library/util/CoordTuple.java new file mode 100644 index 00000000..58af7b71 --- /dev/null +++ b/tconstruct/library/util/CoordTuple.java @@ -0,0 +1,54 @@ +package tconstruct.library.util; + +public class CoordTuple +{ + public final int x; + public final int y; + public final int z; + + public CoordTuple(int posX, int posY, int posZ) + { + x = posX; + y = posY; + z = posZ; + } + + public boolean equalCoords (int posX, int posY, int posZ) + { + if (this.x == posX && this.y == posY && this.z == posZ) + return true; + else + return false; + } + + @Override + public boolean equals (Object obj) + { + if (obj == null) + return false; + + if (getClass() == obj.getClass()) + { + CoordTuple coord = (CoordTuple) obj; + if (this.x == coord.x && this.y == coord.y && this.z == coord.z) + return true; + } + return false; + } + + @Override + public int hashCode () + { + final int prime = 31; + int result = 1; + result = prime * result + x; + result = prime * result + y; + result = prime * result + z; + return result; + } + + public String toString () + { + return "X: " + x + ", Y: " + y + ", Z: " + z; + } +} diff --git a/tconstruct/library/util/IActiveLogic.java b/tconstruct/library/util/IActiveLogic.java new file mode 100644 index 00000000..065eb718 --- /dev/null +++ b/tconstruct/library/util/IActiveLogic.java @@ -0,0 +1,8 @@ +package tconstruct.library.util; + +public interface IActiveLogic +{ + public boolean getActive (); + + public void setActive (boolean flag); +} \ No newline at end of file diff --git a/tconstruct/library/util/IFacingLogic.java b/tconstruct/library/util/IFacingLogic.java new file mode 100644 index 00000000..481ec462 --- /dev/null +++ b/tconstruct/library/util/IFacingLogic.java @@ -0,0 +1,15 @@ +package tconstruct.library.util; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraftforge.common.ForgeDirection; + +public interface IFacingLogic +{ + public byte getRenderDirection (); + + public ForgeDirection getForgeDirection (); + + public void setDirection (int side); + + public void setDirection (float yaw, float pitch, EntityLivingBase player); +} \ No newline at end of file diff --git a/tconstruct/library/util/IMasterLogic.java b/tconstruct/library/util/IMasterLogic.java new file mode 100644 index 00000000..1ca17169 --- /dev/null +++ b/tconstruct/library/util/IMasterLogic.java @@ -0,0 +1,6 @@ +package tconstruct.library.util; + +public interface IMasterLogic +{ + public void notifyChange (int x, int y, int z); +} diff --git a/tconstruct/library/util/IPattern.java b/tconstruct/library/util/IPattern.java new file mode 100644 index 00000000..bf6c64a5 --- /dev/null +++ b/tconstruct/library/util/IPattern.java @@ -0,0 +1,11 @@ +package tconstruct.library.util; + +import tconstruct.library.crafting.PatternBuilder.MaterialSet; +import net.minecraft.item.ItemStack; + +public interface IPattern +{ + public int getPatternCost (ItemStack pattern); + + public ItemStack getPatternOutput (ItemStack pattern, ItemStack input, MaterialSet set); +} diff --git a/tconstruct/library/util/IServantLogic.java b/tconstruct/library/util/IServantLogic.java new file mode 100644 index 00000000..4cbb1110 --- /dev/null +++ b/tconstruct/library/util/IServantLogic.java @@ -0,0 +1,12 @@ +package tconstruct.library.util; + +public interface IServantLogic +{ + public CoordTuple getMasterPosition (); + + public void notifyMasterOfChange (); + + public boolean verifyMaster (int x, int y, int z); + + public boolean setMaster (int x, int y, int z); +} diff --git a/tconstruct/library/util/IToolPart.java b/tconstruct/library/util/IToolPart.java new file mode 100644 index 00000000..eff96d40 --- /dev/null +++ b/tconstruct/library/util/IToolPart.java @@ -0,0 +1,13 @@ +package tconstruct.library.util; + +import net.minecraft.item.ItemStack; + +public interface IToolPart +{ + /** Parts to build tools from. ex: Pickaxe Head + * + * @param stack This item + * @return Proper material ID. -1 for invalid + */ + public int getMaterialID (ItemStack stack); +} diff --git a/tconstruct/library/util/PiercingEntityDamage.java b/tconstruct/library/util/PiercingEntityDamage.java new file mode 100644 index 00000000..153c65ed --- /dev/null +++ b/tconstruct/library/util/PiercingEntityDamage.java @@ -0,0 +1,13 @@ +package tconstruct.library.util; + +import net.minecraft.entity.Entity; +import net.minecraft.util.EntityDamageSource; + +public class PiercingEntityDamage extends EntityDamageSource +{ + public PiercingEntityDamage(String str, Entity entity) + { + super(str, entity); + this.setDamageBypassesArmor(); + } +} diff --git a/tconstruct/library/util/TabTools.java b/tconstruct/library/util/TabTools.java new file mode 100644 index 00000000..202e260f --- /dev/null +++ b/tconstruct/library/util/TabTools.java @@ -0,0 +1,24 @@ +package tconstruct.library.util; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; + +public class TabTools extends CreativeTabs +{ + ItemStack display; + + public TabTools(String label) + { + super(label); + } + + public void init (ItemStack stack) + { + display = stack; + } + + public ItemStack getIconItemStack () + { + return display; + } +} \ No newline at end of file diff --git a/tconstruct/library/util/ValueCoordTuple.java b/tconstruct/library/util/ValueCoordTuple.java new file mode 100644 index 00000000..3689723c --- /dev/null +++ b/tconstruct/library/util/ValueCoordTuple.java @@ -0,0 +1,54 @@ +package tconstruct.library.util; + +public class ValueCoordTuple +{ + public final int dim; + public final int x; + public final int z; + + public ValueCoordTuple(int worldID, int posX, int posZ) + { + dim = worldID; + x = posX; + z = posZ; + } + + public boolean equalCoords (int worldID, int posX, int posZ) + { + if (this.dim == posX && this.x == posX && this.z == posZ) + return true; + else + return false; + } + + @Override + public boolean equals (Object obj) + { + if (obj == null) + return false; + + if (getClass() == obj.getClass()) + { + ValueCoordTuple coord = (ValueCoordTuple) obj; + if (this.dim == coord.dim && this.x == coord.x && this.z == coord.z) + return true; + } + return false; + } + + @Override + public int hashCode () + { + final int prime = 37; + int result = 1; + result = prime * result + dim; + result = prime * result + x; + result = prime * result + z; + return result; + } + + public String toString () + { + return "Dim: " + dim + ", X: " + x + ", Z: " + z; + } +} diff --git a/tconstruct/modifiers/ModAntiSpider.java b/tconstruct/modifiers/ModAntiSpider.java new file mode 100644 index 00000000..189127ed --- /dev/null +++ b/tconstruct/modifiers/ModAntiSpider.java @@ -0,0 +1,85 @@ +package tconstruct.modifiers; + +import tconstruct.library.tools.ToolMod; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModAntiSpider extends ToolMod +{ + String tooltipName; + int increase; + int max = 4; + String guiType; + + public ModAntiSpider(String type, ItemStack[] items, int effect, int inc) + { + super(items, effect, "ModAntiSpider"); + tooltipName = "\u00a72Bane of Arthropods"; + guiType = type; + increase = inc; + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + return tags.getInteger("Modifiers") > 0; + + int keyPair[] = tags.getIntArray(key); + if (keyPair[0] + increase <= keyPair[1]) + return true; + + else if (keyPair[0] == keyPair[1]) + return tags.getInteger("Modifiers") > 0; + + else + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey(key)) + { + int[] keyPair = tags.getIntArray(key); + + if (keyPair[0] % max == 0) + { + keyPair[0] += increase; + keyPair[1] += max; + tags.setIntArray(key, keyPair); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + } + else + { + keyPair[0] += increase; + tags.setIntArray(key, keyPair); + } + updateModTag(tool, keyPair); + + } + else + { + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + String modName = "\u00a72" + guiType + " (" + increase + "/" + max + ")"; + int tooltipIndex = addToolTip(tool, tooltipName, modName); + int[] keyPair = new int[] { increase, max, tooltipIndex }; + tags.setIntArray(key, keyPair); + } + } + + void updateModTag (ItemStack tool, int[] keys) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + String tip = "ModifierTip" + keys[2]; + String modName = "\u00a72" + guiType + " (" + keys[0] + "/" + keys[1] + ")"; + tags.setString(tip, modName); + } +} diff --git a/tconstruct/modifiers/ModAttack.java b/tconstruct/modifiers/ModAttack.java new file mode 100644 index 00000000..c9dff0f0 --- /dev/null +++ b/tconstruct/modifiers/ModAttack.java @@ -0,0 +1,125 @@ +package tconstruct.modifiers; + +import java.util.Arrays; +import java.util.List; + +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMod; + + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModAttack extends ToolMod +{ + String tooltipName; + int increase; + int max = 72; + String guiType; + + public ModAttack(String type, ItemStack[] items, int effect, int inc) + { + super(items, effect, "ModAttack"); + tooltipName = "\u00a7fSharpness"; + guiType = type; + increase = inc; + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + ToolCore toolItem = (ToolCore) tool.getItem(); + if (!validType(toolItem)) + return false; + + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + return tags.getInteger("Modifiers") > 0; + + int keyPair[] = tags.getIntArray(key); + if (keyPair[0] + increase <= keyPair[1]) + return true; + + else if (keyPair[0] == keyPair[1]) + return tags.getInteger("Modifiers") > 0; + + else + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey(key)) + { + int amount = 24; + ToolCore toolItem = (ToolCore) tool.getItem(); + if (toolItem.pierceArmor() || !nerfType(toolItem)) + amount = 36; + + int[] keyPair = tags.getIntArray(key); + + int leftToBoost = amount - (keyPair[0] % amount); + if (increase >= leftToBoost) + { + int attack = tags.getInteger("Attack"); + attack += 1; + tags.setInteger("Attack", attack); + } + + if (keyPair[0] % max == 0) + { + keyPair[0] += increase; + keyPair[1] += max; + tags.setIntArray(key, keyPair); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + } + else + { + keyPair[0] += increase; + tags.setIntArray(key, keyPair); + } + updateModTag(tool, keyPair); + + } + else + { + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + String modName = "\u00a7f" + guiType + " (" + increase + "/" + max + ")"; + int tooltipIndex = addToolTip(tool, tooltipName, modName); + int[] keyPair = new int[] { increase, max, tooltipIndex }; + tags.setIntArray(key, keyPair); + + int attack = tags.getInteger("Attack"); + attack += 1; + tags.setInteger("Attack", attack); + } + } + + void updateModTag (ItemStack tool, int[] keys) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + String tip = "ModifierTip" + keys[2]; + String modName = "\u00a7f" + guiType + " (" + keys[0] + "/" + keys[1] + ")"; + tags.setString(tip, modName); + } + + public boolean validType (ToolCore tool) + { + return true; + /*List list = Arrays.asList(tool.toolCategories()); + return list.contains("melee") || list.contains("harvest") || list.contains("ammo");*/ + } + + public boolean nerfType (ToolCore tool) + { + List list = Arrays.asList(tool.toolCategories()); + return list.contains("throwing") || list.contains("ammo"); + } +} diff --git a/tconstruct/modifiers/ModAutoSmelt.java b/tconstruct/modifiers/ModAutoSmelt.java new file mode 100644 index 00000000..6d1d86c0 --- /dev/null +++ b/tconstruct/modifiers/ModAutoSmelt.java @@ -0,0 +1,23 @@ +package tconstruct.modifiers; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModAutoSmelt extends ModBoolean +{ + + public ModAutoSmelt(ItemStack[] items, int effect, String tag, String c, String tip) + { + super(items, effect, tag, c, tip); + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Silk Touch")) + return false; + return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key); //Will fail if the modifier is false or the tag doesn't exist + } + +} diff --git a/tconstruct/modifiers/ModBlaze.java b/tconstruct/modifiers/ModBlaze.java new file mode 100644 index 00000000..c5da23b8 --- /dev/null +++ b/tconstruct/modifiers/ModBlaze.java @@ -0,0 +1,103 @@ +package tconstruct.modifiers; + +import java.util.Arrays; +import java.util.List; + +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMod; + + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModBlaze extends ToolMod +{ + String tooltipName; + int increase; + int max; + + public ModBlaze(ItemStack[] items, int effect, int inc) + { + super(items, effect, "Blaze"); + tooltipName = "\u00a76Fiery"; + increase = inc; + max = 25; + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + ToolCore toolItem = (ToolCore) tool.getItem(); + if (!validType(toolItem)) + return false; + + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + return tags.getInteger("Modifiers") > 0; + + int keyPair[] = tags.getIntArray(key); + if (keyPair[0] + increase <= keyPair[1]) + return true; + + else if (keyPair[0] == keyPair[1]) + return tags.getInteger("Modifiers") > 0; + + else + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey(key)) + { + int[] keyPair = tags.getIntArray(key); + if (keyPair[0] == max) + { + keyPair[0] += increase; + keyPair[1] += max; + tags.setIntArray(key, keyPair); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + } + else + { + keyPair[0] += increase; + tags.setIntArray(key, keyPair); + } + updateModTag(tool, keyPair); + } + else + { + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + String modName = "\u00a76Blaze (" + increase + "/" + max + ")"; + int tooltipIndex = addToolTip(tool, tooltipName, modName); + int[] keyPair = new int[] { increase, max, tooltipIndex }; + tags.setIntArray(key, keyPair); + } + + int fiery = tags.getInteger("Fiery"); + fiery += (increase); + tags.setInteger("Fiery", fiery); + + } + + void updateModTag (ItemStack tool, int[] keys) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + String tip = "ModifierTip" + keys[2]; + String modName = "\u00a76Blaze (" + keys[0] + "/" + keys[1] + ")"; + tags.setString(tip, modName); + } + + public boolean validType (ToolCore tool) + { + List list = Arrays.asList(tool.toolCategories()); + return list.contains("melee") || list.contains("ammo"); + } +} diff --git a/tconstruct/modifiers/ModBoolean.java b/tconstruct/modifiers/ModBoolean.java new file mode 100644 index 00000000..10b15272 --- /dev/null +++ b/tconstruct/modifiers/ModBoolean.java @@ -0,0 +1,42 @@ +package tconstruct.modifiers; + +import tconstruct.library.tools.ToolMod; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/* Adds a boolean NBTTag */ + +public class ModBoolean extends ToolMod +{ + String color; + String tooltipName; + + public ModBoolean(ItemStack[] items, int effect, String tag, String c, String tip) + { + super(items, effect, tag); + color = c; + tooltipName = tip; + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key); //Will fail if the modifier is false or the tag doesn't exist + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + + tags.setBoolean(key, true); + //System.out.println("Key: "+key+" "+tags.getBoolean(key)); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + + addToolTip(tool, color + tooltipName, color + key); + } +} diff --git a/tconstruct/modifiers/ModButtertouch.java b/tconstruct/modifiers/ModButtertouch.java new file mode 100644 index 00000000..82815243 --- /dev/null +++ b/tconstruct/modifiers/ModButtertouch.java @@ -0,0 +1,117 @@ +package tconstruct.modifiers; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import tconstruct.library.tools.ToolCore; + + +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class ModButtertouch extends ModBoolean +{ + + public ModButtertouch(ItemStack[] items, int effect) + { + super(items, effect, "Silk Touch", "\u00a7e", "Silky"); + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + ToolCore toolItem = (ToolCore) tool.getItem(); + if (!validType(toolItem)) + return false; + + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.getBoolean("Lava") && !tags.hasKey("Lapis")) + { + return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key); + } + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + tags.setBoolean(key, true); + addEnchantment(tool, Enchantment.silkTouch, 1); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + + int attack = tags.getInteger("Attack"); + attack -= 3; + if (attack < 0) + attack = 0; + tags.setInteger("Attack", attack); + + int miningSpeed = tags.getInteger("MiningSpeed"); + miningSpeed -= 300; + if (miningSpeed < 0) + miningSpeed = 0; + tags.setInteger("MiningSpeed", miningSpeed); + + if (tags.hasKey("MiningSpeed2")) + { + int miningSpeed2 = tags.getInteger("MiningSpeed2"); + miningSpeed2 -= 300; + if (miningSpeed2 < 0) + miningSpeed2 = 0; + tags.setInteger("MiningSpeed2", miningSpeed2); + } + + addToolTip(tool, color + tooltipName, color + key); + } + + public void addEnchantment (ItemStack tool, Enchantment enchant, int level) + { + NBTTagList tags = new NBTTagList("ench"); + Map enchantMap = EnchantmentHelper.getEnchantments(tool); + Iterator iterator = enchantMap.keySet().iterator(); + int index; + int lvl; + boolean hasEnchant = false; + while (iterator.hasNext()) + { + NBTTagCompound enchantTag = new NBTTagCompound(); + index = ((Integer) iterator.next()).intValue(); + lvl = (Integer) enchantMap.get(index); + if (index == enchant.effectId) + { + hasEnchant = true; + enchantTag.setShort("id", (short) index); + enchantTag.setShort("lvl", (short) ((byte) level)); + tags.appendTag(enchantTag); + } + else + { + enchantTag.setShort("id", (short) index); + enchantTag.setShort("lvl", (short) ((byte) lvl)); + tags.appendTag(enchantTag); + } + } + if (!hasEnchant) + { + NBTTagCompound enchantTag = new NBTTagCompound(); + enchantTag.setShort("id", (short) enchant.effectId); + enchantTag.setShort("lvl", (short) ((byte) level)); + tags.appendTag(enchantTag); + } + tool.stackTagCompound.setTag("ench", tags); + } + + public boolean validType (ToolCore tool) + { + List list = Arrays.asList(tool.toolCategories()); + return list.contains("weapon") || list.contains("harvest"); + } +} diff --git a/tconstruct/modifiers/ModDurability.java b/tconstruct/modifiers/ModDurability.java new file mode 100644 index 00000000..6d178839 --- /dev/null +++ b/tconstruct/modifiers/ModDurability.java @@ -0,0 +1,69 @@ +package tconstruct.modifiers; + +import tconstruct.library.tools.ToolMod; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/* Adds an integer NBTTag */ + +public class ModDurability extends ToolMod +{ + String tooltipName; + String color; + int durability; + float modifier; + int miningLevel; + + public ModDurability(ItemStack[] items, int effect, int dur, float mod, int level, String k, String tip, String c) + { + super(items, effect, k); + durability = dur; + modifier = mod; + miningLevel = level; + tooltipName = tip; + color = c; + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey(key)) + return false; + return super.canModify(tool, input); + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + + int base = tags.getInteger("BaseDurability"); + int bonus = tags.getInteger("BonusDurability"); + float modDur = tags.getFloat("ModDurability"); + + bonus += durability; + modDur += modifier; + + int total = (int) ((base + bonus) * (modDur + 1f)); + if (total <= 0) + total = 1; + + tags.setInteger("TotalDurability", total); + tags.setInteger("BonusDurability", bonus); + tags.setFloat("ModDurability", modDur); + + int mLevel = tags.getInteger("HarvestLevel"); + if (mLevel < miningLevel) + tags.setInteger("HarvestLevel", miningLevel); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + + tags.setBoolean(key, true); + String modTip = color + key; + addToolTip(tool, tooltipName, modTip); + } + +} diff --git a/tconstruct/modifiers/ModElectric.java b/tconstruct/modifiers/ModElectric.java new file mode 100644 index 00000000..a697a6f8 --- /dev/null +++ b/tconstruct/modifiers/ModElectric.java @@ -0,0 +1,88 @@ +package tconstruct.modifiers; + +import ic2.api.item.IElectricItem; + +import java.util.ArrayList; + +import tconstruct.library.tools.ToolCore; + + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/* IC2 support */ + +public class ModElectric extends ModBoolean +{ + public ArrayList circuits = new ArrayList(); + public ArrayList batteries = new ArrayList(); + + public ModElectric() + { + super(new ItemStack[0], 9, "Electric", "\u00a7e", ""); + } + + @Override + public boolean matches (ItemStack[] input, ItemStack tool) + { + if (input[0] == null || input[1] == null) + return false; + + boolean circuit = false; + boolean battery = false; + + for (ItemStack stack : circuits) + { + if (stack.isItemEqual(input[0]) || stack.isItemEqual(input[1])) + circuit = true; + } + + for (ItemStack stack : batteries) + { + if (stack.itemID == input[0].itemID && input[0].getItem() instanceof IElectricItem) + { + battery = true; + } + if (stack.itemID == input[1].itemID && input[1].getItem() instanceof IElectricItem) + { + battery = true; + } + } + return circuit && battery && canModify(tool, input); + } + + /*@Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + return tags.getInteger("Modifiers") > 0; + + return false; + }*/ + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound(); + + if (!tags.hasKey(key)) + { + tags.setBoolean(key, true); + + int modifiers = tags.getCompoundTag("InfiTool").getInteger("Modifiers"); + modifiers -= 1; + tags.getCompoundTag("InfiTool").setInteger("Modifiers", modifiers); + int charge = 0; + if (input[0].getItem() instanceof IElectricItem && input[0].hasTagCompound()) + charge = input[0].getTagCompound().getInteger("charge"); + if (input[1].getItem() instanceof IElectricItem && input[1].hasTagCompound()) + charge = input[1].getTagCompound().getInteger("charge"); + tags.setInteger("charge", charge); + tags.setInteger(key, 1); + addModifierTip(tool, "\u00a7eElectric"); + ToolCore toolcore = (ToolCore) tool.getItem(); + tool.setItemDamage(1 + (toolcore.getMaxCharge(tool) - charge) * (tool.getMaxDamage() - 1) / toolcore.getMaxCharge(tool)); + } + } +} diff --git a/tconstruct/modifiers/ModExtraModifier.java b/tconstruct/modifiers/ModExtraModifier.java new file mode 100644 index 00000000..d8a2d395 --- /dev/null +++ b/tconstruct/modifiers/ModExtraModifier.java @@ -0,0 +1,39 @@ +package tconstruct.modifiers; + +import tconstruct.library.tools.ToolMod; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModExtraModifier extends ToolMod +{ + + public ModExtraModifier(ItemStack[] items, String dataKey) + { + super(items, 0, dataKey); + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean(key)) + { + return false; + } + return true; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + tags.setBoolean(key, true); + int modifiers = tags.getInteger("Modifiers"); + modifiers += 1; + tags.setInteger("Modifiers", modifiers); + } + + public void addMatchingEffect (ItemStack tool) + { + } +} diff --git a/tconstruct/modifiers/ModInteger.java b/tconstruct/modifiers/ModInteger.java new file mode 100644 index 00000000..b7ad5e26 --- /dev/null +++ b/tconstruct/modifiers/ModInteger.java @@ -0,0 +1,55 @@ +package tconstruct.modifiers; + +import tconstruct.library.tools.ToolMod; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/* Adds an integer NBTTag */ + +public class ModInteger extends ToolMod +{ + String color; + String tooltipName; + int initialIncrease; + int secondaryIncrease; + + public ModInteger(ItemStack[] items, int effect, String dataKey, int increase, String c, String tip) + { + super(items, effect, dataKey); + initialIncrease = secondaryIncrease = increase; + color = c; + tooltipName = tip; + } + + public ModInteger(ItemStack[] items, int effect, String dataKey, int increase1, int increase2, String c, String tip) + { + super(items, effect, dataKey); + initialIncrease = increase1; + secondaryIncrease = increase2; + color = c; + tooltipName = tip; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey(key)) + { + int increase = tags.getInteger(key); + increase += secondaryIncrease; + tags.setInteger(key, increase); + } + else + { + tags.setInteger(key, initialIncrease); + } + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + + addToolTip(tool, color + tooltipName, color + key); + } + +} diff --git a/tconstruct/modifiers/ModLapis.java b/tconstruct/modifiers/ModLapis.java new file mode 100644 index 00000000..c247a92a --- /dev/null +++ b/tconstruct/modifiers/ModLapis.java @@ -0,0 +1,210 @@ +package tconstruct.modifiers; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMod; +import tconstruct.library.tools.Weapon; + + +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class ModLapis extends ToolMod +{ + String tooltipName; + int increase; + int max = 450; + + public ModLapis(ItemStack[] items, int effect, int inc) + { + super(items, effect, "Lapis"); + tooltipName = "\u00a79Luck"; + increase = inc; + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + ToolCore toolItem = (ToolCore) tool.getItem(); + if (!validType(toolItem)) + return false; + + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + + if (tags.getBoolean("Silk Touch")) + return false; + + if (!tags.hasKey(key)) + return tags.getInteger("Modifiers") > 0; + + int keyPair[] = tags.getIntArray(key); + if (keyPair[0] + increase <= max) + return true; + else + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + { + tags.setBoolean(key, true); + + String modName = "\u00a79Lapis (0/450)"; + int tooltipIndex = addToolTip(tool, "\u00a79Luck", modName); + int[] keyPair = new int[] { 0, tooltipIndex }; + tags.setIntArray(key, keyPair); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + } + + int keyPair[] = tags.getIntArray(key); + keyPair[0] += increase; + tags.setIntArray(key, keyPair); + if (tool.getItem() instanceof Weapon) + { + if (keyPair[0] >= 450) + addEnchantment(tool, Enchantment.looting, 3); + else if (keyPair[0] >= 300) + addEnchantment(tool, Enchantment.looting, 2); + else if (keyPair[0] >= 100) + addEnchantment(tool, Enchantment.looting, 1); + } + else + { + if (keyPair[0] >= 450) + addEnchantment(tool, Enchantment.fortune, 3); + else if (keyPair[0] >= 300) + addEnchantment(tool, Enchantment.fortune, 2); + else if (keyPair[0] >= 100) + addEnchantment(tool, Enchantment.fortune, 1); + } + + updateModTag(tool, keyPair); + } + + public void midStreamModify (ItemStack tool, ToolCore toolItem) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + return; + + int keyPair[] = tags.getIntArray(key); + if (keyPair[0] == max) + return; + + if (random.nextInt(50) == 0) + { + keyPair[0] += 1; + tags.setIntArray(key, keyPair); + updateModTag(tool, keyPair); + } + + List list = Arrays.asList(toolItem.toolCategories()); + if (list.contains("weapon")) + { + if (keyPair[0] >= 350) + { + int chance = keyPair[0] - 300; + if (random.nextInt(1000 - chance) == 0) + addEnchantment(tool, Enchantment.looting, 3); + } + else if (keyPair[0] >= 125) + { + int chance = keyPair[0] - 175; + if (random.nextInt(600 - chance) == 0) + addEnchantment(tool, Enchantment.looting, 2); + } + else if (keyPair[0] >= 10) + { + int chance = keyPair[0] - 25; + if (random.nextInt(250 - chance) == 0) + addEnchantment(tool, Enchantment.looting, 1); + } + } + + if (list.contains("harvest")) + { + if (keyPair[0] >= 350) + { + int chance = keyPair[0] - 300; + if (random.nextInt(1000 - chance) == 0) + addEnchantment(tool, Enchantment.fortune, 3); + } + else if (keyPair[0] >= 125) + { + int chance = keyPair[0] - 175; + if (random.nextInt(600 - chance) == 0) + addEnchantment(tool, Enchantment.fortune, 2); + } + else if (keyPair[0] >= 10) + { + int chance = keyPair[0] - 25; + if (random.nextInt(250 - chance) == 0) + addEnchantment(tool, Enchantment.fortune, 1); + } + } + } + + public void addEnchantment (ItemStack tool, Enchantment enchant, int level) + { + NBTTagList tags = new NBTTagList("ench"); + Map enchantMap = EnchantmentHelper.getEnchantments(tool); + Iterator iterator = enchantMap.keySet().iterator(); + int index; + int lvl; + boolean hasEnchant = false; + while (iterator.hasNext()) + { + NBTTagCompound enchantTag = new NBTTagCompound(); + index = ((Integer) iterator.next()).intValue(); + lvl = (Integer) enchantMap.get(index); + if (index == enchant.effectId) + { + hasEnchant = true; + enchantTag.setShort("id", (short) index); + enchantTag.setShort("lvl", (short) ((byte) level)); + tags.appendTag(enchantTag); + } + else + { + enchantTag.setShort("id", (short) index); + enchantTag.setShort("lvl", (short) ((byte) lvl)); + tags.appendTag(enchantTag); + } + } + if (!hasEnchant) + { + NBTTagCompound enchantTag = new NBTTagCompound(); + enchantTag.setShort("id", (short) enchant.effectId); + enchantTag.setShort("lvl", (short) ((byte) level)); + tags.appendTag(enchantTag); + } + tool.stackTagCompound.setTag("ench", tags); + } + + void updateModTag (ItemStack tool, int[] keys) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + String tip = "ModifierTip" + keys[1]; + String modName = "\u00a79Lapis (" + keys[0] + "/" + max + ")"; + tags.setString(tip, modName); + } + + public boolean validType (ToolCore tool) + { + List list = Arrays.asList(tool.toolCategories()); + return list.contains("weapon") || list.contains("harvest"); + } +} diff --git a/tconstruct/modifiers/ModPiston.java b/tconstruct/modifiers/ModPiston.java new file mode 100644 index 00000000..10e22a3f --- /dev/null +++ b/tconstruct/modifiers/ModPiston.java @@ -0,0 +1,103 @@ +package tconstruct.modifiers; + +import java.util.Arrays; +import java.util.List; + +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMod; + + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModPiston extends ToolMod +{ + String tooltipName; + int increase; + int max; + + public ModPiston(ItemStack[] items, int effect, int inc) + { + super(items, effect, "Piston"); + tooltipName = "\u00a77Knockback"; + increase = inc; + max = 10; + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + ToolCore toolItem = (ToolCore) tool.getItem(); + if (!validType(toolItem)) + return false; + + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + return tags.getInteger("Modifiers") > 0; + + int keyPair[] = tags.getIntArray(key); + if (keyPair[0] + increase <= keyPair[1]) + return true; + + else if (keyPair[0] == keyPair[1]) + return tags.getInteger("Modifiers") > 0; + + else + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey(key)) + { + int[] keyPair = tags.getIntArray(key); + if (keyPair[0] % max == 0) + { + keyPair[0] += increase; + keyPair[1] += max; + tags.setIntArray(key, keyPair); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + } + else + { + keyPair[0] += increase; + tags.setIntArray(key, keyPair); + } + updateModTag(tool, keyPair); + } + else + { + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + String modName = "\u00a74Knockback (" + increase + "/" + max + ")"; + int tooltipIndex = addToolTip(tool, tooltipName, modName); + int[] keyPair = new int[] { increase, max, tooltipIndex }; + tags.setIntArray(key, keyPair); + } + + float knockback = tags.getFloat("Knockback"); + + knockback += 0.1 * increase; + tags.setFloat("Knockback", knockback); + } + + void updateModTag (ItemStack tool, int[] keys) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + String tip = "ModifierTip" + keys[2]; + String modName = "\u00a77Knockback (" + keys[0] + "/" + keys[1] + ")"; + tags.setString(tip, modName); + } + + public boolean validType (ToolCore tool) + { + List list = Arrays.asList(tool.toolCategories()); + return list.contains("weapon"); + } +} diff --git a/tconstruct/modifiers/ModPotion.java b/tconstruct/modifiers/ModPotion.java new file mode 100644 index 00000000..da8010b3 --- /dev/null +++ b/tconstruct/modifiers/ModPotion.java @@ -0,0 +1,32 @@ +package tconstruct.modifiers; + +import tconstruct.library.tools.ToolMod; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModPotion extends ToolMod +{ + + public ModPotion(ItemStack[] items, int effect, String dataKey) + { + super(new ItemStack[] { new ItemStack(Item.potion, 1, Short.MAX_VALUE) }, 0, ""); + } + + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + NBTTagCompound potion = tool.getTagCompound().getCompoundTag("Potion"); + if (potion == null) + return true; + + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + + } + +} diff --git a/tconstruct/modifiers/ModRedstone.java b/tconstruct/modifiers/ModRedstone.java new file mode 100644 index 00000000..e9fadd33 --- /dev/null +++ b/tconstruct/modifiers/ModRedstone.java @@ -0,0 +1,118 @@ +package tconstruct.modifiers; + +import java.util.Arrays; +import java.util.List; + +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMod; + + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModRedstone extends ToolMod +{ + String tooltipName; + int increase; + int max; + + public ModRedstone(ItemStack[] items, int effect, int inc) + { + super(items, effect, "Redstone"); + tooltipName = "\u00a74Haste"; + increase = inc; + max = 50; + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + ToolCore toolItem = (ToolCore) tool.getItem(); + if (!validType(toolItem)) + return false; + + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + return tags.getInteger("Modifiers") > 0; + + int keyPair[] = tags.getIntArray(key); + if (keyPair[0] + increase <= keyPair[1]) + return true; + + else if (keyPair[0] == keyPair[1]) + return tags.getInteger("Modifiers") > 0; + + else + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + int[] keyPair; + if (tags.hasKey(key)) + { + keyPair = tags.getIntArray(key); + if (keyPair[0] % max == 0) + { + keyPair[0] += increase; + keyPair[1] += max; + tags.setIntArray(key, keyPair); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + } + else + { + keyPair[0] += increase; + tags.setIntArray(key, keyPair); + } + updateModTag(tool, keyPair); + } + else + { + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + String modName = "\u00a74Redstone (" + increase + "/" + max + ")"; + int tooltipIndex = addToolTip(tool, tooltipName, modName); + keyPair = new int[] { increase, max, tooltipIndex }; + tags.setIntArray(key, keyPair); + } + + int miningSpeed = tags.getInteger("MiningSpeed"); + miningSpeed += (increase * 8); + tags.setInteger("MiningSpeed", miningSpeed); + + if (tags.hasKey("MiningSpeed2")) + { + int miningSpeed2 = tags.getInteger("MiningSpeed2"); + miningSpeed2 += (increase * 8); + tags.setInteger("MiningSpeed2", miningSpeed2); + } + + if (tags.hasKey("DrawSpeed")) + { + //int drawSpeed = tags.getInteger("DrawSpeed"); + int baseDrawSpeed = tags.getInteger("BaseDrawSpeed"); + int drawSpeed = (int) (baseDrawSpeed - (0.1f * baseDrawSpeed * (keyPair[0] / 50f))); + tags.setInteger("DrawSpeed", drawSpeed); + } + } + + void updateModTag (ItemStack tool, int[] keys) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + String tip = "ModifierTip" + keys[2]; + String modName = "\u00a74Redstone (" + keys[0] + "/" + keys[1] + ")"; + tags.setString(tip, modName); + } + + public boolean validType (ToolCore tool) + { + List list = Arrays.asList(tool.toolCategories()); + return list.contains("harvest") || list.contains("utility") || list.contains("bow"); + } +} diff --git a/tconstruct/modifiers/ModReinforced.java b/tconstruct/modifiers/ModReinforced.java new file mode 100644 index 00000000..600f662f --- /dev/null +++ b/tconstruct/modifiers/ModReinforced.java @@ -0,0 +1,70 @@ +package tconstruct.modifiers; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModReinforced extends ModInteger +{ + + public ModReinforced(ItemStack[] items, int effect, int increase) + { + super(items, effect, "Reinforced", 1, "\u00a75", "Reinforced"); + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey(key)) + { + int increase = tags.getInteger(key); + increase += secondaryIncrease; + tags.setInteger(key, increase); + } + else + { + tags.setInteger(key, initialIncrease); + } + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + + int reinforced = tags.getInteger("Unbreaking"); + reinforced += 1; + tags.setInteger("Unbreaking", reinforced); + + addToolTip(tool, color + tooltipName, color + key); + } + + protected int addToolTip (ItemStack tool, String tooltip, String modifierTip) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + int tipNum = 0; + while (true) + { + tipNum++; + String tip = "Tooltip" + tipNum; + if (!tags.hasKey(tip)) + { + //tags.setString(tip, tooltip); + String modTip = "ModifierTip" + tipNum; + String tag = tags.getString(modTip); + tags.setString(modTip, getProperName(modifierTip, tag)); + return tipNum; + } + else + { + String modTip = "ModifierTip" + tipNum; + String tag = tags.getString(modTip); + if (tag.contains(modifierTip)) + { + //tags.setString(tip, getProperName(tooltip, tag)); + tag = tags.getString(modTip); + tags.setString(modTip, getProperName(modifierTip, tag)); + return tipNum; + } + } + } + } +} diff --git a/tconstruct/modifiers/ModRepair.java b/tconstruct/modifiers/ModRepair.java new file mode 100644 index 00000000..ff85de20 --- /dev/null +++ b/tconstruct/modifiers/ModRepair.java @@ -0,0 +1,100 @@ +package tconstruct.modifiers; + +import tconstruct.library.crafting.PatternBuilder; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.ToolCore; +import tconstruct.library.tools.ToolMod; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/* Little mod for actually adding the lapis modifier */ + +public class ModRepair extends ToolMod +{ + + public ModRepair() + { + super(new ItemStack[0], 0, ""); + } + + @Override + public boolean matches (ItemStack[] input, ItemStack tool) + { + return canModify(tool, input); + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + if ((input[0] == null && input[1] == null) || (input[0] != null && input[1] != null)) //Only valid for one itemstack + return false; + + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getInteger("Damage") > 0) + { + int headID = tags.getInteger("Head"); + int matID = -1; + if (input[0] != null) + matID = PatternBuilder.instance.getPartID(input[0]); + else + matID = PatternBuilder.instance.getPartID(input[1]); + + if (matID == headID) + return true; + } + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + tags.setBoolean("Broken", false); + int damage = tags.getInteger("Damage"); + int dur = tags.getInteger("BaseDurability"); + + int materialValue = 0; + if (input[0] != null) + materialValue = PatternBuilder.instance.getPartValue(input[0]); + else + materialValue = PatternBuilder.instance.getPartValue(input[1]); + + int increase = (int) (50 + (dur * 0.4f * materialValue)); + //System.out.println("Increase: "+increase); + + int modifiers = tags.getInteger("Modifiers"); + float mods = 1.0f; + if (modifiers == 2) + mods = 0.8f; + else if (modifiers == 1) + mods = 0.6f; + else if (modifiers == 0) + mods = 0.4f; + + increase *= mods; + + int repair = tags.getInteger("RepairCount"); + repair += 1; + tags.setInteger("RepairCount", repair); + + float repairCount = (100 - repair) / 100f; + if (repairCount < 0.5f) + repairCount = 0.5f; + increase *= repairCount; + increase /= ((ToolCore) tool.getItem()).getRepairCost(); + + damage -= increase; + if (damage < 0) + damage = 0; + tags.setInteger("Damage", damage); + + AbilityHelper.damageTool(tool, 0, null, true); + //tool.setItemDamage(damage * 100 / dur); + + } + + @Override + public void addMatchingEffect (ItemStack tool) + { + } +} diff --git a/tconstruct/modifiers/ModSmite.java b/tconstruct/modifiers/ModSmite.java new file mode 100644 index 00000000..e6df65fc --- /dev/null +++ b/tconstruct/modifiers/ModSmite.java @@ -0,0 +1,85 @@ +package tconstruct.modifiers; + +import tconstruct.library.tools.ToolMod; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ModSmite extends ToolMod +{ + String tooltipName; + int increase; + int max = 36; + String tagName; + + public ModSmite(String type, ItemStack[] items, int effect, int inc) + { + super(items, effect, "ModSmite"); + tooltipName = "\u00a7eSmite"; + tagName = type; + increase = inc; + } + + @Override + protected boolean canModify (ItemStack tool, ItemStack[] input) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (!tags.hasKey(key)) + return tags.getInteger("Modifiers") > 0; + + int keyPair[] = tags.getIntArray(key); + if (keyPair[0] + increase <= keyPair[1]) + return true; + + else if (keyPair[0] == keyPair[1]) + return tags.getInteger("Modifiers") > 0; + + else + return false; + } + + @Override + public void modify (ItemStack[] input, ItemStack tool) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey(key)) + { + int[] keyPair = tags.getIntArray(key); + + if (keyPair[0] % max == 0) + { + keyPair[0] += increase; + keyPair[1] += max; + tags.setIntArray(key, keyPair); + + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + } + else + { + keyPair[0] += increase; + tags.setIntArray(key, keyPair); + } + updateModTag(tool, keyPair); + + } + else + { + int modifiers = tags.getInteger("Modifiers"); + modifiers -= 1; + tags.setInteger("Modifiers", modifiers); + String modName = "\u00a7e" + tagName + " (" + increase + "/" + max + ")"; + int tooltipIndex = addToolTip(tool, tooltipName, modName); + int[] keyPair = new int[] { increase, max, tooltipIndex }; + tags.setIntArray(key, keyPair); + } + } + + void updateModTag (ItemStack tool, int[] keys) + { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + String tip = "ModifierTip" + keys[2]; + String modName = "\u00a7e" + tagName + " (" + keys[0] + "/" + keys[1] + ")"; + tags.setString(tip, modName); + } +} diff --git a/tconstruct/modifiers/TActiveOmniMod.java b/tconstruct/modifiers/TActiveOmniMod.java new file mode 100644 index 00000000..9d1dd6c8 --- /dev/null +++ b/tconstruct/modifiers/TActiveOmniMod.java @@ -0,0 +1,215 @@ +package tconstruct.modifiers; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +import tconstruct.common.TContent; +import tconstruct.library.ActiveToolMod; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.library.tools.ToolCore; +import tconstruct.util.PHConstruct; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class TActiveOmniMod extends ActiveToolMod +{ + Random random = new Random(); + + /* Updating */ + @Override + public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity) + { + if (!world.isRemote && entity instanceof EntityLivingBase && !((EntityLivingBase) entity).isSwingInProgress && stack.getTagCompound() != null) + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.hasKey("Moss")) + { + int chance = tags.getInteger("Moss"); + int check = world.canBlockSeeTheSky((int) entity.posX, (int) entity.posY, (int) entity.posZ) ? 350 : 1150; + if (random.nextInt(check) < chance) + { + AbilityHelper.healTool(stack, 1, (EntityLivingBase) entity, true); + } + } + } + } + + /* Harvesting */ + @Override + public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityLivingBase entity) + { + if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode) + return false; + + List list = Arrays.asList(tool.toolCategories()); + if (list.contains("harvest")) + TContent.modL.midStreamModify(stack, tool); + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + World world = entity.worldObj; + int bID = entity.worldObj.getBlockId(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + Block block = Block.blocksList[bID]; + if (block == null || bID < 1 || bID > 4095) + return false; + + if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0) + { + ItemStack smeltStack = new ItemStack(block.idDropped(meta, random, 0), block.quantityDropped(meta, 0, random), block.damageDropped(meta)); + if (smeltStack.itemID < 0 || smeltStack.itemID >= 32000 || smeltStack.getItem() == null) + return false; + ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack); + if (result != null) + { + world.setBlockToAir(x, y, z); + if (entity instanceof EntityPlayer && !((EntityPlayer) entity).capabilities.isCreativeMode) + tool.onBlockDestroyed(stack, world, bID, x, y, z, entity); + if (!world.isRemote) + { + ItemStack spawnme = result.copy(); + if (!(result.getItem() instanceof ItemBlock) && PHConstruct.lavaFortuneInteraction) + { + int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack); + if (loot > 0) + { + spawnme.stackSize *= (random.nextInt(loot + 1) + 1); + } + } + EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, spawnme); + + entityitem.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(entityitem); + world.playAuxSFX(2001, x, y, z, bID + (meta << 12)); + + int i = spawnme.stackSize; + float f = FurnaceRecipes.smelting().getExperience(spawnme); + int j; + + if (f == 0.0F) + { + i = 0; + } + else if (f < 1.0F) + { + j = MathHelper.floor_float((float) i * f); + + if (j < MathHelper.ceiling_float_int((float) i * f) && (float) Math.random() < (float) i * f - (float) j) + { + ++j; + } + + i = j; + } + + while (i > 0) + { + j = EntityXPOrb.getXPSplit(i); + i -= j; + entity.worldObj.spawnEntityInWorld(new EntityXPOrb(world, x, y + 0.5, z, j)); + } + } + for (int i = 0; i < 5; i++) + { + float f = (float) x + random.nextFloat(); + float f1 = (float) y + random.nextFloat(); + float f2 = (float) z + random.nextFloat(); + float f3 = 0.52F; + float f4 = random.nextFloat() * 0.6F - 0.3F; + world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + + world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + + world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + + world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + } + return true; + } + } + + return false; + } + + /* Attacking */ + + @Override + public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) + { + List list = Arrays.asList(tool.toolCategories()); + if (list.contains("weapon")) + TContent.modL.midStreamModify(stack, tool); + return 0; + } + + @Override + public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) + { + int bonus = 0; + if (entity instanceof EntityLivingBase) + { + EnumCreatureAttribute attribute = ((EntityLivingBase) entity).getCreatureAttribute(); + if (attribute == EnumCreatureAttribute.UNDEAD) + { + if (tool == TContent.hammer) + { + int level = 2; + bonus += random.nextInt(level * 2 + 1) + level * 2; + } + if (toolTags.hasKey("ModSmite")) + { + int[] array = toolTags.getIntArray("ModSmite"); + int base = array[0] / 18; + bonus += 1 + base + random.nextInt(base + 1); + } + } + if (attribute == EnumCreatureAttribute.ARTHROPOD) + { + if (toolTags.hasKey("ModAntiSpider")) + { + int[] array = toolTags.getIntArray("ModAntiSpider"); + int base = array[0] / 2; + bonus += 1 + base + random.nextInt(base + 1); + } + } + } + return bonus; + } + + @Override + public float knockback (float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) + { + float bonus = 0f; + if (toolTags.hasKey("Knockback")) + { + float level = toolTags.getFloat("Knockback"); + bonus += level; + } + return bonus; + } + + public boolean doesCriticalHit (ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) + { + if (tool == TContent.cutlass && random.nextInt(10) == 0) + return true; + return false; + } +} diff --git a/tconstruct/plugins/minefactoryreloaded/MineFactoryReloaded.java b/tconstruct/plugins/minefactoryreloaded/MineFactoryReloaded.java new file mode 100644 index 00000000..2ba82751 --- /dev/null +++ b/tconstruct/plugins/minefactoryreloaded/MineFactoryReloaded.java @@ -0,0 +1,53 @@ +package tconstruct.plugins.minefactoryreloaded; + +import net.minecraft.item.ItemStack; +import powercrystals.minefactoryreloaded.api.FarmingRegistry; +import tconstruct.common.TContent; +import tconstruct.entity.BlueSlime; +import tconstruct.plugins.minefactoryreloaded.grindables.GrindableStandard; +import tconstruct.plugins.minefactoryreloaded.harvestables.HarvestableOreBerry; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.Init; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.network.NetworkMod; + +@Mod(modid = "TConstruct|CompatMineFactoryReloaded", name = "TConstruct Compat: MFR", version = "0.1", dependencies = "after:MineFactoryReloaded;after:TConstruct") +@NetworkMod(clientSideRequired = false, serverSideRequired = false) +public class MineFactoryReloaded +{ + @Init + public static void load (FMLInitializationEvent ev) + { + if (!Loader.isModLoaded("MineFactoryReloaded")) + { + FMLLog.warning("MineFactoryReloaded missing - TConstruct Compat: MFR not loading."); + return; + } + try + { + FMLLog.fine("MineFactoryReloaded detected. Registering TConstruct farmables/grindables with MFR's Farming Registry."); + + FarmingRegistry.registerHarvestable(new HarvestableOreBerry(TContent.oreBerry.blockID, TContent.oreBerries.itemID, 0)); + FarmingRegistry.registerHarvestable(new HarvestableOreBerry(TContent.oreBerrySecond.blockID, TContent.oreBerries.itemID, 4)); + + // A note: in 1.6, this method of registering grindables will no longer exist, once MFR moves to a more universal way of gathering drops. + FarmingRegistry.registerGrindable(new GrindableStandard(BlueSlime.class, new ItemStack(TContent.strangeFood))); + //FarmingRegistry.registerGrindable(new GrindableStandard(Crystal.class, new ItemStack(Item.gunpowder))); + //FarmingRegistry.registerGrindable(new GrindableStandard(MetalSlime.class, new ItemStack(TContent.strangeFood))); + //FarmingRegistry.registerGrindable(new GrindableStandard(NitroCreeper.class, new ItemStack(Item.gunpowder))); + //FarmingRegistry.registerGrindable(new GrindableStandard(Skyla.class, new ItemStack(Item.gunpowder))); + + /* + * Perhaps TC ores should be registered as drops from the MFR Laser Drill here, but I don't know which things would be suitable for that. + * Syntax: FarmingRegistry.registerLaserOre(int weight, ItemStack droppedStack)); + * Currently used weights are from about 50 (emerald) to 175 (coal). + */ + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/tconstruct/plugins/minefactoryreloaded/grindables/GrindableStandard.java b/tconstruct/plugins/minefactoryreloaded/grindables/GrindableStandard.java new file mode 100644 index 00000000..39861bed --- /dev/null +++ b/tconstruct/plugins/minefactoryreloaded/grindables/GrindableStandard.java @@ -0,0 +1,52 @@ +package tconstruct.plugins.minefactoryreloaded.grindables; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import powercrystals.minefactoryreloaded.api.IFactoryGrindable; +import powercrystals.minefactoryreloaded.api.MobDrop; + +public class GrindableStandard implements IFactoryGrindable +{ + private Class _grindableClass; + private List _drops; + + public GrindableStandard(Class entityToGrind, MobDrop[] dropStacks) + { + _grindableClass = entityToGrind; + _drops = new ArrayList(); + for (MobDrop d : dropStacks) + { + _drops.add(d); + } + } + + public GrindableStandard(Class entityToGrind, ItemStack dropStack) + { + _grindableClass = entityToGrind; + _drops = new ArrayList(); + _drops.add(new MobDrop(10, dropStack)); + } + + public GrindableStandard(Class entityToGrind) + { + _grindableClass = entityToGrind; + _drops = new ArrayList(); + } + + @Override + public Class getGrindableEntity () + { + return _grindableClass; + } + + @Override + public List grind (World world, EntityLiving entity, Random random) + { + return _drops; + } +} diff --git a/tconstruct/plugins/minefactoryreloaded/harvestables/HarvestableOreBerry.java b/tconstruct/plugins/minefactoryreloaded/harvestables/HarvestableOreBerry.java new file mode 100644 index 00000000..e822ad4e --- /dev/null +++ b/tconstruct/plugins/minefactoryreloaded/harvestables/HarvestableOreBerry.java @@ -0,0 +1,67 @@ +package tconstruct.plugins.minefactoryreloaded.harvestables; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import powercrystals.minefactoryreloaded.api.HarvestType; +import powercrystals.minefactoryreloaded.api.IFactoryHarvestable; + +public class HarvestableOreBerry implements IFactoryHarvestable +{ + private int _sourceBlockId; + private int _berryItemId; + private int _metaOffset; + + public HarvestableOreBerry(int sourceBlockId, int berryItemId, int metaOffset) + { + _sourceBlockId = sourceBlockId; + _berryItemId = berryItemId; + _metaOffset = metaOffset; + } + + @Override + public int getPlantId () + { + return _sourceBlockId; + } + + @Override + public HarvestType getHarvestType () + { + return HarvestType.Column; + } + + @Override + public boolean breakBlock () + { + return false; + } + + @Override + public boolean canBeHarvested (World world, Map harvesterSettings, int x, int y, int z) + { + return world.getBlockMetadata(x, y, z) >= 12; + } + + @Override + public List getDrops (World world, Random rand, Map harvesterSettings, int x, int y, int z) + { + ItemStack[] returnItems = { new ItemStack(_berryItemId, 1, world.getBlockMetadata(x, y, z) % 4 + _metaOffset) }; + return Arrays.asList(returnItems); + } + + @Override + public void preHarvest (World world, int x, int y, int z) + { + } + + @Override + public void postHarvest (World world, int x, int y, int z) + { + world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 4, 2); + } +} diff --git a/tconstruct/skill/Jump.java b/tconstruct/skill/Jump.java new file mode 100644 index 00000000..e5d23c2a --- /dev/null +++ b/tconstruct/skill/Jump.java @@ -0,0 +1,33 @@ +package tconstruct.skill; + +import net.minecraft.entity.Entity; +import net.minecraft.world.World; + +public class Jump extends Skill +{ + @Override + public String getTextureFile (int guiscale) + { + /*if (guiscale == 2) + return "/mods/tinker/textures/skill/Jump32x.png"; + if (guiscale == 3) + return "/mods/tinker/textures/skill/Jump48x.png"; + + return "/mods/tinker/textures/skill/Jump16x.png";*/ + return "/mods/tinker/textures/skill/Jump48x.png"; + } + + @Override + public String getSkillName () + { + return "Jump"; + } + + @Override + public void activate (Entity entity, World world) + { + if (entity.onGround) + entity.motionY = 0.8f; + } + +} diff --git a/tconstruct/skill/Skill.java b/tconstruct/skill/Skill.java new file mode 100644 index 00000000..dc1c4922 --- /dev/null +++ b/tconstruct/skill/Skill.java @@ -0,0 +1,78 @@ +package tconstruct.skill; + +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +/* Base skill + * + */ + +public abstract class Skill +{ + public int skillID; + boolean active = true; + + public abstract String getTextureFile (int guiscale); + + public abstract String getSkillName (); + + public abstract void activate (Entity entity, World world); + + public void rightClickActivate (Entity entity, World world) + { + }; + + public int chargeTime () //Ticks + { + return 0; + } + + public boolean canEntityUseSkill (Entity entity) + { + return true; + } + + public int getSkillCost () + { + return 0; + } + + public void setActive (boolean flag) + { + this.active = flag; + } + + public boolean getActive () + { + return active; + } + + public Skill copy () throws InstantiationException, IllegalAccessException + { + Skill skill = this.getClass().newInstance(); + skill.setSkillID(this.skillID); + return skill; + } + + public void setSkillID (int i) + { + skillID = i; + } + + public int getSkillID () + { + return skillID; + } + + /* Save/Load */ + public void saveToNBT (NBTTagCompound tag) + { + + } + + public void readFromNBT (NBTTagCompound tag) + { + + } +} diff --git a/tconstruct/skill/SkillRegistry.java b/tconstruct/skill/SkillRegistry.java new file mode 100644 index 00000000..b8e7a545 --- /dev/null +++ b/tconstruct/skill/SkillRegistry.java @@ -0,0 +1,22 @@ +package tconstruct.skill; + +import java.util.HashMap; + +public class SkillRegistry +{ + public static HashMap skills = new HashMap(); + + static int skillID = 0; + public static HashMap skillMapping = new HashMap(); //Simplifies network transmission + + public static void registerSkill (String name, Skill skill) + { + skills.put(name, skill); + skillMapping.put(getNextAvailableID(), skill); + } + + static Integer getNextAvailableID () + { + return skillID++; + } +} diff --git a/tconstruct/skill/WallBuilding.java b/tconstruct/skill/WallBuilding.java new file mode 100644 index 00000000..0429fa3f --- /dev/null +++ b/tconstruct/skill/WallBuilding.java @@ -0,0 +1,132 @@ +package tconstruct.skill; + +import tconstruct.library.tools.AbilityHelper; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class WallBuilding extends Skill +{ + @Override + public String getTextureFile (int guiscale) + { + if (guiscale == 2) + return "/mods/tinker/textures/skill/Wall32x.png"; + if (guiscale == 3) + return "/mods/tinker/textures/skill/Wall48x.png"; + + return "/mods/tinker/textures/skill/Wall16x.png"; + } + + @Override + public String getSkillName () + { + return "Wall Building"; + } + + @Override + public void activate (Entity entity, World world) + { + this.active = !active; + } + + @Override + public void rightClickActivate (Entity entity, World world) + { + if (!world.isRemote && active) + { + if (entity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) entity; + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.getItem() instanceof ItemBlock) + { + MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, entity, true, 6); + + if (mop != null) + { + int xPos = mop.blockX; + int yPos = mop.blockY; + int zPos = mop.blockZ; + /*ForgeDirection sideHit = ForgeDirection.getOrientation(mop.sideHit); + switch (sideHit) + { + case UP: + yPos += 1; + break; + case DOWN: + yPos -= 1; + break; + case NORTH: + zPos -= 1; + break; + case SOUTH: + zPos += 1; + break; + case EAST: + xPos += 1; + break; + case WEST: + xPos -= 1; + break; + default: + break; + }*/ + + int facing = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int xMin = 0; + int xMax = 0; + int zMin = 0; + int zMax = 0; + if (facing % 2 == 0) + { + xMin = -1; + xMax = 1; + } + else + { + zMin = -1; + zMax = 1; + } + + for (int y = -1; y <= 1; y++) + { + for (int x = xMin; x <= xMax; x++) + { + for (int z = zMin; z <= zMax; z++) + { + stack.getItem().onItemUse(stack, player, world, xPos + x, yPos + y, zPos + z, mop.sideHit, 0, 0, 0); + if (stack.stackSize < 1) + { + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + break; + } + //world.setBlock(xPos + x, yPos + y, zPos + z, Block.whiteStone.blockID); + } + } + } + //entity.worldObj.setBlock(xPos, yPos, zPos, Block.stone.blockID, 0, 3); + world.playAuxSFX(2001, xPos, yPos, zPos, Block.stone.blockID + (0 << 12)); + } + } + } + /*for (int x = -2; x <= 2; x++) + { + for (int y = -1; y <= 1; y++) + { + //for (int z = -2; z <= 2; z++) + { + world.setBlock((int) Math.floor(entity.posX) + x, (int) Math.floor(entity.posY) + y, (int) Math.floor(entity.posZ) + 2, Block.whiteStone.blockID); + } + } + } + world.playAuxSFX(2001, (int) entity.posX, (int) entity.posY, (int) entity.posZ, Block.stone.blockID + (0 << 12));*/ + } + } + +} diff --git a/tconstruct/util/PHConstruct.java b/tconstruct/util/PHConstruct.java new file mode 100644 index 00000000..ee8a9306 --- /dev/null +++ b/tconstruct/util/PHConstruct.java @@ -0,0 +1,619 @@ +package tconstruct.util; + +import java.io.File; +import java.io.IOException; + +import net.minecraftforge.common.Configuration; + +public class PHConstruct +{ + + public static void initProps (File location) + { + /* Here we will set up the config file for the mod + * First: Create a folder inside the config folder + * Second: Create the actual config file + * Note: Configs are a pain, but absolutely necessary for every mod. + */ + //File file = new File(TConstruct.proxy.getLocation() + "/config"); + //file.mkdir(); + //File newFile = new File(TConstruct.proxy.getLocation() + "/config/TinkersWorkshop.txt"); + File newFile = new File(location + "/TinkersWorkshop.txt"); + + /* Some basic debugging will go a long way */ + try + { + newFile.createNewFile(); + } + catch (IOException e) + { + System.out.println("Could not create configuration file for TConstruct. Reason:"); + System.out.println(e); + } + + /* [Forge] Configuration class, used as config method */ + Configuration config = new Configuration(newFile); + + /* Load the configuration file */ + config.load(); + + /* Define the mod's IDs. + * Avoid values below 4096 for items and in the 250-450 range for blocks + */ + + //removeToolRecipes = config.get("Diffuclty Changes", "Remove vanilla tool recipes", false).getBoolean(false); + keepHunger = config.get("Difficulty Changes", "Keep hunger on death", true).getBoolean(true); + keepLevels = config.get("Difficulty Changes", "Keep levels on death", true).getBoolean(true); + beginnerBook = config.get("Difficulty Changes", "Spawn beginner book", true).getBoolean(true); + + superfunWorld = config.get("Superfun", "All the world is Superfun", false).getBoolean(false); + + /*disableWoodTools = config.get("Difficulty Changes", "Disable vanilla wooden tools", false).getBoolean(false); + disableStoneTools = config.get("Difficulty Changes", "Disable vanilla stone tools", true).getBoolean(true); + disableIronTools = config.get("Difficulty Changes", "Disable vanilla iron tools", true).getBoolean(true); + disableDiamondTools = config.get("Difficulty Changes", "Disable vanilla diamond tools", true).getBoolean(true); + disableGoldTools = config.get("Difficulty Changes", "Disable vanilla gold tools", true).getBoolean(true);*/ + + enableTWood = config.get("Difficulty Changes", "Enable mod wooden tools", true).getBoolean(true); + enableTStone = config.get("Difficulty Changes", "Enable mod stone tools", true).getBoolean(true); + enableTCactus = config.get("Difficulty Changes", "Enable mod cactus tools", true).getBoolean(true); + enableTBone = config.get("Difficulty Changes", "Enable mod bone tools", true).getBoolean(true); + enableTFlint = config.get("Difficulty Changes", "Enable mod flint tools", true).getBoolean(true); + enableTNetherrack = config.get("Difficulty Changes", "Enable mod netherrack tools", true).getBoolean(true); + enableTSlime = config.get("Difficulty Changes", "Enable mod slime tools", true).getBoolean(true); + enableTPaper = config.get("Difficulty Changes", "Enable mod paper tools", true).getBoolean(true); + enableTBlueSlime = config.get("Difficulty Changes", "Enable mod blue slime tools", true).getBoolean(true); + + craftMetalTools = config.get("Difficulty Changes", "Craft metals with Wood Patterns", false).getBoolean(false); + vanillaMetalBlocks = config.get("Difficulty Changes", "Craft vanilla metal blocks", true).getBoolean(true); + lavaFortuneInteraction = config.get("Difficulty Changes", "Enable Auto-Smelt and Fortune interaction", true).getBoolean(true); + removeVanillaToolRecipes = config.get("Difficulty Changes", "Remove Vanilla Tool Recipes", false).getBoolean(false); + deGreg = config.get("Difficulty Changes", "Remove Vanilla GregTech Nerfs", true).getBoolean(true); + harderBronze = config.get("Difficulty Changes", "Lower bronze output to 2 ingots", false).getBoolean(false); + stencilTableCrafting = config.get("Difficulty Changes", "Craft Stencil Tables", true).getBoolean(true); + miningLevelIncrease = config.get("Difficulty Changes", "Modifiers increase Mining Level", true).getBoolean(true); + denyMattock = config.get("Difficulty Changes", "Deny creation of non-metal mattocks", false).getBoolean(false); + + blueSlime = config.get("Mob Spawning", "Activate Blue Slime Spawns", true).getBoolean(true); + blueSlimeWeight = config.get("Mob Spawning", "Spawn Weight for Blue Slime", 6).getInt(6); + + woodCrafter = config.getBlock("Wood Tool Station", 1471).getInt(1471); + heldItemBlock = config.getBlock("Held Item Block", 1472).getInt(1472); + lavaTank = config.getBlock("Lava Tank", 1473).getInt(1473); + smeltery = config.getBlock("Smeltery", 1474).getInt(1474); + oreSlag = config.getBlock("Ores Slag", 1475).getInt(1475); + craftedSoil = config.getBlock("Special Soil", 1476).getInt(1476); + searedTable = config.getBlock("Seared Table", 1477).getInt(1477); + metalBlock = config.getBlock("Metal Storage", 1478).getInt(1478); + /*metalFlowing = config.getBlock("Liquid Metal Flowing", 1479).getInt(1479); + metalStill = config.getBlock("Liquid Metal Still", 1480).getInt(1480);*/ + + multiBrick = config.getBlock("Multi Brick", 1481).getInt(1481); + + stoneTorch = config.getBlock("Stone Torch", 1484).getInt(1484); + oreBerry = config.getBlock("Ore Berry One", 1485).getInt(1485); + oreBerrySecond = config.getBlock("Ore Berry Two", 1486).getInt(1486); + + oreGravel = config.getBlock("Ores Gravel", 1488).getInt(1488); + speedBlock = config.getBlock("Speed Block", 1489).getInt(1489); + + landmine = config.getBlock("Landmine", 1470).getInt(1470); + barricade = config.getBlock("Barricade", 1469).getInt(1469); + toolForge = config.getBlock("Tool Forge", 1468).getInt(1468); + multiBrickFancy = config.getBlock("Multi Brick Fancy", 1467).getInt(1467); + + /*public static int moltenSilver; //Thermal Expansion + public static int moltenLead; + public static int moltenNickel; + public static int moltenPlatinum; + public static int moltenInvar; + public static int moltenElectrum;*/ + + moltenSilver = config.getBlock("Molten Silver", 3195).getInt(3195); + moltenLead = config.getBlock("Molten Lead", 3196).getInt(3196); + moltenNickel = config.getBlock("Molten Nickel", 3197).getInt(3197); + moltenShiny = config.getBlock("Molten Platinum", 3198).getInt(3198); + moltenInvar = config.getBlock("Molten Invar", 3199).getInt(3199); + moltenElectrum = config.getBlock("Molten Electrum", 3200).getInt(3200); + moltenIron = config.getBlock("Molten Iron", 3201).getInt(3201); + moltenGold = config.getBlock("Molten Gold", 3202).getInt(3202); + moltenCopper = config.getBlock("Molten Copper", 3203).getInt(3203); + moltenTin = config.getBlock("Molten Tin", 3204).getInt(3204); + moltenAluminum = config.getBlock("Molten Aluminum", 3205).getInt(3205); + moltenCobalt = config.getBlock("Molten Cobalt", 3206).getInt(3206); + moltenArdite = config.getBlock("Molten Ardite", 3207).getInt(3207); + moltenBronze = config.getBlock("Molten Bronze", 3208).getInt(3208); + moltenAlubrass = config.getBlock("Molten Aluminum Brass", 3209).getInt(3209); + moltenManyullyn = config.getBlock("Molten Manyullyn", 3210).getInt(3210); + moltenAlumite = config.getBlock("Molten Alumite", 3211).getInt(3211); + moltenObsidian = config.getBlock("Molten Obsidian", 3212).getInt(3212); + moltenSteel = config.getBlock("Molten Steel", 3213).getInt(3213); + moltenGlass = config.getBlock("Molten Glass", 3214).getInt(3214); + moltenStone = config.getBlock("Molten Stone", 3215).getInt(3215); + moltenEmerald = config.getBlock("Molten Emerald", 3216).getInt(3216); + blood = config.getBlock("Liquid Cow", 3217).getInt(3217); + moltenSilver = config.getBlock("Molten Silver", 3218).getInt(3218); + moltenLead = config.getBlock("Molten Lead", 3219).getInt(3219); + + aggregator = config.getBlock("Aggregator", 3221).getInt(3221); + lightCrystalBase = config.getBlock("Light Crystal", 3222).getInt(3222); + glass = config.getBlock("Clear Glass", 3223).getInt(3223); + stainedGlass = config.getBlock("Stained Glass", 3224).getInt(3224); + stainedGlassClear = config.getBlock("Clear Stained Glass", 3225).getInt(3225); + redstoneMachine = config.getBlock("Redstone Machines", 3226).getInt(3226); + dryingRack = config.getBlock("Drying Rack", 3227).getInt(3227); + glassPane = config.getBlock("Glass Pane", 3228).getInt(3228); + stainedGlassClearPane = config.getBlock("Clear Stained Glass Pane", 3229).getInt(3229); + + searedSlab = config.getBlock("Seared Slab", 3230).getInt(3230); + speedSlab = config.getBlock("Speed Slab", 3231).getInt(3231); + //grassSlab = config.getBlock("Grass Slab", 3230).getInt(3230); + + /*golemCore = config.getBlock("Golem Core", 1481).getInt(1481); + golemHead = config.getBlock("Golem Head", 1482).getInt(1482);*/ + //golemPedestal = config.getBlock("Golem Pedestal", 1483).getInt(1483); + //redstoneBallRepeater = config.getBlock("Redstone Ball Repeater", 1483).getInt(1483); + //netherOreBerry = config.getBlock("Ore Berry Nether", 1487).getInt(1487); + + manual = config.getItem("Patterns and Misc", "Tinker's Manual", 14018).getInt(14018); + blankPattern = config.getItem("Patterns and Misc", "Blank Patterns", 14019).getInt(14019); + materials = config.getItem("Patterns and Misc", "Materials", 14020).getInt(14020); + toolRod = config.getItem("Patterns and Misc", "Tool Rod", 14021).getInt(14021); + toolShard = config.getItem("Patterns and Misc", "Tool Shard", 14022).getInt(14022); + woodPattern = config.getItem("Patterns and Misc", "Wood Pattern", 14023).getInt(14023); + metalPattern = config.getItem("Patterns and Misc", "Metal Pattern", 14024).getInt(14024); + + pickaxeHead = config.getItem("Tool Parts", "Pickaxe Head", 14026).getInt(14026); + shovelHead = config.getItem("Tool Parts", "Shovel Head", 14027).getInt(14027); + axeHead = config.getItem("Tool Parts", "Axe Head", 14028).getInt(14028); + hoeHead = config.getItem("Tool Parts", "Hoe Head", 14029).getInt(14029); + + swordBlade = config.getItem("Tool Parts", "Sword Blade", 14030).getInt(14030); + largeGuard = config.getItem("Tool Parts", "Large Guard", 14031).getInt(14031); + medGuard = config.getItem("Tool Parts", "Medium Guard", 14032).getInt(14032); + crossbar = config.getItem("Tool Parts", "Crossbar", 14033).getInt(14033); + binding = config.getItem("Tool Parts", "Tool Binding", 14034).getInt(14034); + + frypanHead = config.getItem("Tool Parts", "Frypan Head", 14035).getInt(14035); + signHead = config.getItem("Tool Parts", "Sign Head", 14036).getInt(14036); + + lumberHead = config.getItem("Tool Parts", "Lumber Axe Head", 14037).getInt(14037); + knifeBlade = config.getItem("Tool Parts", "Knife Blade", 14038).getInt(14038); + chiselHead = config.getItem("Tool Parts", "Chisel Head", 14039).getInt(14039); + scytheBlade = config.getItem("Tool Parts", "Scythe Head", 14040).getInt(14040); + toughBinding = config.getItem("Tool Parts", "Tough Binding", 14041).getInt(14041); + toughRod = config.getItem("Tool Parts", "Tough Rod", 14042).getInt(14042); + largeSwordBlade = config.getItem("Tool Parts", "Large Sword Blade", 14043).getInt(14043); + largePlate = config.getItem("Tool Parts", "Large Plate", 14044).getInt(14044); + excavatorHead = config.getItem("Tool Parts", "Excavator Head", 14045).getInt(14045); + hammerHead = config.getItem("Tool Parts", "Hammer Head", 14046).getInt(14046); + fullGuard = config.getItem("Tool Parts", "Full Guard", 14047).getInt(14047); + bowstring = config.getItem("Tool Parts", "Bowstring", 14048).getInt(14048); + arrowhead = config.getItem("Tool Parts", "Arrowhead", 14049).getInt(14049); + fletching = config.getItem("Tool Parts", "Fletching", 14050).getInt(14050); + + pickaxe = config.getItem("Tools", "Pickaxe", 14051).getInt(14051); + shovel = config.getItem("Tools", "Shovel", 14052).getInt(14052); + axe = config.getItem("Tools", "Axe", 14053).getInt(14053); + hoe = config.getItem("Tools", "Hoe", 14054).getInt(14054); + + broadsword = config.getItem("Tools", "Broadsword", 14055).getInt(14055); + rapier = config.getItem("Tools", "Rapier", 14057).getInt(14057); + longsword = config.getItem("Tools", "Longsword", 14056).getInt(14056); + dagger = config.getItem("Tools", "Dagger", 14065).getInt(14065); + + frypan = config.getItem("Tools", "Frying Pan", 14058).getInt(14058); + battlesign = config.getItem("Tools", "Battlesign", 14059).getInt(14059); + mattock = config.getItem("Tools", "Mattock", 14060).getInt(14060); + lumberaxe = config.getItem("Tools", "Lumber Axe", 14061).getInt(14061); + longbow = config.getItem("Tools", "Longbow", 14062).getInt(14062); + shortbow = config.getItem("Tools", "Shortbow", 14063).getInt(14063); + potionLauncher = config.getItem("Tools", "Potion Launcher", 14064).getInt(14064); + + chisel = config.getItem("Tools", "Chisel", 14066).getInt(14066); + scythe = config.getItem("Tools", "Scythe", 14067).getInt(14067); + cleaver = config.getItem("Tools", "Cleaver", 14068).getInt(14068); + excavator = config.getItem("Tools", "Excavator", 14069).getInt(14069); + hammer = config.getItem("Tools", "Hammer", 14070).getInt(14070); + battleaxe = config.getItem("Tools", "Battleaxe", 14071).getInt(14071); + + cutlass = config.getItem("Tools", "Cutlass", 14072).getInt(14072); + arrow = config.getItem("Tools", "Arrow", 14073).getInt(14073); + + buckets = config.getItem("Patterns and Misc", "Buckets", 14101).getInt(14101); + uselessItem = config.getItem("Patterns and Misc", "Title Icon", 14102).getInt(14102); + slimefood = config.getItem("Patterns and Misc", "Strange Food", 14103).getInt(14103); + oreChunks = config.getItem("Patterns and Misc", "Ore Chunks", 14104).getInt(14104); + + heartCanister = config.getItem("Equipables", "Heart Canister", 14105).getInt(14105); + heavyHelmet = config.getItem("Equipables", "Heavy Helmet", 14106).getInt(14106); + diamondApple = config.getItem("Patterns and Misc", "Jeweled Apple", 14107).getInt(14107); + heavyChestplate = config.getItem("Equipables", "Heavy Chestplate", 14108).getInt(14108); + heavyPants = config.getItem("Equipables", "Heavy Pants", 14109).getInt(14109); + heavyBoots = config.getItem("Equipables", "Heavy Boots", 14110).getInt(14110); + glove = config.getItem("Equipables", "Gloves", 14111).getInt(14111); + knapsack = config.getItem("Equipables", "Knapsack", 14112).getInt(14112); + goldHead = config.getItem("Patterns and Misc", "Golden Head", 14113).getInt(14113); + + boolean ic2 = true; + boolean xycraft = true; + try + { + Class c = Class.forName("ic2.core.IC2"); + ic2 = false; + } + catch (Exception e) + { + } + try + { + Class c = Class.forName("soaryn.xycraft.core.XyCraft"); + xycraft = false; + } + catch (Exception e) + { + } + + generateCopper = config.get("Worldgen Disabler", "Generate Copper", ic2).getBoolean(ic2); + generateTin = config.get("Worldgen Disabler", "Generate Tin", ic2).getBoolean(ic2); + generateAluminum = config.get("Worldgen Disabler", "Generate Aluminum", xycraft).getBoolean(xycraft); + generateNetherOres = config.get("Worldgen Disabler", "Generate Cobalt and Ardite", true).getBoolean(true); + + generateIronSurface = config.get("Worldgen Disabler", "Generate Surface Iron", true).getBoolean(true); + generateGoldSurface = config.get("Worldgen Disabler", "Generate Surface Gold", true).getBoolean(true); + generateCopperSurface = config.get("Worldgen Disabler", "Generate Surface Copper", true).getBoolean(true); + generateTinSurface = config.get("Worldgen Disabler", "Generate Surface Tin", true).getBoolean(true); + generateAluminumSurface = config.get("Worldgen Disabler", "Generate Surface Aluminum", true).getBoolean(true); + + generateIronBush = config.get("Worldgen Disabler", "Generate Iron Bushes", true).getBoolean(true); + generateGoldBush = config.get("Worldgen Disabler", "Generate Gold Bushes", true).getBoolean(true); + generateCopperBush = config.get("Worldgen Disabler", "Generate Copper Bushes", true).getBoolean(true); + generateTinBush = config.get("Worldgen Disabler", "Generate Tin Bushes", true).getBoolean(true); + generateAluminumBush = config.get("Worldgen Disabler", "Generate Aluminum Bushes", true).getBoolean(true); + generateEssenceBush = config.get("Worldgen Disabler", "Generate Essence Bushes", true).getBoolean(true); + addToVillages = config.get("Worldgen Disabler", "Add Village Generation", true).getBoolean(true); + + copperuDensity = config.get("Worldgen", "Copper Underground Density", 2).getInt(2); + tinuDensity = config.get("Worldgen", "Tin Underground Density", 2).getInt(2); + aluminumuDensity = config.get("Worldgen", "Aluminum Underground Density", 3).getInt(3); + netherDensity = config.get("Worldgen", "Nether Ores Density", 8).getInt(8); + + copperuMinY = config.get("Worldgen", "Copper Underground Min Y", 20).getInt(20); + copperuMaxY = config.get("Worldgen", "Copper Underground Max Y", 60).getInt(60); + tinuMinY = config.get("Worldgen", "Tin Underground Min Y", 0).getInt(0); + tinuMaxY = config.get("Worldgen", "Tin Underground Max Y", 40).getInt(40); + aluminumuMinY = config.get("Worldgen", "Aluminum Underground Min Y", 0).getInt(0); + aluminumuMaxY = config.get("Worldgen", "Aluminum Underground Max Y", 64).getInt(64); + + ironsRarity = config.get("Worldgen", "Iron Surface Rarity", 400).getInt(400); + goldsRarity = config.get("Worldgen", "Gold Surface Rarity", 900).getInt(900); + coppersRarity = config.get("Worldgen", "Copper Surface Rarity", 100).getInt(100); + tinsRarity = config.get("Worldgen", "Tin Surface Rarity", 100).getInt(100); + aluminumsRarity = config.get("Worldgen", "Aluminum Surface Rarity", 50).getInt(50); + cobaltsRarity = config.get("Worldgen", "Cobalt Surface Rarity", 2000).getInt(2000); + + ironBushDensity = config.get("Worldgen", "Iron Bush Density", 1).getInt(1); + goldBushDensity = config.get("Worldgen", "Gold Bush Density", 1).getInt(1); + copperBushDensity = config.get("Worldgen", "Copper Bush Density", 2).getInt(2); + tinBushDensity = config.get("Worldgen", "Tin Bush Density", 2).getInt(2); + aluminumBushDensity = config.get("Worldgen", "Aluminum Bush Density", 2).getInt(2); + silverBushDensity = config.get("Worldgen", "Silver Bush Density", 1).getInt(1); + + ironBushRarity = config.get("Worldgen", "Iron Bush Rarity", 5).getInt(5); + goldBushRarity = config.get("Worldgen", "Gold Bush Rarity", 8).getInt(8); + copperBushRarity = config.get("Worldgen", "Copper Bush Rarity", 3).getInt(3); + tinBushRarity = config.get("Worldgen", "Tin Bush Rarity", 3).getInt(3); + aluminumBushRarity = config.get("Worldgen", "Aluminum Bush Rarity", 2).getInt(2); + essenceBushRarity = config.get("Worldgen", "Essence Bush Rarity", 6).getInt(6); + + copperBushMinY = config.get("Worldgen", "Copper Bush Min Y", 20).getInt(20); + copperBushMaxY = config.get("Worldgen", "Copper Bush Max Y", 60).getInt(60); + tinBushMinY = config.get("Worldgen", "Tin Bush Min Y", 0).getInt(0); + tinBushMaxY = config.get("Worldgen", "Tin Bush Max Y", 40).getInt(40); + aluminumBushMinY = config.get("Worldgen", "Aluminum Bush Min Y", 0).getInt(0); + aluminumBushMaxY = config.get("Worldgen", "Aluminum Bush Max Y", 60).getInt(60); + + seaLevel = config.get("general", "Sea level", 64).getInt(64); + + enableHealthRegen = config.get("Ultra Hardcore Changes", "Passive Health Regen", true).getBoolean(true); //Check + goldAppleRecipe = config.get("Ultra Hardcore Changes", "Change Crafting Recipes", false).getBoolean(false); //Check + dropPlayerHeads = config.get("Ultra Hardcore Changes", "Players drop heads on death", false).getBoolean(false); //Check + uhcGhastDrops = config.get("Ultra Hardcore Changes", "Change Ghast drops to Gold Ingots", false).getBoolean(false); //Check + worldBorder = config.get("Ultra Hardcore Changes", "Add World Border", false).getBoolean(false); + worldBorderSize = config.get("Ultra Hardcore Changes", "World Border Radius", 1000).getInt(1000); + freePatterns = config.get("Ultra Hardcore Changes", "Add Patterns to Pattern Chests", false).getBoolean(false); //Check + + /* Save the configuration file */ + config.save(); + + File gt = new File(location + "/GregTech"); + if (gt.exists()) + { + File gtDyn = new File(location + "/GregTech/DynamicConfig.cfg"); + Configuration gtConfig = new Configuration(gtDyn); + gtConfig.load(); + gregtech = gtConfig.get("smelting", "tile.anvil.slightlyDamaged", false).getBoolean(false); + } + } + + //Blocks + public static int woodCrafter; + public static int toolForge; + public static int heldItemBlock; + public static int ores; + public static int lavaTank; + public static int smeltery; + public static int searedTable; + public static int craftedSoil; + public static int oreSlag; + public static int oreGravel; + public static int metalBlock; + + public static int redstoneMachine; + public static int dryingRack; + + /*public static int golemCore; + public static int golemHead; + public static int golemPedestal;*/ + + //Crops + public static int oreBerry; + public static int oreBerrySecond; + public static int netherOreBerry; + + //Traps + public static int landmine; + public static int barricade; + + //InfiBlocks + public static int speedBlock; + public static int glass; + public static int glassPane; + public static int stainedGlass; + public static int stainedGlassClear; + public static int stainedGlassClearPane; + + //Crystalline + public static int aggregator; + public static int lightCrystalBase; + + //Liquids + public static int metalFlowing; + public static int metalStill; + + public static int moltenIron; + public static int moltenGold; + public static int moltenCopper; + public static int moltenTin; + public static int moltenAluminum; + public static int moltenCobalt; + public static int moltenArdite; + public static int moltenBronze; + public static int moltenAlubrass; + public static int moltenManyullyn; + public static int moltenAlumite; + public static int moltenObsidian; + public static int moltenSteel; + public static int moltenGlass; + public static int moltenStone; + public static int moltenEmerald; + public static int blood; + public static int moltenSilver; //Thermal Expansion + public static int moltenLead; + public static int moltenNickel; + public static int moltenShiny; + public static int moltenInvar; + public static int moltenElectrum; + + //Decoration + public static int stoneTorch; + public static int multiBrick; + public static int multiBrickFancy; + public static int redstoneBallRepeater; + public static int searedSlab; + public static int speedSlab; + + //Patterns and misc + public static int blankPattern; + public static int materials; + public static int toolRod; + public static int toolShard; + public static int woodPattern; + public static int metalPattern; + + public static int manual; + public static int buckets; + public static int uselessItem; + public static int oreChunks; + + //Food + public static int diamondApple; + public static int slimefood; + + //Tools + public static int pickaxe; + public static int shovel; + public static int axe; + public static int hoe; + + public static int broadsword; + public static int longsword; + public static int rapier; + public static int dagger; + public static int cutlass; + + public static int frypan; + public static int battlesign; + public static int longbow; + public static int shortbow; + public static int potionLauncher; + public static int mattock; + + public static int lumberaxe; + public static int scythe; + public static int cleaver; + public static int excavator; + public static int hammer; + public static int battleaxe; + + public static int chisel; + public static int arrow; + + //Tool parts + public static int swordBlade; + public static int largeGuard; + public static int medGuard; + public static int crossbar; + public static int knifeBlade; + public static int fullGuard; + + public static int pickaxeHead; + public static int axeHead; + public static int shovelHead; + public static int hoeHead; + + public static int frypanHead; + public static int signHead; + public static int chiselHead; + + public static int scytheBlade; + public static int lumberHead; + public static int largeSwordBlade; + public static int excavatorHead; + public static int hammerHead; + + public static int binding; + public static int toughBinding; + public static int toughRod; + public static int largePlate; + + public static int bowstring; + public static int arrowhead; + public static int fletching; + + //Wearables + public static int heavyHelmet; + public static int heavyChestplate; + public static int heavyPants; + public static int heavyBoots; + public static int glove; + public static int knapsack; + + public static int heartCanister; + + //Ore values + public static boolean generateCopper; + public static boolean generateTin; + public static boolean generateAluminum; + public static boolean generateNetherOres; + + public static boolean generateIronSurface; + public static boolean generateGoldSurface; + public static boolean generateCopperSurface; + public static boolean generateTinSurface; + public static boolean generateAluminumSurface; + public static boolean generateCobaltSurface; + + public static boolean generateIronBush; + public static boolean generateGoldBush; + public static boolean generateCopperBush; + public static boolean generateTinBush; + public static boolean generateAluminumBush; + public static boolean generateEssenceBush; + + public static boolean addToVillages; + + public static int copperuDensity; + public static int tinuDensity; + public static int aluminumuDensity; + public static int netherDensity; + + public static int ironsRarity; + public static int goldsRarity; + public static int coppersRarity; + public static int tinsRarity; + public static int aluminumsRarity; + public static int cobaltsRarity; + + public static int ironBushDensity; + public static int goldBushDensity; + public static int copperBushDensity; + public static int tinBushDensity; + public static int aluminumBushDensity; + public static int silverBushDensity; + + public static int ironBushRarity; + public static int goldBushRarity; + public static int copperBushRarity; + public static int tinBushRarity; + public static int aluminumBushRarity; + public static int essenceBushRarity; + + public static int copperuMinY; + public static int copperuMaxY; + public static int tinuMinY; + public static int tinuMaxY; + public static int aluminumuMinY; + public static int aluminumuMaxY; + + public static int copperBushMinY; + public static int copperBushMaxY; + public static int tinBushMinY; + public static int tinBushMaxY; + public static int aluminumBushMinY; + public static int aluminumBushMaxY; + + public static int seaLevel; + + //Mobs + public static boolean blueSlime; + public static int blueSlimeWeight; + + //Difficulty modifiers + public static boolean keepHunger; + public static boolean keepLevels; + public static boolean clearWater; + public static boolean voidFog; + + public static boolean disableWoodTools; + public static boolean disableStoneTools; + public static boolean disableIronTools; + public static boolean disableDiamondTools; + public static boolean disableGoldTools; + + public static boolean enableTWood; + public static boolean enableTStone; + public static boolean enableTCactus; + public static boolean enableTBone; + public static boolean enableTFlint; + public static boolean enableTNetherrack; + public static boolean enableTSlime; + public static boolean enableTPaper; + public static boolean enableTBlueSlime; + + public static boolean craftMetalTools; + public static boolean vanillaMetalBlocks; + public static boolean removeVanillaToolRecipes; + public static boolean harderBronze; + public static boolean stencilTableCrafting; + public static boolean miningLevelIncrease; + public static boolean denyMattock; + + //Ultra Hardcore modifiers + public static boolean enableHealthRegen; + public static boolean goldAppleRecipe; + public static boolean dropPlayerHeads; + public static boolean uhcGhastDrops; + public static boolean worldBorder; + public static int worldBorderSize; + public static boolean freePatterns; + public static int goldHead; + + //Superfun + public static boolean superfunWorld; + public static boolean beginnerBook; + + public static boolean gregtech; + public static boolean lavaFortuneInteraction; + public static boolean deGreg; +} \ No newline at end of file diff --git a/tconstruct/util/RecipeRemover.java b/tconstruct/util/RecipeRemover.java new file mode 100644 index 00000000..ab7771c6 --- /dev/null +++ b/tconstruct/util/RecipeRemover.java @@ -0,0 +1,56 @@ +package tconstruct.util; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; + +public class RecipeRemover +{ + public static void removeShapedRecipes (List removelist) + { + for (ItemStack stack : removelist) + removeShapedRecipe(stack); + } + + public static void removeShapedRecipe (ItemStack resultItem) + { + List recipes = CraftingManager.getInstance().getRecipeList(); + for (int i = 0; i < recipes.size(); i++) + { + IRecipe tmpRecipe = recipes.get(i); + if (tmpRecipe instanceof ShapedRecipes) + { + ShapedRecipes recipe = (ShapedRecipes) tmpRecipe; + ItemStack recipeResult = recipe.getRecipeOutput(); + + if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) + { + recipes.remove(i--); + } + } + } + } + + public static void removeShapelessRecipe (ItemStack resultItem) + { + List recipes = CraftingManager.getInstance().getRecipeList(); + for (int i = 0; i < recipes.size(); i++) + { + IRecipe tmpRecipe = recipes.get(i); + if (tmpRecipe instanceof ShapelessRecipes) + { + ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe; + ItemStack recipeResult = recipe.getRecipeOutput(); + + if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) + { + recipes.remove(i--); + } + } + } + } +} diff --git a/tconstruct/util/SmelteryDamageSource.java b/tconstruct/util/SmelteryDamageSource.java new file mode 100644 index 00000000..9f32108f --- /dev/null +++ b/tconstruct/util/SmelteryDamageSource.java @@ -0,0 +1,41 @@ +package tconstruct.util; + +import tconstruct.library.tools.AbilityHelper; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.DamageSource; +import net.minecraft.util.StatCollector; + +public class SmelteryDamageSource extends DamageSource +{ + public SmelteryDamageSource() + { + super("smeltery"); + } + + public String getDeathMessage (EntityLiving par1EntityLiving) + { + String type = ""; + switch (AbilityHelper.random.nextInt(4)) + { + case 0: + type = "one."; + break; + case 1: + type = "two."; + break; + case 2: + type = "three."; + break; + case 3: + type = "four."; + break; + } + EntityLivingBase entityliving1 = par1EntityLiving.func_94060_bK(); + String s = "death." + type + this.damageType; + String s1 = s + ".player"; + return entityliving1 != null && StatCollector.func_94522_b(s1) ? StatCollector.translateToLocalFormatted(s1, + new Object[] { par1EntityLiving.getTranslatedEntityName(), entityliving1.getTranslatedEntityName() }) : StatCollector.translateToLocalFormatted(s, + new Object[] { par1EntityLiving.getTranslatedEntityName() }); + } +} diff --git a/tconstruct/util/TCraftingHandler.java b/tconstruct/util/TCraftingHandler.java new file mode 100644 index 00000000..5c46ebb8 --- /dev/null +++ b/tconstruct/util/TCraftingHandler.java @@ -0,0 +1,52 @@ +package tconstruct.util; + +import tconstruct.TConstruct; +import tconstruct.common.TContent; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.util.player.TPlayerStats; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.common.ICraftingHandler; + +public class TCraftingHandler implements ICraftingHandler +{ + + @Override + public void onCrafting (EntityPlayer player, ItemStack item, IInventory craftMatrix) + { + if (!player.worldObj.isRemote) + { + int itemID = item.getItem().itemID; + if (itemID == TContent.toolStationWood.blockID) + { + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + NBTTagCompound tags = player.getEntityData().getCompoundTag("TConstruct"); + if (!tags.getBoolean("materialManual") || !stats.materialManual) + { + stats.materialManual = true; + tags.setBoolean("materialManual", true); + AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.manualBook, 1, 1)); + } + } + if (itemID == TContent.smeltery.blockID || itemID == TContent.lavaTank.blockID) + { + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + NBTTagCompound tags = player.getEntityData().getCompoundTag("TConstruct"); + if (!tags.getBoolean("smelteryManual") || !stats.smelteryManual) + { + stats.smelteryManual = true; + tags.setBoolean("smelteryManual", true); + AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.manualBook, 1, 2)); + } + } + } + } + + @Override + public void onSmelting (EntityPlayer player, ItemStack item) + { + } + +} diff --git a/tconstruct/util/TDispenserBehaviorSpawnEgg.java b/tconstruct/util/TDispenserBehaviorSpawnEgg.java new file mode 100644 index 00000000..2b19db29 --- /dev/null +++ b/tconstruct/util/TDispenserBehaviorSpawnEgg.java @@ -0,0 +1,32 @@ +package tconstruct.util; + +import tconstruct.items.TitleIcon; +import net.minecraft.block.BlockDispenser; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; + +public class TDispenserBehaviorSpawnEgg extends BehaviorDefaultDispenseItem +{ + /** + * Dispense the specified stack, play the dispense sound and spawn particles. + */ + public ItemStack dispenseStack (IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata()); + double d0 = par1IBlockSource.getX() + (double) enumfacing.getFrontOffsetX(); + double d1 = (double) ((float) par1IBlockSource.getYInt() + 0.2F); + double d2 = par1IBlockSource.getZ() + (double) enumfacing.getFrontOffsetZ(); + EntityLiving entity = TitleIcon.activateSpawnEgg(par2ItemStack, par1IBlockSource.getWorld(), d0, d1, d2, 0); + + if (par2ItemStack.hasDisplayName()) + { + ((EntityLiving) entity).setCustomNameTag(par2ItemStack.getDisplayName()); + } + + par2ItemStack.splitStack(1); + return par2ItemStack; + } +} diff --git a/tconstruct/util/TEventHandler.java b/tconstruct/util/TEventHandler.java new file mode 100644 index 00000000..80c0f69c --- /dev/null +++ b/tconstruct/util/TEventHandler.java @@ -0,0 +1,1371 @@ +package tconstruct.util; + +import java.util.ArrayList; +import java.util.Random; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.LiquidTextureLogic; +import tconstruct.common.TContent; +import tconstruct.crystal.TheftValueTracker; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.PatternBuilder; +import tconstruct.library.crafting.Smeltery; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.event.PartBuilderEvent; +import tconstruct.library.event.ToolCraftEvent; +import tconstruct.library.tools.ArrowMaterial; +import tconstruct.library.tools.BowMaterial; +import tconstruct.library.tools.BowstringMaterial; +import tconstruct.library.tools.FletchingMaterial; +import tconstruct.library.tools.ToolCore; +import tconstruct.library.util.ValueCoordTuple; +import tconstruct.modifiers.ModAttack; +import tconstruct.util.player.TPlayerStats; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumMovingObjectType; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.event.Event.Result; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingDropsEvent; +import net.minecraftforge.event.entity.living.LivingSpawnEvent; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import net.minecraftforge.event.world.ChunkDataEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent; + +public class TEventHandler +{ + Random random = new Random(); + private Object evt; + + /* Crafting */ + @ForgeSubscribe + public void craftTool (ToolCraftEvent.NormalTool event) + { + NBTTagCompound toolTag = event.toolTag.getCompoundTag("InfiTool"); + if (PHConstruct.denyMattock && event.tool == TContent.mattock) + { + int head = toolTag.getInteger("Head"); + int handle = toolTag.getInteger("Handle"); + int accessory = toolTag.getInteger("Accessory"); + + if (!allowCrafting(head, handle, accessory)) + { + event.setResult(Result.DENY); + return; + } + } + + int thaum = 0; + if (toolTag.getInteger("Head") == 31) + thaum++; + if (toolTag.getInteger("Handle") == 31) + thaum++; + if (toolTag.getInteger("Accessory") == 31) + thaum++; + if (toolTag.getInteger("Extra") == 31) + thaum++; + + if ((thaum >= 3) || (!toolTag.hasKey("Accessory") && thaum >= 2)) + { + int modifiers = toolTag.getInteger("Modifiers"); + modifiers += 2; + toolTag.setInteger("Modifiers", modifiers); + } + else if (thaum >= 1) + { + int modifiers = toolTag.getInteger("Modifiers"); + modifiers += 1; + toolTag.setInteger("Modifiers", modifiers); + } + + if (event.tool == TContent.shortbow) + { + BowMaterial top = TConstructRegistry.getBowMaterial(toolTag.getInteger("Head")); + BowMaterial bottom = TConstructRegistry.getBowMaterial(toolTag.getInteger("Accessory")); + BowstringMaterial string = (BowstringMaterial) TConstructRegistry.getCustomMaterial(toolTag.getInteger("Handle"), BowstringMaterial.class); + + if (top != null && bottom != null && string != null) + { + if (toolTag.getInteger("Handle") == 1) + { + int modifiers = toolTag.getInteger("Modifiers"); + modifiers += 1; + toolTag.setInteger("Modifiers", modifiers); + } + + int durability = (int) ((top.durability + bottom.durability) / 2 * string.durabilityModifier); + toolTag.setInteger("TotalDurability", durability); + toolTag.setInteger("BaseDurability", durability); + + int drawSpeed = (int) ((top.drawspeed + bottom.drawspeed) / 2 * string.drawspeedModifier); + toolTag.setInteger("DrawSpeed", drawSpeed); + toolTag.setInteger("BaseDrawSpeed", drawSpeed); + + float flightSpeed = (top.flightSpeedMax + bottom.flightSpeedMax) / 2f * string.flightSpeedModifier; + toolTag.setFloat("FlightSpeed", flightSpeed); + } + } + + if (event.tool == TContent.arrow) + { + ArrowMaterial head = TConstructRegistry.getArrowMaterial(toolTag.getInteger("Head")); + ArrowMaterial shaft = TConstructRegistry.getArrowMaterial(toolTag.getInteger("Handle")); + FletchingMaterial fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(toolTag.getInteger("Accessory"), FletchingMaterial.class); + + if (head != null && shaft != null && fletching != null) + { + float mass = head.mass / 5f + shaft.mass + fletching.mass; + float shatter = (head.breakChance + shaft.breakChance + fletching.breakChance) / 4f; + float accuracy = (head.accuracy + shaft.accuracy + fletching.accuracy) / 3; + + ItemStack arrow = new ItemStack(event.tool, 4); + toolTag.setInteger("TotalDurability", 0); + toolTag.setFloat("Mass", mass); + toolTag.setFloat("BreakChance", shatter); + toolTag.setFloat("Accuracy", accuracy); + toolTag.setInteger("Unbreaking", 10); + arrow.setTagCompound(event.toolTag); + event.overrideResult(arrow); + } + } + } + + private boolean allowCrafting (int head, int handle, int accessory) + { + int[] nonMetals = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 17 }; + for (int i = 0; i < nonMetals.length; i++) + { + if (head == nonMetals[i] || handle == nonMetals[i] || accessory == nonMetals[i]) + return false; + } + return true; + } + + @ForgeSubscribe + public void craftPart (PartBuilderEvent.NormalPart event) + { + if (event.pattern.getItem() == TContent.woodPattern && event.pattern.getItemDamage() == 23) + { + ItemStack result = craftBowString(event.material); + if (result != null) + { + event.overrideResult(new ItemStack[] { result, null }); + } + } + + if (event.pattern.getItem() == TContent.woodPattern && event.pattern.getItemDamage() == 24) + { + ItemStack result = craftFletching(event.material); + if (result != null) + { + event.overrideResult(new ItemStack[] { result, null }); + } + } + } + + public static ItemStack craftBowString (ItemStack stack) + { + if (stack.stackSize < 3) + return null; + + BowstringMaterial mat = (BowstringMaterial) TConstructRegistry.getCustomMaterial(stack, BowstringMaterial.class); + if (mat != null) + return mat.craftingItem.copy(); + return null; + } + + public static ItemStack craftFletching (ItemStack stack) + { + FletchingMaterial mat = (FletchingMaterial) TConstructRegistry.getCustomMaterial(stack, FletchingMaterial.class); + if (mat != null) + return mat.craftingItem.copy(); + return null; + } + + /* Interact */ + + /*@ForgeSubscribe + public void interact (PlayerInteractEvent event) + { + if (event.action == Action.RIGHT_CLICK_BLOCK)// && !event.entityPlayer.worldObj.isRemote) + { + List skills = TConstruct.playerTracker.getPlayerStats(event.entityPlayer.username).skillList; + if (skills.size() > 0) + { + Skill walls = TConstruct.playerTracker.getPlayerStats(event.entityPlayer.username).skillList.get(0); + walls.rightClickActivate(event.entityPlayer, event.entityPlayer.worldObj); + } + } + }*/ + + /* Damage */ + /*@ForgeSubscribe + public void onHurt (LivingHurtEvent event) + {*/ + /*if (event.entityLiving instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack stack = player.getItemInUse(); + if (stack != null && stack.getItem() == TContent.cutlass) + { + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3*20, 1)); + } + }*/ + /*if (event.source instanceof EntityDamageSource && event.source.damageType.equals("explosion.player") && ((EntityDamageSource) event.source).getEntity() instanceof NitroCreeper) + { + if (event.entityLiving.worldObj.difficultySetting == 3) + event.ammount /= 2.3; + else + event.ammount /= 1.5; + }*/ + //} + + /* Drops */ + @ForgeSubscribe + public void onLivingDrop (LivingDropsEvent event) + { + if (random.nextInt(500) == 0 && event.entityLiving instanceof IMob && event.entityLiving.dimension == 0) + { + ItemStack dropStack = new ItemStack(TContent.heartCanister, 1, 1); + EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack); + entityitem.delayBeforeCanPickup = 10; + event.drops.add(entityitem); + } + + if (event.entityLiving instanceof EntityWither && random.nextInt(5) == 0) + { + ItemStack dropStack = new ItemStack(TContent.heartCanister, 1, 1); + EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack); + entityitem.delayBeforeCanPickup = 10; + event.drops.add(entityitem); + } + + //if (event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) + //{ + if (!event.entityLiving.isChild()) + { + if (event.entityLiving.getClass() == EntityCow.class) + { + int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1; + + for (int iter = 0; iter < amount; ++iter) + { + addDrops(event, new ItemStack(Item.leather, 1)); + } + } + + else if (event.entityLiving.getClass() == EntityChicken.class) + { + int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1; + + for (int iter = 0; iter < amount; ++iter) + { + addDrops(event, new ItemStack(Item.feather, 1)); + } + } + } + + if (event.recentlyHit) + { + if (event.entityLiving.getClass() == EntitySkeleton.class) + { + EntitySkeleton enemy = (EntitySkeleton) event.entityLiving; + + if (event.source.damageType.equals("player")) + { + EntityPlayer player = (EntityPlayer) event.source.getEntity(); + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) + { + int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); + if (stack.getItem() == TContent.cleaver) + beheading += 2; + if (beheading > 0 && random.nextInt(100) < beheading * 10) + { + addDrops(event, new ItemStack(Item.skull.itemID, 1, enemy.getSkeletonType())); + } + } + } + if (enemy.getSkeletonType() == 1 && random.nextInt(Math.max(1, 5 - event.lootingLevel)) == 0) + { + addDrops(event, new ItemStack(TContent.materials, 1, 8)); + } + } + + if (event.entityLiving.getClass() == EntityZombie.class) + { + EntityZombie enemy = (EntityZombie) event.entityLiving; + + if (event.source.damageType.equals("player")) + { + EntityPlayer player = (EntityPlayer) event.source.getEntity(); + ItemStack stack = player.getCurrentEquippedItem(); + + if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) + { + int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); + if (stack.getItem() == TContent.cleaver) + beheading += 2; + if (beheading > 0 && random.nextInt(100) < beheading * 10) + { + addDrops(event, new ItemStack(Item.skull.itemID, 1, 2)); + } + } + /*if (stack.getItem() == TContent.breakerBlade && random.nextInt(100) < 10) //Swap out for real beheading + { + addDrops(event, new ItemStack(Item.skull.itemID, 1, 2)); + }*/ + } + } + + if (event.entityLiving.getClass() == EntityCreeper.class) + { + EntityCreeper enemy = (EntityCreeper) event.entityLiving; + + if (event.source.damageType.equals("player")) + { + EntityPlayer player = (EntityPlayer) event.source.getEntity(); + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) + { + int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); + if (stack.getItem() == TContent.cleaver) + beheading += 2; + if (beheading > 0 && random.nextInt(100) < beheading * 5) + { + addDrops(event, new ItemStack(Item.skull.itemID, 1, 4)); + } + } + } + } + } + + if (event.entityLiving.getClass() == EntityGhast.class) + { + if (PHConstruct.uhcGhastDrops) + { + for (EntityItem o : event.drops) + { + if (o.getEntityItem().itemID == Item.ghastTear.itemID) + { + o.setEntityItemStack(new ItemStack(Item.ingotGold, 1)); + } + } + } + else + { + addDrops(event, new ItemStack(Item.ghastTear, 1)); + } + } + //} + + if (event.entityLiving instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) event.entityLiving; + + if (PHConstruct.dropPlayerHeads) + { + ItemStack dropStack = new ItemStack(Item.skull.itemID, 1, 3); + NBTTagCompound nametag = new NBTTagCompound(); + nametag.setString("SkullOwner", player.username); + addDrops(event, dropStack); + } + + else if (event.source.damageType.equals("player")) + { + EntityPlayer source = (EntityPlayer) event.source.getEntity(); + ItemStack stack = source.getCurrentEquippedItem(); + if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) + { + int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); + if (stack.getItem() == TContent.cleaver) + beheading += 2; + if (beheading > 0 && random.nextInt(100) < beheading * 50) + { + ItemStack dropStack = new ItemStack(Item.skull.itemID, 1, 3); + NBTTagCompound nametag = new NBTTagCompound(); + nametag.setString("SkullOwner", player.username); + addDrops(event, dropStack); + } + } + } + + /*if (!player.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) + { + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + stats.armor.dropItems(); + stats.knapsack.dropItems(); + }*/ + } + } + + @ForgeSubscribe + public void onLivingDeath (LivingDeathEvent event) + { + if (event.entityLiving instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) event.entityLiving; + if (!player.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) + { + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + stats.armor.dropItems(); + stats.knapsack.dropItems(); + } + } + } + + void addDrops (LivingDropsEvent event, ItemStack dropStack) + { + EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack); + entityitem.delayBeforeCanPickup = 10; + event.drops.add(entityitem); + } + + /*@ForgeSubscribe + public void onLivingSpawn (EntityJoinWorldEvent event) + { + if (event.entity instanceof EntityXPOrb) + { + System.out.println("Entity: " + event.entity); + } + }*/ + + @ForgeSubscribe + public void onLivingSpawn (LivingSpawnEvent.SpecialSpawn event) + { + if (event.entityLiving.getClass() == EntitySpider.class && random.nextInt(100) == 0) + { + EntityCreeper creeper = new EntityCreeper(event.entityLiving.worldObj); + spawnEntity(event.entityLiving.posX, event.entityLiving.posY + 1, event.entityLiving.posZ, creeper, event.entityLiving.worldObj); + creeper.mountEntity(event.entityLiving); + } + } + + public static void spawnEntity (double x, double y, double z, Entity entity, World world) + { + /*if (!world.isRemote) + { + entity.setPosition(x, y, z); + ((EntityLiving) entity).initCreature(); + world.spawnEntityInWorld(entity); + }*/ + } + + /* Chunks */ + @ForgeSubscribe + public void chunkDataLoad (ChunkDataEvent.Load event) + { + Chunk chunk = event.getChunk(); + int worldID = chunk.worldObj.provider.dimensionId; + ValueCoordTuple coord = new ValueCoordTuple(worldID, chunk.xPosition, chunk.zPosition); + TheftValueTracker.crystallinity.put(coord, event.getData().getInteger("TConstruct.Crystallinity")); + } + + @ForgeSubscribe + public void chunkDataSave (ChunkDataEvent.Save event) + { + Chunk chunk = event.getChunk(); + int worldID = chunk.worldObj.provider.dimensionId; + ValueCoordTuple coord = new ValueCoordTuple(worldID, chunk.xPosition, chunk.zPosition); + if (TheftValueTracker.crystallinity.containsKey(coord)) + { + int crystal = TheftValueTracker.crystallinity.get(coord); + event.getData().setInteger("TConstruct.Crystallinity", crystal); + if (!event.getChunk().isChunkLoaded) + { + TheftValueTracker.crystallinity.remove(worldID); + } + } + } + + /* Ore Dictionary */ + @ForgeSubscribe + public void registerOre (OreRegisterEvent evt) + { + if (evt.Name == "battery") + TConstruct.content.modE.batteries.add(evt.Ore); + + else if (evt.Name == "basicCircuit") + TConstruct.content.modE.circuits.add(evt.Ore); + + else if (evt.Name == "plankWood") + { + PatternBuilder.instance.registerMaterial(evt.Ore, 2, "Wood"); + } + + else if (evt.Name == "crystalQuartz") + { + ToolBuilder.instance.registerToolMod(new ModAttack("Quartz", new ItemStack[] { evt.Ore }, 11, 2)); + } + + else if (evt.Name == "crystalCerusQuartz") + { + ToolBuilder.instance.registerToolMod(new ModAttack("Quartz", new ItemStack[] { evt.Ore }, 11, 24)); + } + + //Ingots + else if (evt.Name == "ingotCopper") + { + PatternBuilder.instance.registerMaterial(evt.Ore, 2, "Copper"); + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenCopperFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotTin") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 5, 175, new FluidStack(TContent.moltenTinFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotBronze") + { + PatternBuilder.instance.registerMaterial(evt.Ore, 2, "Bronze"); + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 4, 500, new FluidStack(TContent.moltenBronzeFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotCobalt") + { + PatternBuilder.instance.registerMaterial(evt.Ore, 2, "Cobalt"); + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 0, 650, new FluidStack(TContent.moltenCobaltFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotArdite") + { + PatternBuilder.instance.registerMaterial(evt.Ore, 2, "Ardite"); + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 1, 650, new FluidStack(TContent.moltenArditeFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotManyullyn") + { + PatternBuilder.instance.registerMaterial(evt.Ore, 2, "Manyullyn"); + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 2, 750, new FluidStack(TContent.moltenManyullynFluid, + TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotNaturalAluminum") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 6, 250, new FluidStack(TContent.moltenAluminumFluid, + TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "naturalAluminum") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 6, 250, new FluidStack(TContent.moltenAluminumFluid, + TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotAluminumBrass") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 7, 350, new FluidStack(TContent.moltenAlubrassFluid, + TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotAlumite") + { + PatternBuilder.instance.registerMaterial(evt.Ore, 2, "Alumite"); + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 8, 500, + new FluidStack(TContent.moltenAlumiteFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotSteel") + { + PatternBuilder.instance.registerMaterial(evt.Ore, 2, "Steel"); + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenSteelFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotNickel") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenNickelFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotLead") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenLeadFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotSilver") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenSilverFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotPlatinum") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenShinyFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotInvar") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenInvarFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "ingotElectrum") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenElectrumFluid, + TConstruct.ingotLiquidValue)); + } + //Ores + else if (evt.Name == "oreCopper") + { + Smeltery.addMelting(evt.Ore, 550, new FluidStack(TContent.moltenCopperFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "oreTin") + { + Smeltery.addMelting(evt.Ore, 275, new FluidStack(TContent.moltenTinFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "oreNaturalAluminum") + { + Smeltery.addMelting(evt.Ore, 350, new FluidStack(TContent.moltenAluminumFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "oreCobalt") + { + Smeltery.addMelting(evt.Ore, 750, new FluidStack(TContent.moltenCobaltFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "oreArdite") + { + Smeltery.addMelting(evt.Ore, 750, new FluidStack(TContent.moltenArditeFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "oreNickel") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenNickelFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "oreLead") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenLeadFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "oreSilver") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenSilverFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "orePlatinum") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenShinyFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "oreInvar") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenInvarFluid, TConstruct.ingotLiquidValue * 2)); + } + + else if (evt.Name == "oreElectrum") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenElectrumFluid, TConstruct.ingotLiquidValue * 2)); + } + + //Blocks + else if (evt.Name == "blockCopper") + { + Smeltery.addMelting(evt.Ore, 550, new FluidStack(TContent.moltenCopperFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockTin") + { + Smeltery.addMelting(evt.Ore, 275, new FluidStack(TContent.moltenTinFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockBronze") + { + Smeltery.addMelting(evt.Ore, 500, new FluidStack(TContent.moltenBronzeFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockNaturalAluminum") + { + Smeltery.addMelting(evt.Ore, 350, new FluidStack(TContent.moltenAluminumFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockCobalt") + { + Smeltery.addMelting(evt.Ore, 750, new FluidStack(TContent.moltenCobaltFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockArdite") + { + Smeltery.addMelting(evt.Ore, 750, new FluidStack(TContent.moltenArditeFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockManyullyn") + { + Smeltery.addMelting(evt.Ore, 800, new FluidStack(TContent.moltenManyullynFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockAluminumBrass") + { + Smeltery.addMelting(evt.Ore, 350, new FluidStack(TContent.moltenAlubrassFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockAlumite") + { + Smeltery.addMelting(evt.Ore, 500, new FluidStack(TContent.moltenAlumiteFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockSteel") + { + Smeltery.addMelting(evt.Ore, 500, new FluidStack(TContent.moltenSteelFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockNickel") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenNickelFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockLead") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenLeadFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockSilver") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenSilverFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockPlatinum") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenShinyFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockInvar") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenInvarFluid, TConstruct.ingotLiquidValue * 9)); + } + + else if (evt.Name == "blockElectrum") + { + Smeltery.addMelting(evt.Ore, 400, new FluidStack(TContent.moltenElectrumFluid, TConstruct.ingotLiquidValue * 9)); + } + + //Dust + else if (evt.Name == "dustIron") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenIronFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustGold") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenGoldFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustCopper") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenCopperFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustTin") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 5, 175, new FluidStack(TContent.moltenTinFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustBronze") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 4, 500, new FluidStack(TContent.moltenBronzeFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustCobalt") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 0, 650, new FluidStack(TContent.moltenCobaltFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustArdite") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 1, 650, new FluidStack(TContent.moltenArditeFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustManyullyn") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 2, 750, new FluidStack(TContent.moltenManyullynFluid, + TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustAluminum") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 6, 250, new FluidStack(TContent.moltenAluminumFluid, + TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustNaturalAluminum") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 6, 250, new FluidStack(TContent.moltenAluminumFluid, + TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustAluminumBrass") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 7, 350, new FluidStack(TContent.moltenAlubrassFluid, + TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustAlumite") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 8, 500, + new FluidStack(TContent.moltenAlumiteFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustSteel") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenSteelFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustNickel") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenNickelFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustLead") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenLeadFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustSilver") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenSilverFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustPlatinum") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenShinyFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustInvar") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenInvarFluid, TConstruct.ingotLiquidValue)); + } + + else if (evt.Name == "dustElectrum") + { + Smeltery.addMelting(new ItemStack(evt.Ore.itemID, 2, evt.Ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenElectrumFluid, + TConstruct.ingotLiquidValue)); + } + } + + public void unfuxOreDictionary () //TODO: This isn't the best + { + ArrayList ores = OreDictionary.getOres("ingotCopper"); + for (ItemStack ore : ores) + { + PatternBuilder.instance.registerMaterial(ore, 2, "Copper"); + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenCopperFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotTin"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 5, 175, new FluidStack(TContent.moltenTinFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotBronze"); + for (ItemStack ore : ores) + { + PatternBuilder.instance.registerMaterial(ore, 2, "Bronze"); + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 4, 500, new FluidStack(TContent.moltenBronzeFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotCobalt"); + for (ItemStack ore : ores) + { + PatternBuilder.instance.registerMaterial(ore, 2, "Cobalt"); + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 650, new FluidStack(TContent.moltenCobaltFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotArdite"); + for (ItemStack ore : ores) + { + PatternBuilder.instance.registerMaterial(ore, 2, "Ardite"); + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 1, 650, new FluidStack(TContent.moltenArditeFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotManyullyn"); + for (ItemStack ore : ores) + { + PatternBuilder.instance.registerMaterial(ore, 2, "Manyullyn"); + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 2, 750, new FluidStack(TContent.moltenManyullynFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("naturalAluminum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 6, 250, new FluidStack(TContent.moltenAluminumFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotNaturalAluminum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 6, 250, new FluidStack(TContent.moltenAluminumFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotAluminumBrass"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 7, 350, new FluidStack(TContent.moltenAlubrassFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotAlumite"); + for (ItemStack ore : ores) + { + PatternBuilder.instance.registerMaterial(ore, 2, "Alumite"); + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 8, 500, new FluidStack(TContent.moltenAlumiteFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotSteel"); + for (ItemStack ore : ores) + { + PatternBuilder.instance.registerMaterial(ore, 2, "Steel"); + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenSteelFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotNickel"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenNickelFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotLead"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenLeadFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotSilver"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenSilverFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotPlatinum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenShinyFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotInvar"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenInvarFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("ingotElectrum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenElectrumFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("oreCopper"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 550, new FluidStack(TContent.moltenCopperFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("oreTin"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 275, new FluidStack(TContent.moltenTinFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("oreNaturalAluminum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 350, new FluidStack(TContent.moltenAluminumFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("oreCobalt"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 750, new FluidStack(TContent.moltenCobaltFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("oreArdite"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 750, new FluidStack(TContent.moltenArditeFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("oreNickel"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenNickelFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("oreLead"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenLeadFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("oreSilver"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenSilverFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("orePlatinum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenShinyFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("oreInvar"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenInvarFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("oreElectrum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenElectrumFluid, TConstruct.ingotLiquidValue * 2)); + } + + ores = OreDictionary.getOres("blockCopper"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 550, new FluidStack(TContent.moltenCopperFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockTin"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 275, new FluidStack(TContent.moltenTinFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockBronze"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 500, new FluidStack(TContent.moltenBronzeFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockNaturalAluminum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 350, new FluidStack(TContent.moltenAluminumFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockCobalt"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 750, new FluidStack(TContent.moltenCobaltFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockArdite"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 750, new FluidStack(TContent.moltenArditeFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockManyullyn"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 800, new FluidStack(TContent.moltenManyullynFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockAluminumBrass"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 350, new FluidStack(TContent.moltenAlubrassFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockAlumite"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 500, new FluidStack(TContent.moltenAlumiteFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockSteel"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 500, new FluidStack(TContent.moltenSteelFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockNickel"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenNickelFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockLead"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenLeadFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockSilver"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenSilverFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockPlatinum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenShinyFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockInvar"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenInvarFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("blockElectrum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(ore, 400, new FluidStack(TContent.moltenElectrumFluid, TConstruct.ingotLiquidValue * 9)); + } + + ores = OreDictionary.getOres("dustIron"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenIronFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustGold"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenGoldFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustCopper"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenCopperFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustTin"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 5, 175, new FluidStack(TContent.moltenTinFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustBronze"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 4, 500, new FluidStack(TContent.moltenBronzeFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustCobalt"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 650, new FluidStack(TContent.moltenCobaltFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustArdite"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 1, 650, new FluidStack(TContent.moltenArditeFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustManyullyn"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 2, 750, new FluidStack(TContent.moltenManyullynFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustNaturalAluminum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 6, 250, new FluidStack(TContent.moltenAluminumFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustAluminumBrass"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 7, 350, new FluidStack(TContent.moltenAlubrassFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustAlumite"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 8, 500, new FluidStack(TContent.moltenAlumiteFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustSteel"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 9, 500, new FluidStack(TContent.moltenSteelFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustNickel"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenNickelFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustLead"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenLeadFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustSilver"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenSilverFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustPlatinum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenShinyFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustInvar"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenInvarFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("dustElectrum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenElectrumFluid, TConstruct.ingotLiquidValue)); + } + + ores = OreDictionary.getOres("nuggetIron"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenIronFluid, TConstruct.ingotLiquidValue / 9)); + } + + ores = OreDictionary.getOres("nuggetCopper"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 3, 450, new FluidStack(TContent.moltenCopperFluid, TConstruct.ingotLiquidValue / 9)); + } + + ores = OreDictionary.getOres("nuggetTin"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 5, 175, new FluidStack(TContent.moltenTinFluid, TConstruct.ingotLiquidValue / 9)); + } + + ores = OreDictionary.getOres("nuggetNaturalAluminum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 6, 250, new FluidStack(TContent.moltenAluminumFluid, TConstruct.ingotLiquidValue / 9)); + } + + ores = OreDictionary.getOres("nuggetNickel"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenNickelFluid, TConstruct.ingotLiquidValue / 9)); + } + + ores = OreDictionary.getOres("nuggetLead"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenLeadFluid, TConstruct.ingotLiquidValue / 9)); + } + + ores = OreDictionary.getOres("nuggetSilver"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenSilverFluid, TConstruct.ingotLiquidValue / 9)); + } + + ores = OreDictionary.getOres("nuggetPlatinum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenShinyFluid, TConstruct.ingotLiquidValue / 9)); + } + + ores = OreDictionary.getOres("nuggetInvar"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenInvarFluid, TConstruct.ingotLiquidValue / 9)); + } + + ores = OreDictionary.getOres("nuggetElectrum"); + for (ItemStack ore : ores) + { + Smeltery.addMelting(new ItemStack(ore.itemID, 2, ore.getItemDamage()), TContent.metalBlock.blockID, 0, 400, new FluidStack(TContent.moltenElectrumFluid, TConstruct.ingotLiquidValue / 9)); + } + } + + @ForgeSubscribe + public void bucketFill (FillBucketEvent evt) + { + if (evt.current.getItem() == Item.bucketEmpty && evt.target.typeOfHit == EnumMovingObjectType.TILE) + { + int hitX = evt.target.blockX; + int hitY = evt.target.blockY; + int hitZ = evt.target.blockZ; + + if (evt.entityPlayer != null && !evt.entityPlayer.canPlayerEdit(hitX, hitY, hitZ, evt.target.sideHit, evt.current)) + { + return; + } + + int bID = evt.world.getBlockId(hitX, hitY, hitZ); + for (int id = 0; id < TContent.fluidBlocks.length; id++) + { + if (bID == TContent.fluidBlocks[id].blockID) + { + if (evt.entityPlayer.capabilities.isCreativeMode) + { + evt.world.setBlockToAir(hitX, hitY, hitZ); + } + else + { + int quanta = 0; + for (int posX = -1; posX <= 1; posX++) + { + for (int posZ = -1; posZ <= 1; posZ++) + { + int localID = evt.world.getBlockId(hitX + posX, hitY, hitZ + posZ); + if (localID == bID) + { + quanta += evt.world.getBlockMetadata(hitX + posX, hitY, hitZ + posZ) + 1; + } + } + } + + if (quanta >= 8) + while (quanta > 0) + { + for (int posX = -1; posX <= 1; posX++) + { + for (int posZ = -1; posZ <= 1; posZ++) + { + int localID = evt.world.getBlockId(hitX + posX, hitY, hitZ + posZ); + if (localID == bID) + { + quanta -= 1; + int meta = evt.world.getBlockMetadata(hitX + posX, hitY, hitZ + posZ); + if (meta > 0) + evt.world.setBlockMetadataWithNotify(hitX + posX, hitY, hitZ + posZ, meta - 1, 3); + else + evt.world.setBlockToAir(hitX + posX, hitY, hitZ + posZ); + } + } + } + } + evt.setResult(Result.ALLOW); + } + } + } + } + } + +} diff --git a/tconstruct/util/network/TPacketHandler.java b/tconstruct/util/network/TPacketHandler.java new file mode 100644 index 00000000..e855df8f --- /dev/null +++ b/tconstruct/util/network/TPacketHandler.java @@ -0,0 +1,171 @@ +package tconstruct.util.network; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.util.ArrayList; + +import tconstruct.TConstruct; +import tconstruct.blocks.logic.ToolForgeLogic; +import tconstruct.blocks.logic.ToolStationLogic; +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.skill.Skill; +import tconstruct.skill.SkillRegistry; +import tconstruct.util.player.TPlayerStats; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.IPacketHandler; +import cpw.mods.fml.common.network.Player; +import cpw.mods.fml.relauncher.Side; + +public class TPacketHandler implements IPacketHandler +{ + + @Override + public void onPacketData (INetworkManager manager, Packet250CustomPayload packet, Player player) + { + Side side = FMLCommonHandler.instance().getEffectiveSide(); + + if (packet.channel.equals("TConstruct")) + { + if (side == Side.SERVER) + handleServerPacket(packet, (EntityPlayerMP) player); + else + handleClientPacket(packet, (EntityPlayer) player); + } + } + + void handleClientPacket (Packet250CustomPayload packet, EntityPlayer player) + { + DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); + + byte packetID; + + try + { + packetID = inputStream.readByte(); + if (packetID == 1) + { + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + stats.skillList = new ArrayList(); + int size = inputStream.readInt(); + for (int i = 0; i < size; i++) + { + Skill skill = SkillRegistry.skillMapping.get(inputStream.readInt()).copy(); + skill.setActive(inputStream.readBoolean()); + stats.skillList.add(skill); + } + } + } + catch (Exception e) + { + System.out.println("Failed at reading client packet for TConstruct."); + e.printStackTrace(); + return; + } + } + + void handleServerPacket (Packet250CustomPayload packet, EntityPlayerMP player) + { + DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); + + byte packetID; + + try + { + packetID = inputStream.readByte(); + + if (packetID == 1) //Tool Station + { + int dimension = inputStream.readInt(); + World world = DimensionManager.getWorld(dimension); + int x = inputStream.readInt(); + int y = inputStream.readInt(); + int z = inputStream.readInt(); + TileEntity te = world.getBlockTileEntity(x, y, z); + + String toolName = inputStream.readUTF(); + if (te instanceof ToolStationLogic) + { + ((ToolStationLogic) te).setToolname(toolName); + } + if (te instanceof ToolForgeLogic) + { + ((ToolForgeLogic) te).setToolname(toolName); + } + } + else if (packetID == 2) //Stencil Table + { + int dimension = inputStream.readInt(); + World world = DimensionManager.getWorld(dimension); + int x = inputStream.readInt(); + int y = inputStream.readInt(); + int z = inputStream.readInt(); + TileEntity te = world.getBlockTileEntity(x, y, z); + + Short itemID = inputStream.readShort(); + Short itemDamage = inputStream.readShort(); + if (te instanceof InventoryLogic) + { + ((InventoryLogic) te).setInventorySlotContents(1, new ItemStack(itemID, 1, itemDamage)); + } + } + + else if (packetID == 3) //Armor + { + //String user = inputStream.readUTF(); + //EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user); + switch (inputStream.readByte()) + { + case 0: + player.openGui(TConstruct.instance, TConstruct.proxy.inventoryGui, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); + break; + case 1: + player.openGui(TConstruct.instance, TConstruct.proxy.armorGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); + break; + case 2: + player.openGui(TConstruct.instance, TConstruct.proxy.knapsackGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); + break; + } + } + + else if (packetID == 4) //Active Skills + { + Byte id = inputStream.readByte(); + TConstruct.playerTracker.activateSkill(player, id); + } + + else if (packetID == 10) //Double jump + { + //String user = inputStream.readUTF(); + //EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user); + player.fallDistance = 0; + } + } + catch (IOException e) + { + System.out.println("Failed at reading server packet for TConstruct."); + e.printStackTrace(); + return; + } + } + + Entity getEntity (World world, int id) + { + for (Object o : world.loadedEntityList) + { + if (((Entity) o).entityId == id) + return (Entity) o; + } + return null; + } +} diff --git a/tconstruct/util/player/ArmorExtended.java b/tconstruct/util/player/ArmorExtended.java new file mode 100644 index 00000000..0b851412 --- /dev/null +++ b/tconstruct/util/player/ArmorExtended.java @@ -0,0 +1,236 @@ +package tconstruct.util.player; + +import java.lang.ref.WeakReference; + +import tconstruct.TConstruct; +import tconstruct.common.TContent; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class ArmorExtended implements IInventory +{ + public ItemStack[] inventory = new ItemStack[7]; + public WeakReference parent; + + public void init (EntityPlayer player) + { + parent = new WeakReference(player); + } + + @Override + public int getSizeInventory () + { + return inventory.length; + } + + public boolean isStackInSlot (int slot) + { + return inventory[slot] != null; + } + + @Override + public ItemStack getStackInSlot (int slot) + { + return inventory[slot]; + } + + @Override + public ItemStack decrStackSize (int slot, int quantity) + { + if (inventory[slot] != null) + { + //System.out.println("Took something from slot " + slot); + if (inventory[slot].stackSize <= quantity) + { + ItemStack stack = inventory[slot]; + inventory[slot] = null; + return stack; + } + ItemStack split = inventory[slot].splitStack(quantity); + if (inventory[slot].stackSize == 0) + { + inventory[slot] = null; + } + EntityPlayer player = parent.get(); + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + recalculateHealth(player, stats); + return split; + } + else + { + return null; + } + } + + @Override + public ItemStack getStackInSlotOnClosing (int slot) + { + return null; + } + + @Override + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + inventory[slot] = itemstack; + //System.out.println("Changed slot " + slot + " on side " + FMLCommonHandler.instance().getEffectiveSide()); + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); + } + + EntityPlayer player = parent.get(); + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + recalculateHealth(player, stats); + } + + @Override + public String getInvName () + { + return ""; + } + + @Override + public boolean isInvNameLocalized () + { + return false; + } + + @Override + public int getInventoryStackLimit () + { + return 64; + } + + @Override + public void onInventoryChanged () + { + EntityPlayer player = parent.get(); + TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); + //recalculateSkills(player, stats); + recalculateHealth(player, stats); + + /*if (inventory[2] == null && stats.knapsack != null) + { + stats.knapsack.unequipItems(); + }*/ + } + + /*public void recalculateSkills(EntityPlayer player, TPlayerStats stats) + { + if (inventory[1] != null && inventory[1].getItem() == TContent.glove) + { + if (stats.skillList.size() < 1) + { + try + { + stats.skillList.add(SkillRegistry.skills.get("Wall Building").copy()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + else + { + if (stats.skillList.size() > 0) + { + stats.skillList.remove(0); + } + } + }*/ + + public void recalculateHealth (EntityPlayer player, TPlayerStats stats) + { + if (inventory[6] != null && inventory[6].getItem() == TContent.heartCanister) + { + ItemStack stack = inventory[6]; + int meta = stack.getItemDamage(); + if (meta == 2) + { + int bonusHP = stack.stackSize * 2; + stats.bonusHealth = bonusHP; + //player.maxHealth = 20 + bonusHP; + } + } + else if (parent != null && parent.get() != null) + { + //parent.get().maxHealth = 20; + } + } + + @Override + public boolean isUseableByPlayer (EntityPlayer entityplayer) + { + return true; + } + + public void openChest () + { + } + + public void closeChest () + { + } + + @Override + public boolean isItemValidForSlot (int slot, ItemStack itemstack) + { + return false; + } + + /* Save/Load */ + public void saveToNBT (EntityPlayer entityplayer) + { + NBTTagCompound tags = entityplayer.getEntityData(); + NBTTagList tagList = new NBTTagList(); + NBTTagCompound invSlot; + + for (int i = 0; i < this.inventory.length; ++i) + { + if (this.inventory[i] != null) + { + invSlot = new NBTTagCompound(); + invSlot.setByte("Slot", (byte) i); + this.inventory[i].writeToNBT(invSlot); + tagList.appendTag(invSlot); + } + } + + tags.setTag("TConstruct.Inventory", tagList); + } + + public void readFromNBT (EntityPlayer entityplayer) + { + NBTTagCompound tags = entityplayer.getEntityData(); + NBTTagList tagList = tags.getTagList("TConstruct.Inventory"); + for (int i = 0; i < tagList.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.tagAt(i); + int j = nbttagcompound.getByte("Slot") & 255; + ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound); + + if (itemstack != null) + { + this.inventory[j] = itemstack; + } + } + } + + public void dropItems () + { + EntityPlayer player = parent.get(); + for (int i = 0; i < 4; ++i) + { + if (this.inventory[i] != null) + { + player.dropPlayerItemWithRandomChoice(this.inventory[i], true); + this.inventory[i] = null; + } + } + } +} diff --git a/tconstruct/util/player/ArmorExtendedClient.java b/tconstruct/util/player/ArmorExtendedClient.java new file mode 100644 index 00000000..c08e7b8b --- /dev/null +++ b/tconstruct/util/player/ArmorExtendedClient.java @@ -0,0 +1,31 @@ +package tconstruct.util.player; + + +public class ArmorExtendedClient extends ArmorExtended +{ + /*public void recalculateSkills(EntityPlayer player, TPlayerStats stats) + { + System.out.println("Client skills"); + if (inventory[1] != null && inventory[1].getItem() == TContent.glove) + { + if (TProxyClient.skillList.size() < 1) + { + try + { + TProxyClient.skillList.add(SkillRegistry.skills.get("Wall Building").copy()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + else + { + if (TProxyClient.skillList.size() > 0) + { + TProxyClient.skillList.remove(0); + } + } + }*/ +} diff --git a/tconstruct/util/player/KnapsackInventory.java b/tconstruct/util/player/KnapsackInventory.java new file mode 100644 index 00000000..45af3ce3 --- /dev/null +++ b/tconstruct/util/player/KnapsackInventory.java @@ -0,0 +1,197 @@ +package tconstruct.util.player; + +import java.lang.ref.WeakReference; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class KnapsackInventory implements IInventory +{ + public ItemStack[] inventory = new ItemStack[27]; + public WeakReference parent; + + public void init (EntityPlayer player) + { + parent = new WeakReference(player); + } + + @Override + public ItemStack getStackInSlot (int slot) + { + return inventory[slot]; + } + + public boolean isStackInSlot (int slot) + { + return inventory[slot] != null; + } + + @Override + public int getSizeInventory () + { + return inventory.length; + } + + @Override + public int getInventoryStackLimit () + { + return 64; + } + + public boolean canDropInventorySlot (int slot) + { + return true; + } + + @Override + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + inventory[slot] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); + } + } + + @Override + public ItemStack decrStackSize (int slot, int quantity) + { + if (inventory[slot] != null) + { + if (inventory[slot].stackSize <= quantity) + { + ItemStack stack = inventory[slot]; + inventory[slot] = null; + return stack; + } + ItemStack split = inventory[slot].splitStack(quantity); + if (inventory[slot].stackSize == 0) + { + inventory[slot] = null; + } + return split; + } + else + { + return null; + } + } + + @Override + public String getInvName () + { + return "tconstruct.knapsack"; + } + + @Override + public boolean isInvNameLocalized () + { + return false; + } + + @Override + public void onInventoryChanged () + { + + } + + public ItemStack getStackInSlotOnClosing (int slot) + { + return null; + } + + public void openChest () + { + } + + public void closeChest () + { + } + + @Override + public boolean isItemValidForSlot (int i, ItemStack itemstack) + { + return true; + } + + @Override + public boolean isUseableByPlayer (EntityPlayer entityplayer) + { + return true; + } + + /* Save/Load */ + public void saveToNBT (EntityPlayer entityplayer) + { + NBTTagCompound tags = entityplayer.getEntityData(); + NBTTagList tagList = new NBTTagList(); + NBTTagCompound invSlot; + + for (int i = 0; i < this.inventory.length; ++i) + { + if (this.inventory[i] != null) + { + invSlot = new NBTTagCompound(); + invSlot.setByte("Slot", (byte) i); + this.inventory[i].writeToNBT(invSlot); + tagList.appendTag(invSlot); + } + } + + tags.setTag("TConstruct.Knapsack", tagList); + } + + public void readFromNBT (EntityPlayer entityplayer) + { + NBTTagCompound tags = entityplayer.getEntityData(); + NBTTagList tagList = tags.getTagList("TConstruct.Knapsack"); + for (int i = 0; i < tagList.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.tagAt(i); + int j = nbttagcompound.getByte("Slot") & 255; + ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound); + + if (itemstack != null) + { + this.inventory[j] = itemstack; + } + } + } + + public void dropItems () + { + EntityPlayer player = parent.get(); + for (int i = 0; i < inventory.length; ++i) + { + if (this.inventory[i] != null) + { + player.dropPlayerItemWithRandomChoice(this.inventory[i], true); + this.inventory[i] = null; + } + } + } + + public void unequipItems () + { + EntityPlayer player = parent.get(); + for (int i = 0; i < inventory.length; ++i) + { + if (this.inventory[i] != null) + { + dropItemEntity(player, inventory[i]); + this.inventory[i] = null; + } + } + } + + void dropItemEntity (Entity dropper, ItemStack dropStack) + { + EntityItem entityitem = new EntityItem(dropper.worldObj, dropper.posX, dropper.posY, dropper.posZ, dropStack); + dropper.worldObj.spawnEntityInWorld(entityitem); + } +} \ No newline at end of file diff --git a/tconstruct/util/player/TPlayerHandler.java b/tconstruct/util/player/TPlayerHandler.java new file mode 100644 index 00000000..75d4b878 --- /dev/null +++ b/tconstruct/util/player/TPlayerHandler.java @@ -0,0 +1,349 @@ +package tconstruct.util.player; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; + +import tconstruct.common.TContent; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.skill.Skill; +import tconstruct.util.PHConstruct; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumEntitySize; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.event.entity.living.LivingFallEvent; +import net.minecraftforge.event.entity.player.PlayerDropsEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.IPlayerTracker; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.network.PacketDispatcher; +import cpw.mods.fml.common.network.Player; +import cpw.mods.fml.relauncher.Side; + +public class TPlayerHandler implements IPlayerTracker +{ + /* Player */ + //public int hunger; + public ConcurrentHashMap playerStats = new ConcurrentHashMap(); + + @Override + public void onPlayerLogin (EntityPlayer entityplayer) + { + //System.out.println("Player: "+entityplayer); + //Lookup player + /*TFoodStats food = new TFoodStats(); + food.readStats(entityplayer.foodStats); + entityplayer.foodStats = food*/; + NBTTagCompound tags = entityplayer.getEntityData(); + if (!tags.hasKey("TConstruct")) + { + tags.setCompoundTag("TConstruct", new NBTTagCompound()); + } + TPlayerStats stats = new TPlayerStats(); + stats.player = new WeakReference(entityplayer); + stats.armor = new ArmorExtended(); + stats.armor.init(entityplayer); + stats.armor.readFromNBT(entityplayer); + + stats.knapsack = new KnapsackInventory(); + stats.knapsack.init(entityplayer); + stats.knapsack.readFromNBT(entityplayer); + + stats.level = entityplayer.experienceLevel; + stats.hunger = entityplayer.getFoodStats().getFoodLevel(); + stats.beginnerManual = tags.getCompoundTag("TConstruct").getBoolean("beginnerManual"); + stats.materialManual = tags.getCompoundTag("TConstruct").getBoolean("materialManual"); + stats.smelteryManual = tags.getCompoundTag("TConstruct").getBoolean("smelteryManual"); + if (!stats.beginnerManual) + { + stats.beginnerManual = true; + tags.getCompoundTag("TConstruct").setBoolean("beginnerManual", true); + if (PHConstruct.beginnerBook) + { + ItemStack diary = new ItemStack(TContent.manualBook); + if (!entityplayer.inventory.addItemStackToInventory(diary)) + { + AbilityHelper.spawnItemAtPlayer(entityplayer, diary); + } + } + } + + stats.skillList = new ArrayList(); + //stats.armor.recalculateSkills(entityplayer, stats); + + playerStats.put(entityplayer.username, stats); + + if (PHConstruct.gregtech) + { + PHConstruct.gregtech = false; + if (PHConstruct.lavaFortuneInteraction) + { + entityplayer.addChatMessage("Warning: Cross-mod Exploit Present!"); + entityplayer.addChatMessage("Solution 1: Disable Reverse Smelting recipes from GregTech."); + entityplayer.addChatMessage("Solution 2: Disable Auto-Smelt/Fortune interaction from TConstruct."); + } + } + + if (Loader.isModLoaded("GregTech_Addon") || Loader.isModLoaded("GregTech-Addon")) + { + if (entityplayer.username.equals("GregoriousT") || entityplayer.username.equals("gregorioust")) + entityplayer.addChatMessage("Quit being a dick."); + else + { + entityplayer.addChatMessage("\u00A74!!!WARNING!!! \u00A7fGREGTECH PRESENT!! VANILLA MINECRAFT MAY BE IRREPARABLY DAMAGED"); + entityplayer.addChatMessage("\u00A74!!!WARNING!!! \u00A7fGREGTECH PRESENT!! MODS MAY NOT FUNCTION PROPERLY"); + } + } + + updatePlayerInventory(entityplayer, stats); + //sendSkills(entityplayer, stats); + } + + void updatePlayerInventory (EntityPlayer entityplayer, TPlayerStats stats) + { + + } + + void sendSkills (EntityPlayer entityplayer, TPlayerStats stats) + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + List skills = stats.skillList; + + try + { + outputStream.writeByte(1); + outputStream.writeInt(skills.size()); + + for (Skill skill : stats.skillList) + { + outputStream.writeInt(skill.getSkillID()); + outputStream.writeBoolean(skill.getActive()); + } + //outputStream.writeByte(key); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + updateClientPlayer(bos, entityplayer); + } + + void updateClientPlayer (ByteArrayOutputStream bos, EntityPlayer player) + { + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "TConstruct"; + packet.data = bos.toByteArray(); + packet.length = bos.size(); + + PacketDispatcher.sendPacketToPlayer(packet, (Player) player); + } + + public void activateSkill (EntityPlayer player, int slot) + { + TPlayerStats stats = getPlayerStats(player.username); + if (stats.skillList.size() > slot) + { + Skill skill = stats.skillList.get(slot); + if (skill != null) + { + skill.activate(player, player.worldObj); + } + } + } + + @Override + public void onPlayerLogout (EntityPlayer entityplayer) + { + savePlayerStats(entityplayer, true); + } + + @Override + public void onPlayerChangedDimension (EntityPlayer entityplayer) + { + savePlayerStats(entityplayer, false); + } + + void savePlayerStats (EntityPlayer player, boolean clean) + { + if (player != null) + { + TPlayerStats stats = getPlayerStats(player.username); + if (stats != null && stats.armor != null) + { + stats.armor.saveToNBT(player); + stats.knapsack.saveToNBT(player); + if (clean) + playerStats.remove(player.username); + } + else + //Revalidate all players + { + + } + } + } + + @Override + public void onPlayerRespawn (EntityPlayer entityplayer) + { + //Boom! + TPlayerStats stats = getPlayerStats(entityplayer.username); + stats.player = new WeakReference(entityplayer); + stats.armor.recalculateHealth(entityplayer, stats); + + /*TFoodStats food = new TFoodStats(); + entityplayer.foodStats = food;*/ + + if (PHConstruct.keepLevels) + entityplayer.experienceLevel = stats.level; + if (PHConstruct.keepHunger) + entityplayer.getFoodStats().addStats(-1 * (20 - stats.hunger), 0); + NBTTagCompound tags = entityplayer.getEntityData(); + NBTTagCompound tTag = new NBTTagCompound(); + tTag.setBoolean("beginnerManual", stats.beginnerManual); + tTag.setBoolean("materialManual", stats.materialManual); + tTag.setBoolean("smelteryManual", stats.smelteryManual); + tags.setCompoundTag("TConstruct", tTag); + + Side side = FMLCommonHandler.instance().getEffectiveSide(); + if (side == Side.CLIENT) + { + //TProxyClient.controlInstance.resetControls(); + if (PHConstruct.keepHunger) + entityplayer.getFoodStats().setFoodLevel(stats.hunger); + } + } + + @ForgeSubscribe + public void livingFall (LivingFallEvent evt) //Only for negating fall damage + { + if (evt.entityLiving instanceof EntityPlayer) + { + evt.distance -= 1; + } + } + + /*@ForgeSubscribe + public void livingUpdate (LivingUpdateEvent evt) + { + Side side = FMLCommonHandler.instance().getEffectiveSide(); + if (side == Side.CLIENT && evt.entityLiving instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) evt.entityLiving; + TPlayerStats stats = playerStats.get(player.username); + if (player.onGround != stats.prevOnGround) + { + if (player.onGround)// && -stats.prevMotionY > 0.1) + //player.motionY = 0.5; + player.motionY = -stats.prevMotionY * 0.8; + //player.motionY *= -1.2; + stats.prevOnGround = player.onGround; + //if () + + //System.out.println("Fall: "+player.fallDistance); + } + } + }*/ + + @ForgeSubscribe + public void playerDrops (PlayerDropsEvent evt) + { + TPlayerStats stats = getPlayerStats(evt.entityPlayer.username); + stats.level = evt.entityPlayer.experienceLevel / 2; + //stats.health = 20; + int hunger = evt.entityPlayer.getFoodStats().getFoodLevel(); + if (hunger < 6) + stats.hunger = 6; + else + stats.hunger = evt.entityPlayer.getFoodStats().getFoodLevel(); + } + + /* Find the right player */ + public TPlayerStats getPlayerStats (String username) + { + TPlayerStats stats = playerStats.get(username); + //System.out.println("Stats: "+stats); + if (stats == null) + { + stats = new TPlayerStats(); + playerStats.put(username, stats); + } + return stats; + } + + public EntityPlayer getEntityPlayer (String username) + { + TPlayerStats stats = playerStats.get(username); + if (stats == null) + { + return null; + } + else + { + return stats.player.get(); + } + } + + /* Modify Player */ + public void updateSize (String user, float offset) + { + /*EntityPlayer player = getEntityPlayer(user); + setEntitySize(0.6F, offset, player); + player.yOffset = offset - 0.18f;*/ + } + + public static void setEntitySize (float width, float height, Entity entity) + { + //System.out.println("Size: " + height); + if (width != entity.width || height != entity.height) + { + entity.width = width; + entity.height = height; + entity.boundingBox.maxX = entity.boundingBox.minX + (double) entity.width; + entity.boundingBox.maxZ = entity.boundingBox.minZ + (double) entity.width; + entity.boundingBox.maxY = entity.boundingBox.minY + (double) entity.height; + } + + float que = width % 2.0F; + + if ((double) que < 0.375D) + { + entity.myEntitySize = EnumEntitySize.SIZE_1; + } + else if ((double) que < 0.75D) + { + entity.myEntitySize = EnumEntitySize.SIZE_2; + } + else if ((double) que < 1.0D) + { + entity.myEntitySize = EnumEntitySize.SIZE_3; + } + else if ((double) que < 1.375D) + { + entity.myEntitySize = EnumEntitySize.SIZE_4; + } + else if ((double) que < 1.75D) + { + entity.myEntitySize = EnumEntitySize.SIZE_5; + } + else + { + entity.myEntitySize = EnumEntitySize.SIZE_6; + } + //entity.yOffset = height; + } + + Random rand = new Random(); + +} diff --git a/tconstruct/util/player/TPlayerStats.java b/tconstruct/util/player/TPlayerStats.java new file mode 100644 index 00000000..d224fa98 --- /dev/null +++ b/tconstruct/util/player/TPlayerStats.java @@ -0,0 +1,23 @@ +package tconstruct.util.player; + +import java.lang.ref.WeakReference; +import java.util.List; + +import tconstruct.skill.Skill; + +import net.minecraft.entity.player.EntityPlayer; + +public class TPlayerStats +{ + public WeakReference player; + public int level; + public int levelHealth; + public int bonusHealth; + public int hunger; + public boolean beginnerManual; + public boolean materialManual; + public boolean smelteryManual; + public ArmorExtended armor; + public KnapsackInventory knapsack; + public List skillList; +} diff --git a/tconstruct/worldgen/OreberryBushGen.java b/tconstruct/worldgen/OreberryBushGen.java new file mode 100644 index 00000000..3b75f43a --- /dev/null +++ b/tconstruct/worldgen/OreberryBushGen.java @@ -0,0 +1,110 @@ +package tconstruct.worldgen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class OreberryBushGen extends WorldGenerator +{ + private int blockID; + private int metadata; + int chance; + private int[] replaceBlocks; + + public OreberryBushGen(Block block, int meta, int chance) + { + this(block.blockID, meta, chance, Block.stone.blockID, Block.grass.blockID, Block.dirt.blockID, Block.waterStill.blockID, Block.sand.blockID, Block.gravel.blockID, Block.snow.blockID); + } + + public OreberryBushGen(int blockID, int meta, int chance, int... target) + { + this.blockID = blockID; + metadata = meta; + this.chance = chance; + this.replaceBlocks = target; + } + + public boolean generate (World world, Random random, int x, int y, int z) + { + int type = random.nextInt(chance); + if (type == 11) + generateMediumNode(world, random, x, y, z); + else if (type >= 5) + generateSmallNode(world, random, x, y, z); + else + generateTinyNode(world, random, x, y, z); + + return true; + } + + public void generateMediumNode (World world, Random random, int x, int y, int z) + { + for (int xPos = -1; xPos <= 1; xPos++) + for (int yPos = -1; yPos <= 1; yPos++) + for (int zPos = -1; zPos <= 1; zPos++) + if (random.nextInt(4) == 0) + generateBerryBlock(world, x + xPos, y + yPos, z + zPos, random); + + generateSmallNode(world, random, x, y, z); + } + + public void generateSmallNode (World world, Random random, int x, int y, int z) + { + generateBerryBlock(world, x, y, z, random); + if (random.nextBoolean()) + generateBerryBlock(world, x + 1, y, z, random); + if (random.nextBoolean()) + generateBerryBlock(world, x - 1, y, z, random); + if (random.nextBoolean()) + generateBerryBlock(world, x, y, z + 1, random); + if (random.nextBoolean()) + generateBerryBlock(world, x, y, z - 1, random); + if (random.nextBoolean()) + generateBerryBlock(world, x, y + 1, z, random); + if (random.nextBoolean()) + generateBerryBlock(world, x, y + 1, z, random); + } + + public void generateTinyNode (World world, Random random, int x, int y, int z) + { + generateBerryBlock(world, x, y, z, random); + if (random.nextInt(4) == 0) + generateBerryBlock(world, x + 1, y, z, random); + if (random.nextInt(4) == 0) + generateBerryBlock(world, x - 1, y, z, random); + if (random.nextInt(4) == 0) + generateBerryBlock(world, x, y, z + 1, random); + if (random.nextInt(4) == 0) + generateBerryBlock(world, x, y, z - 1, random); + if (random.nextInt(4) == 0) + generateBerryBlock(world, x, y + 1, z, random); + if (random.nextInt(4) == 0) + generateBerryBlock(world, x, y + 1, z, random); + } + + void generateBerryBlock (World world, int x, int y, int z, Random random) + { + /*if (!Block.opaqueCubeLookup[world.getBlockId(x, y, z)]) + { + setBlockAndMetadata(world, x, y, z, blockID, metadata); + }*/ + + Block block = Block.blocksList[world.getBlockId(x, y, z)]; + if (block == null || (block != Block.endPortalFrame && !Block.opaqueCubeLookup[world.getBlockId(x, y, z)])) + world.setBlock(x, y, z, this.blockID, metadata, 2); + else + { + for (int iter = 0; iter < replaceBlocks.length; iter++) + { + if (block.isGenMineableReplaceable(world, x, y, z, replaceBlocks[iter])) + { + world.setBlock(x, y, z, this.blockID, metadata, 2); + break; + } + } + } + + } +} diff --git a/tconstruct/worldgen/OverworldProvider.java b/tconstruct/worldgen/OverworldProvider.java new file mode 100644 index 00000000..93689bea --- /dev/null +++ b/tconstruct/worldgen/OverworldProvider.java @@ -0,0 +1,68 @@ +package tconstruct.worldgen; + +import tconstruct.util.PHConstruct; +import net.minecraft.world.WorldProvider; + +public class OverworldProvider extends WorldProvider +{ + + @Override + public String getDimensionName () + { + return "Overworld"; + } + + public boolean getWorldHasVoidParticles () + { + if (PHConstruct.voidFog) + return false; + return this.terrainType.hasVoidParticles(this.hasNoSky); + } + + public float calculateCelestialAngle (long worldtime, float par3) + { + int timeOfDay = 18000; + float f1 = ((float) timeOfDay + par3) / 24000.0F - 0.25F; + + if (f1 < 0.0F) + { + ++f1; + } + + if (f1 > 1.0F) + { + --f1; + } + + float f2 = f1; + f1 = 1.0F - (float) ((Math.cos((double) f1 * Math.PI) + 1.0D) / 2.0D); + f1 = f2 + (f1 - f2) / 3.0F; + return f1; + } + + /*public float calculateCelestialAngle(long worldtime, float par3) + { + int timeOfDay = (int)(worldtime % 43200L); + float f1 = ((float)timeOfDay + par3) / 43200.0F - 0.25F; + + if (f1 < 0.0F) + { + ++f1; + } + + if (f1 > 1.0F) + { + --f1; + } + + float f2 = f1; + f1 = 1.0F - (float)((Math.cos((double)f1 * Math.PI) + 1.0D) / 2.0D); + f1 = f2 + (f1 - f2) / 3.0F; + return f1; + } + + public int getMoonPhase(long par1) + { + return (int)(par1 / 43200L) % 8; + }*/ +} diff --git a/tconstruct/worldgen/SurfaceOreGen.java b/tconstruct/worldgen/SurfaceOreGen.java new file mode 100644 index 00000000..e37da47f --- /dev/null +++ b/tconstruct/worldgen/SurfaceOreGen.java @@ -0,0 +1,143 @@ +package tconstruct.worldgen; + +import java.util.Random; + +import tconstruct.util.PHConstruct; + +import net.minecraft.block.Block; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class SurfaceOreGen extends WorldGenerator +{ + /** The block ID of the ore to be placed using this generator. */ + private int minableBlockId; + private int minableBlockMeta = 0; + + /** The number of blocks to generate. */ + private int numberOfBlocks; + private int[] replaceBlocks; + private boolean alterSize; + + public SurfaceOreGen(int id, int meta, int number, boolean changeSize) + { + this(id, meta, number, changeSize, Block.stone.blockID, Block.grass.blockID, Block.dirt.blockID, Block.waterStill.blockID, Block.sand.blockID, Block.gravel.blockID, Block.snow.blockID); + } + + public SurfaceOreGen(int id, int meta, int number, boolean changeSize, int... target) + { + this.minableBlockId = id; + this.numberOfBlocks = number; + this.replaceBlocks = target; + this.alterSize = changeSize; + minableBlockMeta = meta; + } + + int findGround (World world, int x, int y, int z) + { + int returnHeight = -1; + int blockID = world.getBlockId(x, y - 1, z); + if (!Block.opaqueCubeLookup[world.getBlockId(x, y, z)] && (blockID == Block.dirt.blockID || blockID == Block.grass.blockID)) + { + return y; + } + int height = PHConstruct.seaLevel + 64; + do + { + if (height < PHConstruct.seaLevel - 30) + { + break; + } + int bID = world.getBlockId(x, height, z); + if (bID == Block.dirt.blockID || bID == Block.grass.blockID) + { + if (!Block.opaqueCubeLookup[world.getBlockId(x, height + 1, z)]) + { + returnHeight = height + 1; + } + break; + } + height--; + } while (height > 0); + return returnHeight; + } + + public boolean generate (World world, Random random, int startX, int startY, int startZ) + { + if (alterSize) + { + startY = findGround(world, startX, startY, startZ); + if (startY == -1) + return false; + } + + float f = random.nextFloat() * (float) Math.PI; + int blockNumber = numberOfBlocks; + if (alterSize) + blockNumber = numberOfBlocks * 2 / 5 + random.nextInt(numberOfBlocks * 3 / 5); + double d0 = (double) ((float) (startX + 8) + MathHelper.sin(f) * (float) blockNumber / 8.0F); + double d1 = (double) ((float) (startX + 8) - MathHelper.sin(f) * (float) blockNumber / 8.0F); + double d2 = (double) ((float) (startZ + 8) + MathHelper.cos(f) * (float) blockNumber / 8.0F); + double d3 = (double) ((float) (startZ + 8) - MathHelper.cos(f) * (float) blockNumber / 8.0F); + double d4 = (double) (startY + random.nextInt(3) - 2); + double d5 = (double) (startY + random.nextInt(3) - 2); + + for (int l = 0; l <= blockNumber; ++l) + { + double d6 = d0 + (d1 - d0) * (double) l / (double) blockNumber; + double d7 = d4 + (d5 - d4) * (double) l / (double) blockNumber; + double d8 = d2 + (d3 - d2) * (double) l / (double) blockNumber; + double d9 = random.nextDouble() * (double) blockNumber / 16.0D; + double d10 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) blockNumber) + 1.0F) * d9 + 1.0D; + double d11 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) blockNumber) + 1.0F) * d9 + 1.0D; + int i1 = MathHelper.floor_double(d6 - d10 / 2.0D); + int j1 = MathHelper.floor_double(d7 - d11 / 2.0D); + int k1 = MathHelper.floor_double(d8 - d10 / 2.0D); + int l1 = MathHelper.floor_double(d6 + d10 / 2.0D); + int i2 = MathHelper.floor_double(d7 + d11 / 2.0D); + int j2 = MathHelper.floor_double(d8 + d10 / 2.0D); + + for (int k2 = i1; k2 <= l1; ++k2) + { + double d12 = ((double) k2 + 0.5D - d6) / (d10 / 2.0D); + + if (d12 * d12 < 1.0D) + { + for (int l2 = j1; l2 <= i2; ++l2) + { + double d13 = ((double) l2 + 0.5D - d7) / (d11 / 2.0D); + + if (d12 * d12 + d13 * d13 < 1.0D) + { + for (int i3 = k1; i3 <= j2; ++i3) + { + double d14 = ((double) i3 + 0.5D - d8) / (d10 / 2.0D); + + Block block = Block.blocksList[world.getBlockId(k2, l2, i3)]; + if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D) + { + if (block == null || !Block.opaqueCubeLookup[world.getBlockId(k2, l2, i3)]) + world.setBlock(k2, l2, i3, this.minableBlockId, minableBlockMeta, 2); + else + { + for (int iter = 0; iter < replaceBlocks.length; iter++) + { + if (block.isGenMineableReplaceable(world, k2, l2, i3, replaceBlocks[iter])) + { + world.setBlock(k2, l2, i3, this.minableBlockId, minableBlockMeta, 2); + break; + } + } + } + } + } + } + } + } + } + } + + return true; + } +} diff --git a/tconstruct/worldgen/TBaseWorldGenerator.java b/tconstruct/worldgen/TBaseWorldGenerator.java new file mode 100644 index 00000000..259778a2 --- /dev/null +++ b/tconstruct/worldgen/TBaseWorldGenerator.java @@ -0,0 +1,333 @@ +package tconstruct.worldgen; + +import java.util.Random; + +import tconstruct.common.TContent; +import tconstruct.crystal.TheftValueTracker; +import tconstruct.library.util.ValueCoordTuple; +import tconstruct.util.PHConstruct; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.world.World; +import net.minecraft.world.WorldType; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenMinable; +import cpw.mods.fml.common.IWorldGenerator; + +public class TBaseWorldGenerator implements IWorldGenerator +{ + public TBaseWorldGenerator() + { + copper = new WorldGenMinable(TContent.oreSlag.blockID, 3, 8, Block.stone.blockID); + tin = new WorldGenMinable(TContent.oreSlag.blockID, 4, 8, Block.stone.blockID); + aluminum = new WorldGenMinable(TContent.oreSlag.blockID, 5, 6, Block.stone.blockID); + + cobalt = new WorldGenMinable(TContent.oreSlag.blockID, 1, 3, Block.netherrack.blockID); + ardite = new WorldGenMinable(TContent.oreSlag.blockID, 2, 3, Block.netherrack.blockID); + + ironBush = new OreberryBushGen(TContent.oreBerry.blockID, 12, 12); + goldBush = new OreberryBushGen(TContent.oreBerry.blockID, 13, 6); + copperBush = new OreberryBushGen(TContent.oreBerry.blockID, 14, 12); + tinBush = new OreberryBushGen(TContent.oreBerry.blockID, 15, 12); + aluminumBush = new OreberryBushGen(TContent.oreBerrySecond.blockID, 12, 14); + silverBush = new OreberryBushGen(TContent.oreBerrySecond.blockID, 13, 8); + } + + @Override + public void generate (Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + { + initializeChunkData(chunkX, chunkZ, world.provider.dimensionId); + + if (world.provider.isHellWorld) + { + generateNether(random, chunkX * 16, chunkZ * 16, world); + } + else if (world.provider.terrainType != WorldType.FLAT) + { + generateSurface(random, chunkX * 16, chunkZ * 16, world); + if (world.provider.dimensionId == 0) + generateOreBushes(random, chunkX * 16, chunkZ * 16, world); + } + + if (PHConstruct.superfunWorld && world.provider.dimensionId == 0) + { + superfunGenerate(random, chunkX * 16, chunkZ * 16, world); + } + + if (PHConstruct.worldBorder) + { + generateChunkBorder(random, chunkX * 16, chunkZ * 16, world); + } + } + + void initializeChunkData (int chunkX, int chunkZ, int worldID) + { + ValueCoordTuple coord = new ValueCoordTuple(worldID, chunkX, chunkZ); + TheftValueTracker.crystallinity.put(coord, 0); + } + + void generateSurface (Random random, int xChunk, int zChunk, World world) + { + String biomeName = world.getWorldChunkManager().getBiomeGenAt(xChunk, zChunk).biomeName; + + generateUndergroundOres(random, xChunk, zChunk, world); + + if (biomeName == "Extreme Hills Edge" || biomeName == "Extreme Hills") + { + generateUndergroundOres(random, xChunk, zChunk, world); + } + } + + void generateUndergroundOres (Random random, int xChunk, int zChunk, World world) + { + int xPos, yPos, zPos; + if (PHConstruct.generateCopper) + { + for (int q = 0; q <= PHConstruct.copperuDensity; q++) + { + xPos = xChunk + random.nextInt(16); + yPos = PHConstruct.copperuMinY + random.nextInt(PHConstruct.copperuMaxY - PHConstruct.copperuMinY); + zPos = zChunk + random.nextInt(16); + copper.generate(world, random, xPos, yPos, zPos); + } + } + if (PHConstruct.generateTin) + { + for (int q = 0; q <= PHConstruct.tinuDensity; q++) + { + xPos = xChunk + random.nextInt(16); + yPos = PHConstruct.tinuMinY + random.nextInt(PHConstruct.tinuMaxY - PHConstruct.tinuMinY); + zPos = zChunk + random.nextInt(16); + tin.generate(world, random, xPos, yPos, zPos); + } + } + if (PHConstruct.generateAluminum) + { + for (int q = 0; q <= PHConstruct.aluminumuDensity; q++) + { + xPos = xChunk + random.nextInt(16); + yPos = PHConstruct.aluminumuMinY + random.nextInt(PHConstruct.aluminumuMaxY - PHConstruct.aluminumuMinY); + zPos = zChunk + random.nextInt(16); + aluminum.generate(world, random, xPos, yPos, zPos); + } + } + } + + void generateOreBushes (Random random, int xChunk, int zChunk, World world) + { + int xPos, yPos, zPos; + if (PHConstruct.generateIronBush && random.nextInt(PHConstruct.ironBushRarity + 1) == 0) + { + for (int i = 0; i < PHConstruct.ironBushDensity; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = PHConstruct.seaLevel - 32; + zPos = zChunk + random.nextInt(16); + yPos = findAdequateLocation(world, xPos, yPos, zPos, PHConstruct.seaLevel, 0); + if (yPos != -1) + { + /*CoordTuple coord = new CoordTuple(xPos, yPos, zPos); + System.out.println("Iron: "+coord.toString());*/ + ironBush.generate(world, random, xPos, yPos, zPos); + } + } + } + if (PHConstruct.generateGoldBush && random.nextInt(PHConstruct.goldBushRarity + 1) == 0) + { + for (int i = 0; i < PHConstruct.goldBushDensity; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 16; + zPos = zChunk + random.nextInt(16); + yPos = findAdequateLocation(world, xPos, yPos, zPos, 32, 0); + if (yPos != -1) + { + /*CoordTuple coord = new CoordTuple(xPos, yPos, zPos); + System.out.println("Gold: "+coord.toString());*/ + goldBush.generate(world, random, xPos, yPos, zPos); + } + } + } + if (PHConstruct.generateCopperBush && random.nextInt(PHConstruct.copperBushRarity + 1) == 0)// && random.nextInt(PHConstruct.copperbRarity) == 0) + { + for (int i = 0; i < PHConstruct.copperBushDensity; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = (PHConstruct.copperBushMaxY + PHConstruct.copperBushMinY) / 2; + zPos = zChunk + random.nextInt(16); + yPos = findAdequateLocation(world, xPos, yPos, zPos, PHConstruct.copperBushMaxY, PHConstruct.copperBushMinY); + if (yPos != -1) + { + /*CoordTuple coord = new CoordTuple(xPos, yPos, zPos); + System.out.println("Copper: "+coord.toString());*/ + copperBush.generate(world, random, xPos, yPos, zPos); + } + } + } + if (PHConstruct.generateTinBush && random.nextInt(PHConstruct.tinBushRarity + 1) == 0)// && random.nextInt(PHConstruct.tinbRarity) == 0) + { + for (int i = 0; i < PHConstruct.tinBushDensity; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = (PHConstruct.tinBushMaxY + PHConstruct.tinBushMinY) / 2; + zPos = zChunk + random.nextInt(16); + yPos = findAdequateLocation(world, xPos, yPos, zPos, PHConstruct.tinBushMaxY, PHConstruct.tinBushMinY); + if (yPos != -1) + { + /*CoordTuple coord = new CoordTuple(xPos, yPos, zPos); + System.out.println("Tin: "+coord.toString());*/ + tinBush.generate(world, random, xPos, yPos, zPos); + } + } + } + if (PHConstruct.generateAluminumBush && random.nextInt(PHConstruct.aluminumBushRarity + 1) == 0)// && random.nextInt(PHConstruct.aluminumbRarity) == 0) + { + for (int i = 0; i < PHConstruct.aluminumBushDensity; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = (PHConstruct.aluminumBushMaxY + PHConstruct.aluminumBushMinY) / 2; + zPos = zChunk + random.nextInt(16); + yPos = findAdequateLocation(world, xPos, yPos, zPos, PHConstruct.aluminumBushMaxY, PHConstruct.aluminumBushMinY); + if (yPos != -1) + { + /*CoordTuple coord = new CoordTuple(xPos, yPos, zPos); + System.out.println("Aluminum: "+coord.toString());*/ + aluminumBush.generate(world, random, xPos, yPos, zPos); + } + } + } + if (PHConstruct.generateEssenceBush && random.nextInt(PHConstruct.essenceBushRarity) == 0) + { + for (int i = 0; i < PHConstruct.silverBushDensity; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = PHConstruct.seaLevel - 16; + zPos = zChunk + random.nextInt(16); + yPos = findAdequateLocation(world, xPos, yPos, zPos, 32, 0); + if (yPos != -1) + { + /*CoordTuple coord = new CoordTuple(xPos, yPos, zPos); + System.out.println("Silver: "+coord.toString());*/ + silverBush.generate(world, random, xPos, yPos, zPos); + } + } + } + } + + void generateNether (Random random, int xChunk, int zChunk, World world) + { + int xPos, yPos, zPos; + if (PHConstruct.generateNetherOres) + { + for (int i = 0; i < PHConstruct.netherDensity; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = random.nextInt(64) + 32; + zPos = zChunk + random.nextInt(16); + cobalt.generate(world, random, xPos, yPos, zPos); + + xPos = xChunk + random.nextInt(16); + yPos = random.nextInt(64) + 32; + zPos = zChunk + random.nextInt(16); + ardite.generate(world, random, xPos, yPos, zPos); + + } + for (int i = 0; i < PHConstruct.netherDensity; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = random.nextInt(128); + zPos = zChunk + random.nextInt(16); + cobalt.generate(world, random, xPos, yPos, zPos); + + xPos = xChunk + random.nextInt(16); + yPos = random.nextInt(128); + zPos = zChunk + random.nextInt(16); + ardite.generate(world, random, xPos, yPos, zPos); + } + } + } + + int findAdequateLocation (World world, int x, int y, int z, int heightLimit, int depthLimit) + { + int height = y; + do + { + if (world.getBlockId(x, height, z) == 0 && world.getBlockId(x, height + 1, z) != 0) + return height + 1; + height++; + } while (height < heightLimit); + + height = y; + do + { + if (world.getBlockId(x, height, z) == 0 && world.getBlockId(x, height - 1, z) != 0) + return height - 1; + height--; + } while (height > depthLimit); + + return -1; + } + + void superfunGenerate (Random random, int chunkX, int chunkZ, World world) + { + /*for (int x = 0; x < 16; x++) + for (int z = 0; z < 16; z++) + world.setBlock(x+chunkX, 192, z+chunkZ, Block.glowStone.blockID);*/ + + for (int x = 0; x < 16; x++) + { + for (int z = 0; z < 16; z++) + { + for (int y = 0; y < 128; y++) + { + int blockID = world.getBlockId(x + chunkX, y, z + chunkZ); + Block block = Block.blocksList[blockID]; + if (block != null) + { + if (block.blockMaterial == Material.leaves) + world.setBlock(x + chunkX, y, z + chunkZ, Block.lavaStill.blockID, 0, 0); + if (block.blockMaterial == Material.wood) + world.setBlock(x + chunkX, y, z + chunkZ, Block.netherrack.blockID, 0, 0); + if (block.blockID == Block.stone.blockID) + world.setBlock(x + chunkX, y, z + chunkZ, Block.whiteStone.blockID, 0, 0); + if (y > 40 && (block.blockMaterial == Material.ground || block.blockMaterial == Material.grass)) + world.setBlock(x + chunkX, y, z + chunkZ, Block.slowSand.blockID, 0, 0); + if (block.blockMaterial == Material.sand) + world.setBlock(x + chunkX, y, z + chunkZ, Block.silverfish.blockID, 0, 0); + } + } + } + } + } + + void generateChunkBorder (Random random, int chunkX, int chunkZ, World world) + { + for (int x = 0; x < 16; x++) + { + for (int z = 0; z < 16; z++) + { + if (x + chunkX == PHConstruct.worldBorderSize || x + chunkX == -PHConstruct.worldBorderSize || z + chunkZ == PHConstruct.worldBorderSize || z + chunkZ == -PHConstruct.worldBorderSize) + { + for (int y = 0; y < 256; y++) + { + world.setBlock(x + chunkX, y, z + chunkZ, Block.bedrock.blockID, 0, 0); + } + } + } + } + } + + WorldGenMinable copper; + WorldGenMinable tin; + WorldGenMinable aluminum; + WorldGenMinable cobalt; + WorldGenMinable ardite; + + OreberryBushGen ironBush; + OreberryBushGen goldBush; + OreberryBushGen copperBush; + OreberryBushGen tinBush; + OreberryBushGen aluminumBush; + OreberryBushGen silverBush; +} diff --git a/tconstruct/worldgen/TerrainGenEventHandler.java b/tconstruct/worldgen/TerrainGenEventHandler.java new file mode 100644 index 00000000..80bc9866 --- /dev/null +++ b/tconstruct/worldgen/TerrainGenEventHandler.java @@ -0,0 +1,92 @@ +package tconstruct.worldgen; + +import static net.minecraft.world.biome.BiomeGenBase.extremeHills; +import static net.minecraft.world.biome.BiomeGenBase.extremeHillsEdge; +import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SAND; + +import java.util.Random; + +import tconstruct.common.TContent; +import tconstruct.util.PHConstruct; + +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate; + +import com.google.common.collect.ImmutableCollection; +import com.google.common.collect.ImmutableList; + +public class TerrainGenEventHandler +{ + private final SurfaceOreGen ironSurface = new SurfaceOreGen(TContent.oreGravel.blockID, 0, 12, true); + private final SurfaceOreGen goldSurface = new SurfaceOreGen(TContent.oreGravel.blockID, 1, 20, true); + private final SurfaceOreGen copperSurface = new SurfaceOreGen(TContent.oreGravel.blockID, 2, 12, true); + private final SurfaceOreGen tinSurface = new SurfaceOreGen(TContent.oreGravel.blockID, 3, 12, true); + private final SurfaceOreGen aluminumSurface = new SurfaceOreGen(TContent.oreGravel.blockID, 4, 12, true); + private final SurfaceOreGen cobaltSurface = new SurfaceOreGen(TContent.oreGravel.blockID, 5, 30, true); + + private static ImmutableCollection EXTRA_ORE_BIOMES = ImmutableList.of(extremeHills, extremeHillsEdge); + + @ForgeSubscribe + public void onDecorateEvent (Decorate e) + { + // Trigger just before sand pass one--which comes just after vanilla ore generation. + if (e.type != SAND) + return; + + BiomeGenBase biome = e.world.getWorldChunkManager().getBiomeGenAt(e.chunkX, e.chunkZ); + int iterations = EXTRA_ORE_BIOMES.contains(biome) ? 2 : 1; + for (int i = 0; i < iterations; i++) + { + generateSurfaceOres(e.rand, e.chunkX, e.chunkZ, e.world); + } + } + + private void generateSurfaceOres (Random random, int xChunk, int zChunk, World world) + { + int xPos, yPos, zPos; + if (PHConstruct.generateIronSurface && random.nextInt(PHConstruct.ironsRarity) == 0) + { + xPos = xChunk + random.nextInt(16); + yPos = 64 + PHConstruct.seaLevel; + zPos = zChunk + random.nextInt(16); + ironSurface.generate(world, random, xPos, yPos, zPos); + } + if (PHConstruct.generateGoldSurface && random.nextInt(PHConstruct.goldsRarity) == 0) + { + xPos = xChunk + random.nextInt(16); + yPos = 64 + PHConstruct.seaLevel; + zPos = zChunk + random.nextInt(16); + goldSurface.generate(world, random, xPos, yPos, zPos); + } + if (PHConstruct.generateCopperSurface && random.nextInt(PHConstruct.coppersRarity) == 0) + { + xPos = xChunk + random.nextInt(16); + yPos = 64 + PHConstruct.seaLevel; + zPos = zChunk + random.nextInt(16); + copperSurface.generate(world, random, xPos, yPos, zPos); + } + if (PHConstruct.generateTinSurface && random.nextInt(PHConstruct.tinsRarity) == 0) + { + xPos = xChunk + random.nextInt(16); + yPos = 64 + PHConstruct.seaLevel; + zPos = zChunk + random.nextInt(16); + tinSurface.generate(world, random, xPos, yPos, zPos); + } + if (PHConstruct.generateAluminumSurface && random.nextInt(PHConstruct.aluminumsRarity) == 0) + { + xPos = xChunk + random.nextInt(16); + yPos = 64 + PHConstruct.seaLevel; + zPos = zChunk + random.nextInt(16); + aluminumSurface.generate(world, random, xPos, yPos, zPos); + } + if (PHConstruct.generateCobaltSurface && random.nextInt(PHConstruct.cobaltsRarity) == 0) + { + xPos = xChunk + random.nextInt(16); + yPos = 64 + PHConstruct.seaLevel; + zPos = zChunk + random.nextInt(16); + cobaltSurface.generate(world, random, xPos, yPos, zPos); + } + } +} diff --git a/tconstruct/worldgen/village/ComponentSmeltery.java b/tconstruct/worldgen/village/ComponentSmeltery.java new file mode 100644 index 00000000..014e27f6 --- /dev/null +++ b/tconstruct/worldgen/village/ComponentSmeltery.java @@ -0,0 +1,116 @@ +package tconstruct.worldgen.village; + +import java.util.List; +import java.util.Random; + +import tconstruct.common.TContent; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.ComponentVillage; +import net.minecraft.world.gen.structure.ComponentVillageStartPiece; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; + +public class ComponentSmeltery extends ComponentVillage +{ + private int averageGroundLevel = -1; + + public ComponentSmeltery(ComponentVillageStartPiece par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + } + + public static ComponentSmeltery buildComponent (ComponentVillageStartPiece villagePiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 9, 3, 7, p4); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(pieces, structureboundingbox) == null ? new ComponentSmeltery(villagePiece, p5, random, + structureboundingbox, p4) : null; + } + + /** + * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at + * the end, it adds Fences... + */ + public boolean addComponentParts (World world, Random random, StructureBoundingBox sbb) + { + if (this.averageGroundLevel < 0) + { + this.averageGroundLevel = this.getAverageGroundLevel(world, sbb); + + if (this.averageGroundLevel < 0) + { + return true; + } + + this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + 2, 0); + } + + /** + * arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int + * maxZ, int placeBlockId, int replaceBlockId, boolean alwaysreplace) + */ + + this.fillWithBlocks(world, sbb, 1, 0, 0, 7, 0, 6, Block.stoneBrick.blockID, Block.stoneBrick.blockID, false); //Base + this.fillWithBlocks(world, sbb, 0, 0, 1, 0, 0, 5, Block.stoneBrick.blockID, Block.stoneBrick.blockID, false); + this.fillWithBlocks(world, sbb, 8, 0, 1, 8, 0, 5, Block.stoneBrick.blockID, Block.stoneBrick.blockID, false); + this.fillWithBlocks(world, sbb, 0, 1, 0, 9, 3, 7, 0, 0, false); + + this.fillWithMetaBlocks(world, sbb, 2, 0, 1, 6, 2, 5, TContent.smeltery.blockID, 2, TContent.smeltery.blockID, 2, false); //Basin + this.fillWithBlocks(world, sbb, 3, 1, 2, 5, 2, 4, 0, 0, false); + + this.placeBlockAtCurrentPosition(world, TContent.searedBlock.blockID, 0, 1, 1, 2, sbb); + this.placeBlockAtCurrentPosition(world, TContent.searedBlock.blockID, 2, 1, 1, 4, sbb); + this.placeBlockAtCurrentPosition(world, TContent.searedBlock.blockID, 0, 7, 1, 2, sbb); + this.placeBlockAtCurrentPosition(world, TContent.searedBlock.blockID, 2, 7, 1, 4, sbb); + + for (int l = 1; l < 6; ++l) + { + for (int i1 = 0; i1 < 9; ++i1) + { + this.clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); + this.fillCurrentPositionBlocksDownwards(world, Block.stoneBrick.blockID, 0, i1, -1, l, sbb); + } + } + + for (int l = 0; l < 7; ++l) + { + for (int i1 = 1; i1 < 8; ++i1) + { + this.clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); + this.fillCurrentPositionBlocksDownwards(world, Block.stoneBrick.blockID, 0, i1, -1, l, sbb); + } + } + return true; + } + + int remapDirection (int direction) + { + System.out.println("Direction: " + direction); + switch (direction) + { + case 0: + return 2; + case 1: + return 3; + case 2: + return 1; + case 3: + return 0; + } + System.out.println("This shouldn't happen"); + return -1; + } + + protected void fillWithMetaBlocks (World par1World, StructureBoundingBox par2StructureBoundingBox, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int placeBlockID, + int placeBlockMeta, int replaceBlockID, int replaceBlockMeta, boolean alwaysReplace) + { + int i2 = this.getBiomeSpecificBlock(placeBlockID, placeBlockMeta); + int j2 = this.getBiomeSpecificBlockMetadata(placeBlockID, placeBlockMeta); + int k2 = this.getBiomeSpecificBlock(replaceBlockID, replaceBlockMeta); + int l2 = this.getBiomeSpecificBlockMetadata(replaceBlockID, replaceBlockMeta); + super.fillWithMetadataBlocks(par1World, par2StructureBoundingBox, minX, minY, minZ, maxX, maxY, maxZ, i2, j2, k2, l2, alwaysReplace); + } +} diff --git a/tconstruct/worldgen/village/ComponentToolWorkshop.java b/tconstruct/worldgen/village/ComponentToolWorkshop.java new file mode 100644 index 00000000..84d7cc94 --- /dev/null +++ b/tconstruct/worldgen/village/ComponentToolWorkshop.java @@ -0,0 +1,178 @@ +package tconstruct.worldgen.village; + +import java.util.List; +import java.util.Random; + +import tconstruct.blocks.logic.PatternChestLogic; +import tconstruct.common.TContent; + +import net.minecraft.block.Block; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.ComponentVillage; +import net.minecraft.world.gen.structure.ComponentVillageStartPiece; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; + +public class ComponentToolWorkshop extends ComponentVillage +{ + private int averageGroundLevel = -1; + + public ComponentToolWorkshop(ComponentVillageStartPiece par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + } + + public static ComponentToolWorkshop buildComponent (ComponentVillageStartPiece villagePiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 7, 6, 7, p4); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(pieces, structureboundingbox) == null ? new ComponentToolWorkshop(villagePiece, p5, random, + structureboundingbox, p4) : null; + } + + /** + * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at + * the end, it adds Fences... + */ + public boolean addComponentParts (World world, Random random, StructureBoundingBox sbb) + { + if (this.averageGroundLevel < 0) + { + this.averageGroundLevel = this.getAverageGroundLevel(world, sbb); + + if (this.averageGroundLevel < 0) + { + return true; + } + + this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + 4, 0); + } + + /** + * arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int + * maxZ, int placeBlockId, int replaceBlockId, boolean alwaysreplace) + */ + + this.fillWithBlocks(world, sbb, 0, 0, 0, 6, 0, 6, Block.cobblestone.blockID, Block.cobblestone.blockID, false); //Base + this.fillWithBlocks(world, sbb, 0, 5, 0, 6, 5, 6, Block.fence.blockID, Block.fence.blockID, false); + this.fillWithBlocks(world, sbb, 1, 0, 1, 5, 0, 5, Block.planks.blockID, Block.planks.blockID, false); + this.fillWithBlocks(world, sbb, 2, 0, 2, 4, 0, 4, Block.cloth.blockID, Block.cloth.blockID, false); + + //this.fillWithBlocks(world, sbb, 0, 5, 0, 6, 5, 6, Block.wood.blockID, Block.wood.blockID, false); + + this.fillWithBlocks(world, sbb, 0, 1, 0, 0, 4, 0, Block.wood.blockID, Block.wood.blockID, false); //Edges + this.fillWithBlocks(world, sbb, 0, 1, 6, 0, 4, 6, Block.wood.blockID, Block.wood.blockID, false); + this.fillWithBlocks(world, sbb, 6, 1, 0, 6, 4, 0, Block.wood.blockID, Block.wood.blockID, false); + this.fillWithBlocks(world, sbb, 6, 1, 6, 6, 4, 6, Block.wood.blockID, Block.wood.blockID, false); + + this.fillWithBlocks(world, sbb, 0, 1, 1, 0, 1, 5, Block.planks.blockID, Block.planks.blockID, false); //Walls + this.fillWithBlocks(world, sbb, 1, 1, 0, 5, 1, 0, Block.planks.blockID, Block.planks.blockID, false); + this.fillWithBlocks(world, sbb, 6, 1, 1, 6, 1, 5, Block.planks.blockID, Block.planks.blockID, false); + this.fillWithBlocks(world, sbb, 1, 1, 6, 5, 1, 6, Block.planks.blockID, Block.planks.blockID, false); + + this.fillWithBlocks(world, sbb, 0, 3, 1, 0, 3, 5, Block.planks.blockID, Block.planks.blockID, false); + this.fillWithBlocks(world, sbb, 1, 3, 0, 5, 3, 0, Block.planks.blockID, Block.planks.blockID, false); + this.fillWithBlocks(world, sbb, 6, 3, 1, 6, 3, 5, Block.planks.blockID, Block.planks.blockID, false); + this.fillWithBlocks(world, sbb, 1, 3, 6, 5, 3, 6, Block.planks.blockID, Block.planks.blockID, false); + + this.fillWithBlocks(world, sbb, 0, 4, 1, 0, 4, 5, Block.wood.blockID, Block.wood.blockID, false); + this.fillWithBlocks(world, sbb, 1, 4, 0, 5, 4, 0, Block.wood.blockID, Block.wood.blockID, false); + this.fillWithBlocks(world, sbb, 6, 4, 1, 6, 4, 5, Block.wood.blockID, Block.wood.blockID, false); + this.fillWithBlocks(world, sbb, 1, 4, 6, 5, 4, 6, Block.wood.blockID, Block.wood.blockID, false); + + this.fillWithBlocks(world, sbb, 1, 1, 1, 5, 5, 5, 0, 0, false); + this.fillWithBlocks(world, sbb, 1, 4, 1, 5, 4, 5, Block.planks.blockID, Block.planks.blockID, false); + + //world, blockID, metadata, x, y, z, bounds + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 1, 2, 0, sbb);//Glass and door + this.placeBlockAtCurrentPosition(world, Block.planks.blockID, 0, 2, 2, 0, sbb); + this.placeDoorAtCurrentPosition(world, sbb, random, 3, 1, 0, this.getMetadataWithOffset(Block.doorWood.blockID, 1)); + this.placeBlockAtCurrentPosition(world, Block.planks.blockID, 0, 4, 2, 0, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 5, 2, 0, sbb); + + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 1, 2, 6, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 2, 2, 6, sbb); + this.placeBlockAtCurrentPosition(world, Block.planks.blockID, 0, 3, 2, 6, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 4, 2, 6, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 5, 2, 6, sbb); + + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 0, 2, 1, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 0, 2, 2, sbb); + this.placeBlockAtCurrentPosition(world, Block.planks.blockID, 0, 0, 2, 3, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 0, 2, 4, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 0, 2, 5, sbb); + + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 6, 2, 1, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 6, 2, 2, sbb); + this.placeBlockAtCurrentPosition(world, Block.planks.blockID, 0, 6, 2, 3, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 6, 2, 4, sbb); + this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 6, 2, 5, sbb); + + int i = this.getMetadataWithOffset(Block.ladder.blockID, 3); //Ladders + this.placeBlockAtCurrentPosition(world, Block.ladder.blockID, i, 3, 1, 5, sbb); + this.placeBlockAtCurrentPosition(world, Block.ladder.blockID, i, 3, 2, 5, sbb); + this.placeBlockAtCurrentPosition(world, Block.ladder.blockID, i, 3, 3, 5, sbb); + this.placeBlockAtCurrentPosition(world, Block.ladder.blockID, i, 3, 4, 5, sbb); + + this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 0, 1, 1, 1, sbb); //Inside + this.generateStructurePatternChestContents(world, sbb, random, 1, 1, 2, TContent.tinkerHousePatterns.getItems(random), TContent.tinkerHousePatterns.getCount(random)); + //this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 5, 1, 1, 2, sbb); + this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 1, 1, 1, 3, sbb); + this.placeBlockAtCurrentPosition(world, Block.workbench.blockID, 0, 1, 1, 4, sbb); + this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 10, 1, 1, 5, sbb); + + //ChestGenHooks info = ChestGenHooks.getInfo("TinkerHouse"); + + this.generateStructureChestContents(world, sbb, random, 4, 1, 5, TContent.tinkerHouseChest.getItems(random), TContent.tinkerHouseChest.getCount(random)); + //this.placeBlockAtCurrentPosition(world, Block.chest.blockID, i, 4, 1, 5, sbb); + i = this.getMetadataWithOffset(Block.pistonBase.blockID, 3); + this.placeBlockAtCurrentPosition(world, Block.pistonBase.blockID, i, 5, 1, 5, sbb); + + for (int l = 0; l < 6; ++l) + { + for (int i1 = 0; i1 < 9; ++i1) + { + this.clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); + this.fillCurrentPositionBlocksDownwards(world, Block.cobblestone.blockID, 0, i1, -1, l, sbb); + } + } + this.spawnVillagers(world, sbb, 3, 1, 3, 1); + + return true; + } + + protected boolean generateStructurePatternChestContents (World world, StructureBoundingBox par2StructureBoundingBox, Random random, int x, int y, int z, WeightedRandomChestContent[] content, + int par8) + { + int posX = this.getXWithOffset(x, z); + int posY = this.getYWithOffset(y); + int posZ = this.getZWithOffset(x, z); + + if (par2StructureBoundingBox.isVecInside(posX, posY, posZ) && world.getBlockId(posX, posY, posZ) != Block.chest.blockID) + { + world.setBlock(posX, posY, posZ, TContent.toolStationWood.blockID, 5, 2); + PatternChestLogic logic = (PatternChestLogic) world.getBlockTileEntity(posX, posY, posZ); + + if (logic != null) + { + WeightedRandomChestContent.generateChestContents(random, content, logic, par8); + } + + return true; + } + else + { + return false; + } + } + + /** + * Returns the villager type to spawn in this component, based on the number of villagers already spawned. + */ + protected int getVillagerType (int par1) + { + return 78943; + } +} diff --git a/tconstruct/worldgen/village/TVillageTrades.java b/tconstruct/worldgen/village/TVillageTrades.java new file mode 100644 index 00000000..e7b84504 --- /dev/null +++ b/tconstruct/worldgen/village/TVillageTrades.java @@ -0,0 +1,35 @@ +package tconstruct.worldgen.village; + +import java.util.Random; + +import tconstruct.common.TContent; + +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; + +public class TVillageTrades implements IVillageTradeHandler +{ + + @Override + public void manipulateTradesForVillager (EntityVillager villager, MerchantRecipeList recipeList, Random random) + { + if (villager.getProfession() == 78943) + { + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 1, 23), new ItemStack(TContent.materials, 1, 20))); + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 4, 23), new ItemStack(Item.arrow, 4))); + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 1, 23), new ItemStack(TContent.materials, 1, 0))); + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 1, 23), new ItemStack(TContent.materials, 1, 21))); + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 5, 23), new ItemStack(TContent.materials, 1, 1))); + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 1, 23), new ItemStack(TContent.materials, 1, 22))); + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 2, 23), new ItemStack(TContent.materials, 1, 2))); + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 1, 23), new ItemStack(TContent.materials, 1, 19))); + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 64, 23), new ItemStack(TContent.materials, 1, 6))); + recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(TContent.materials, 64, 23), new ItemStack(TContent.materials, 1, 7))); + } + } + +} diff --git a/tconstruct/worldgen/village/VillageSmelteryHandler.java b/tconstruct/worldgen/village/VillageSmelteryHandler.java new file mode 100644 index 00000000..2eb94752 --- /dev/null +++ b/tconstruct/worldgen/village/VillageSmelteryHandler.java @@ -0,0 +1,31 @@ +package tconstruct.worldgen.village; + +import java.util.List; +import java.util.Random; + +import net.minecraft.world.gen.structure.ComponentVillageStartPiece; +import net.minecraft.world.gen.structure.StructureVillagePieceWeight; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler; + +public class VillageSmelteryHandler implements IVillageCreationHandler +{ + + @Override + public StructureVillagePieceWeight getVillagePieceWeight (Random random, int i) + { + return new StructureVillagePieceWeight(ComponentSmeltery.class, 9, i + random.nextInt(10) == 0 ? 1 : 0); + } + + @Override + public Class getComponentClass () + { + return ComponentSmeltery.class; + } + + @Override + public Object buildComponent (StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) + { + return ComponentSmeltery.buildComponent(startPiece, pieces, random, p1, p2, p3, p4, p5); + } + +} diff --git a/tconstruct/worldgen/village/VillageToolStationHandler.java b/tconstruct/worldgen/village/VillageToolStationHandler.java new file mode 100644 index 00000000..882e77be --- /dev/null +++ b/tconstruct/worldgen/village/VillageToolStationHandler.java @@ -0,0 +1,31 @@ +package tconstruct.worldgen.village; + +import java.util.List; +import java.util.Random; + +import net.minecraft.world.gen.structure.ComponentVillageStartPiece; +import net.minecraft.world.gen.structure.StructureVillagePieceWeight; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler; + +public class VillageToolStationHandler implements IVillageCreationHandler +{ + + @Override + public StructureVillagePieceWeight getVillagePieceWeight (Random random, int i) + { + return new StructureVillagePieceWeight(ComponentToolWorkshop.class, 30, i + random.nextInt(4)); + } + + @Override + public Class getComponentClass () + { + return ComponentToolWorkshop.class; + } + + @Override + public Object buildComponent (StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) + { + return ComponentToolWorkshop.buildComponent(startPiece, pieces, random, p1, p2, p3, p4, p5); + } + +}