diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 412eeda7..00000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/src/assets/warpdrive/sound/cloak.ogg b/src/assets/warpdrive/sound/cloak.ogg new file mode 100644 index 00000000..49f4c0ec Binary files /dev/null and b/src/assets/warpdrive/sound/cloak.ogg differ diff --git a/src/assets/warpdrive/sound/decloak.ogg b/src/assets/warpdrive/sound/decloak.ogg new file mode 100644 index 00000000..448fcf11 Binary files /dev/null and b/src/assets/warpdrive/sound/decloak.ogg differ diff --git a/src/assets/warpdrive/sound/hilaser.ogg b/src/assets/warpdrive/sound/hilaser.ogg new file mode 100644 index 00000000..edc93fc4 Binary files /dev/null and b/src/assets/warpdrive/sound/hilaser.ogg differ diff --git a/src/assets/warpdrive/sound/lowlaser.ogg b/src/assets/warpdrive/sound/lowlaser.ogg new file mode 100644 index 00000000..823cf770 Binary files /dev/null and b/src/assets/warpdrive/sound/lowlaser.ogg differ diff --git a/src/assets/warpdrive/sound/midlaser.ogg b/src/assets/warpdrive/sound/midlaser.ogg new file mode 100644 index 00000000..b1252d3f Binary files /dev/null and b/src/assets/warpdrive/sound/midlaser.ogg differ diff --git a/src/assets/warpdrive/sound/warp.ogg b/src/assets/warpdrive/sound/warp.ogg new file mode 100644 index 00000000..4a148e70 Binary files /dev/null and b/src/assets/warpdrive/sound/warp.ogg differ diff --git a/src/assets/warpdrive/textures/blocks/airBlock.png b/src/assets/warpdrive/textures/blocks/airBlock.png new file mode 100644 index 00000000..1be0e96f Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/airBlock.png differ diff --git a/src/assets/warpdrive/textures/blocks/airgenSideActive.png b/src/assets/warpdrive/textures/blocks/airgenSideActive.png new file mode 100644 index 00000000..e2520225 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/airgenSideActive.png differ diff --git a/src/assets/warpdrive/textures/blocks/airgenSideActive.png.mcmeta b/src/assets/warpdrive/textures/blocks/airgenSideActive.png.mcmeta new file mode 100644 index 00000000..f6e326db --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/airgenSideActive.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} diff --git a/src/assets/warpdrive/textures/blocks/airgenSideInactive.png b/src/assets/warpdrive/textures/blocks/airgenSideInactive.png new file mode 100644 index 00000000..7760f003 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/airgenSideInactive.png differ diff --git a/src/assets/warpdrive/textures/blocks/airgenTopActive.png b/src/assets/warpdrive/textures/blocks/airgenTopActive.png new file mode 100644 index 00000000..e2520225 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/airgenTopActive.png differ diff --git a/src/assets/warpdrive/textures/blocks/boosterSide.png b/src/assets/warpdrive/textures/blocks/boosterSide.png new file mode 100644 index 00000000..8d092153 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/boosterSide.png differ diff --git a/src/assets/warpdrive/textures/blocks/camOverlay.png b/src/assets/warpdrive/textures/blocks/camOverlay.png new file mode 100644 index 00000000..9e3d1e94 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/camOverlay.png differ diff --git a/src/assets/warpdrive/textures/blocks/cameraSide.png b/src/assets/warpdrive/textures/blocks/cameraSide.png new file mode 100644 index 00000000..66332b11 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/cameraSide.png differ diff --git a/src/assets/warpdrive/textures/blocks/cloakCoilSide.png b/src/assets/warpdrive/textures/blocks/cloakCoilSide.png new file mode 100644 index 00000000..035a9721 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/cloakCoilSide.png differ diff --git a/src/assets/warpdrive/textures/blocks/cloakCoilSideActive.png b/src/assets/warpdrive/textures/blocks/cloakCoilSideActive.png new file mode 100644 index 00000000..7b8c1c3b Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/cloakCoilSideActive.png differ diff --git a/src/assets/warpdrive/textures/blocks/cloakCoilSideActive.png.mcmeta b/src/assets/warpdrive/textures/blocks/cloakCoilSideActive.png.mcmeta new file mode 100644 index 00000000..0645f48c --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/cloakCoilSideActive.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} diff --git a/src/assets/warpdrive/textures/blocks/cloakingCoreActive.png b/src/assets/warpdrive/textures/blocks/cloakingCoreActive.png new file mode 100644 index 00000000..48737a1c Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/cloakingCoreActive.png differ diff --git a/src/assets/warpdrive/textures/blocks/cloakingCoreActive.png.mcmeta b/src/assets/warpdrive/textures/blocks/cloakingCoreActive.png.mcmeta new file mode 100644 index 00000000..0645f48c --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/cloakingCoreActive.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} diff --git a/src/assets/warpdrive/textures/blocks/cloakingCoreInactive.png b/src/assets/warpdrive/textures/blocks/cloakingCoreInactive.png new file mode 100644 index 00000000..e235c863 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/cloakingCoreInactive.png differ diff --git a/src/assets/warpdrive/textures/blocks/contBottom.png b/src/assets/warpdrive/textures/blocks/contBottom.png new file mode 100644 index 00000000..b150416a Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contBottom.png differ diff --git a/src/assets/warpdrive/textures/blocks/contSideActive0.png b/src/assets/warpdrive/textures/blocks/contSideActive0.png new file mode 100644 index 00000000..09d00940 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contSideActive0.png differ diff --git a/src/assets/warpdrive/textures/blocks/contSideActive1.png b/src/assets/warpdrive/textures/blocks/contSideActive1.png new file mode 100644 index 00000000..1980059b Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contSideActive1.png differ diff --git a/src/assets/warpdrive/textures/blocks/contSideActive1.png.mcmeta b/src/assets/warpdrive/textures/blocks/contSideActive1.png.mcmeta new file mode 100644 index 00000000..b84e69f2 --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/contSideActive1.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 4 + } +} diff --git a/src/assets/warpdrive/textures/blocks/contSideActive2.png b/src/assets/warpdrive/textures/blocks/contSideActive2.png new file mode 100644 index 00000000..a446b704 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contSideActive2.png differ diff --git a/src/assets/warpdrive/textures/blocks/contSideActive2.png.mcmeta b/src/assets/warpdrive/textures/blocks/contSideActive2.png.mcmeta new file mode 100644 index 00000000..b84e69f2 --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/contSideActive2.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 4 + } +} diff --git a/src/assets/warpdrive/textures/blocks/contSideActive3.png b/src/assets/warpdrive/textures/blocks/contSideActive3.png new file mode 100644 index 00000000..36ef3bdc Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contSideActive3.png differ diff --git a/src/assets/warpdrive/textures/blocks/contSideActive3.png.mcmeta b/src/assets/warpdrive/textures/blocks/contSideActive3.png.mcmeta new file mode 100644 index 00000000..f6730e30 --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/contSideActive3.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 4 + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/contSideActive4.png b/src/assets/warpdrive/textures/blocks/contSideActive4.png new file mode 100644 index 00000000..2df281d3 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contSideActive4.png differ diff --git a/src/assets/warpdrive/textures/blocks/contSideActive4.png.mcmeta b/src/assets/warpdrive/textures/blocks/contSideActive4.png.mcmeta new file mode 100644 index 00000000..f6730e30 --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/contSideActive4.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 4 + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/contSideActive5.png b/src/assets/warpdrive/textures/blocks/contSideActive5.png new file mode 100644 index 00000000..ef5dda0c Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contSideActive5.png differ diff --git a/src/assets/warpdrive/textures/blocks/contSideActive5.png.mcmeta b/src/assets/warpdrive/textures/blocks/contSideActive5.png.mcmeta new file mode 100644 index 00000000..b84e69f2 --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/contSideActive5.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 4 + } +} diff --git a/src/assets/warpdrive/textures/blocks/contSideActive6.png b/src/assets/warpdrive/textures/blocks/contSideActive6.png new file mode 100644 index 00000000..202f5045 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contSideActive6.png differ diff --git a/src/assets/warpdrive/textures/blocks/contSideActive6.png.mcmeta b/src/assets/warpdrive/textures/blocks/contSideActive6.png.mcmeta new file mode 100644 index 00000000..b84e69f2 --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/contSideActive6.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 4 + } +} diff --git a/src/assets/warpdrive/textures/blocks/contSideInactive.png b/src/assets/warpdrive/textures/blocks/contSideInactive.png new file mode 100644 index 00000000..2845c4ad Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contSideInactive.png differ diff --git a/src/assets/warpdrive/textures/blocks/contTop.png b/src/assets/warpdrive/textures/blocks/contTop.png new file mode 100644 index 00000000..ec7d79af Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/contTop.png differ diff --git a/src/assets/warpdrive/textures/blocks/coreBottom.png b/src/assets/warpdrive/textures/blocks/coreBottom.png new file mode 100644 index 00000000..43f67ed1 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/coreBottom.png differ diff --git a/src/assets/warpdrive/textures/blocks/coreSideActive.png b/src/assets/warpdrive/textures/blocks/coreSideActive.png new file mode 100644 index 00000000..3c2a0afd Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/coreSideActive.png differ diff --git a/src/assets/warpdrive/textures/blocks/coreSideActive.png.mcmeta b/src/assets/warpdrive/textures/blocks/coreSideActive.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/coreSideActive.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/coreSideInactive.png b/src/assets/warpdrive/textures/blocks/coreSideInactive.png new file mode 100644 index 00000000..1ef47892 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/coreSideInactive.png differ diff --git a/src/assets/warpdrive/textures/blocks/coreTop.png b/src/assets/warpdrive/textures/blocks/coreTop.png new file mode 100644 index 00000000..da52c058 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/coreTop.png differ diff --git a/src/assets/warpdrive/textures/blocks/energy.png b/src/assets/warpdrive/textures/blocks/energy.png new file mode 100644 index 00000000..184f7faa Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/energy.png differ diff --git a/src/assets/warpdrive/textures/blocks/energy_green.png b/src/assets/warpdrive/textures/blocks/energy_green.png new file mode 100644 index 00000000..076e194f Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/energy_green.png differ diff --git a/src/assets/warpdrive/textures/blocks/energy_orange.png b/src/assets/warpdrive/textures/blocks/energy_orange.png new file mode 100644 index 00000000..313dbfa7 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/energy_orange.png differ diff --git a/src/assets/warpdrive/textures/blocks/energy_red.png b/src/assets/warpdrive/textures/blocks/energy_red.png new file mode 100644 index 00000000..8996066d Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/energy_red.png differ diff --git a/src/assets/warpdrive/textures/blocks/energy_sy.png b/src/assets/warpdrive/textures/blocks/energy_sy.png new file mode 100644 index 00000000..80393d78 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/energy_sy.png differ diff --git a/src/assets/warpdrive/textures/blocks/energy_violet.png b/src/assets/warpdrive/textures/blocks/energy_violet.png new file mode 100644 index 00000000..31a99f65 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/energy_violet.png differ diff --git a/src/assets/warpdrive/textures/blocks/energy_yellow.png b/src/assets/warpdrive/textures/blocks/energy_yellow.png new file mode 100644 index 00000000..465d8836 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/energy_yellow.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockBlue.png b/src/assets/warpdrive/textures/blocks/gasBlockBlue.png new file mode 100644 index 00000000..f9916c91 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockBlue.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockDark.png b/src/assets/warpdrive/textures/blocks/gasBlockDark.png new file mode 100644 index 00000000..03e1ecad Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockDark.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockDarkness.png b/src/assets/warpdrive/textures/blocks/gasBlockDarkness.png new file mode 100644 index 00000000..20a1d17c Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockDarkness.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockGray.png b/src/assets/warpdrive/textures/blocks/gasBlockGray.png new file mode 100644 index 00000000..89dc9f83 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockGray.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockGreen.png b/src/assets/warpdrive/textures/blocks/gasBlockGreen.png new file mode 100644 index 00000000..89d35271 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockGreen.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockMilk.png b/src/assets/warpdrive/textures/blocks/gasBlockMilk.png new file mode 100644 index 00000000..cb4181a7 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockMilk.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockOrange.png b/src/assets/warpdrive/textures/blocks/gasBlockOrange.png new file mode 100644 index 00000000..d248516c Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockOrange.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockRed.png b/src/assets/warpdrive/textures/blocks/gasBlockRed.png new file mode 100644 index 00000000..b5891426 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockRed.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockSyren.png b/src/assets/warpdrive/textures/blocks/gasBlockSyren.png new file mode 100644 index 00000000..12505967 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockSyren.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockViolet.png b/src/assets/warpdrive/textures/blocks/gasBlockViolet.png new file mode 100644 index 00000000..824551a3 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockViolet.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockWhite.png b/src/assets/warpdrive/textures/blocks/gasBlockWhite.png new file mode 100644 index 00000000..27fff93f Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockWhite.png differ diff --git a/src/assets/warpdrive/textures/blocks/gasBlockYellow.png b/src/assets/warpdrive/textures/blocks/gasBlockYellow.png new file mode 100644 index 00000000..dfe886e6 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/gasBlockYellow.png differ diff --git a/src/assets/warpdrive/textures/blocks/iridiumSide.png b/src/assets/warpdrive/textures/blocks/iridiumSide.png new file mode 100644 index 00000000..4bb39440 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/iridiumSide.png differ diff --git a/src/assets/warpdrive/textures/blocks/laserSide.png b/src/assets/warpdrive/textures/blocks/laserSide.png new file mode 100644 index 00000000..9f505881 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/laserSide.png differ diff --git a/src/assets/warpdrive/textures/blocks/laserSideCam.png b/src/assets/warpdrive/textures/blocks/laserSideCam.png new file mode 100644 index 00000000..8e8b1acc Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/laserSideCam.png differ diff --git a/src/assets/warpdrive/textures/blocks/lasercamOverlay.png b/src/assets/warpdrive/textures/blocks/lasercamOverlay.png new file mode 100644 index 00000000..c0de1806 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/lasercamOverlay.png differ diff --git a/src/assets/warpdrive/textures/blocks/liftOutIn.png b/src/assets/warpdrive/textures/blocks/liftOutIn.png new file mode 100644 index 00000000..50079604 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/liftOutIn.png differ diff --git a/src/assets/warpdrive/textures/blocks/liftSideDown.png b/src/assets/warpdrive/textures/blocks/liftSideDown.png new file mode 100644 index 00000000..5f6b3eff Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/liftSideDown.png differ diff --git a/src/assets/warpdrive/textures/blocks/liftSideOffline.png b/src/assets/warpdrive/textures/blocks/liftSideOffline.png new file mode 100644 index 00000000..f05d96d3 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/liftSideOffline.png differ diff --git a/src/assets/warpdrive/textures/blocks/liftSideUp.png b/src/assets/warpdrive/textures/blocks/liftSideUp.png new file mode 100644 index 00000000..57076224 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/liftSideUp.png differ diff --git a/src/assets/warpdrive/textures/blocks/liftUpDown.png.mcmeta b/src/assets/warpdrive/textures/blocks/liftUpDown.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/liftUpDown.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/liftUpIn.png b/src/assets/warpdrive/textures/blocks/liftUpIn.png new file mode 100644 index 00000000..50079604 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/liftUpIn.png differ diff --git a/src/assets/warpdrive/textures/blocks/liftUpIn.png.mcmeta b/src/assets/warpdrive/textures/blocks/liftUpIn.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/liftUpIn.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/liftUpInactive.png b/src/assets/warpdrive/textures/blocks/liftUpInactive.png new file mode 100644 index 00000000..3a14f952 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/liftUpInactive.png differ diff --git a/src/assets/warpdrive/textures/blocks/liftUpOut.png b/src/assets/warpdrive/textures/blocks/liftUpOut.png new file mode 100644 index 00000000..cd54032a Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/liftUpOut.png differ diff --git a/src/assets/warpdrive/textures/blocks/liftUpOut.png.mcmeta b/src/assets/warpdrive/textures/blocks/liftUpOut.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/liftUpOut.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/miningLaserSide0.png b/src/assets/warpdrive/textures/blocks/miningLaserSide0.png new file mode 100644 index 00000000..fad0939f Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/miningLaserSide0.png differ diff --git a/src/assets/warpdrive/textures/blocks/monitorFront.png b/src/assets/warpdrive/textures/blocks/monitorFront.png new file mode 100644 index 00000000..34244816 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/monitorFront.png differ diff --git a/src/assets/warpdrive/textures/blocks/monitorSide.png b/src/assets/warpdrive/textures/blocks/monitorSide.png new file mode 100644 index 00000000..381f1e6d Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/monitorSide.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide0.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide0.png new file mode 100644 index 00000000..9b717a85 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide0.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide0.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide0.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide0.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide1.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide1.png new file mode 100644 index 00000000..1e8ec965 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide1.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide1.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide1.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide1.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide10.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide10.png new file mode 100644 index 00000000..7d8b2e17 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide10.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide10.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide10.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide10.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide2.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide2.png new file mode 100644 index 00000000..e8f2723c Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide2.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide2.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide2.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide2.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide3.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide3.png new file mode 100644 index 00000000..0dd5644c Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide3.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide3.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide3.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide3.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide4.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide4.png new file mode 100644 index 00000000..df51cce7 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide4.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide4.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide4.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide4.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide5.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide5.png new file mode 100644 index 00000000..19b11ea8 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide5.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide5.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide5.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide5.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide6.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide6.png new file mode 100644 index 00000000..0d26d8ae Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide6.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide6.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide6.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide6.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide7.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide7.png new file mode 100644 index 00000000..9d81804c Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide7.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide7.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide7.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide7.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide8.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide8.png new file mode 100644 index 00000000..d20d3834 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide8.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide8.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide8.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide8.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide9.png b/src/assets/warpdrive/textures/blocks/particleBoosterSide9.png new file mode 100644 index 00000000..99eb37ec Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterSide9.png differ diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterSide9.png.mcmeta b/src/assets/warpdrive/textures/blocks/particleBoosterSide9.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/particleBoosterSide9.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/particleBoosterTopBottom.png b/src/assets/warpdrive/textures/blocks/particleBoosterTopBottom.png new file mode 100644 index 00000000..12045750 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/particleBoosterTopBottom.png differ diff --git a/src/assets/warpdrive/textures/blocks/radarSideActive.png b/src/assets/warpdrive/textures/blocks/radarSideActive.png new file mode 100644 index 00000000..0c063dbf Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/radarSideActive.png differ diff --git a/src/assets/warpdrive/textures/blocks/radarSideActive.png.mcmeta b/src/assets/warpdrive/textures/blocks/radarSideActive.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/radarSideActive.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/radarSideActiveScan.png b/src/assets/warpdrive/textures/blocks/radarSideActiveScan.png new file mode 100644 index 00000000..7a59b3bd Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/radarSideActiveScan.png differ diff --git a/src/assets/warpdrive/textures/blocks/radarSideActiveScan.png.mcmeta b/src/assets/warpdrive/textures/blocks/radarSideActiveScan.png.mcmeta new file mode 100644 index 00000000..37d84f6a --- /dev/null +++ b/src/assets/warpdrive/textures/blocks/radarSideActiveScan.png.mcmeta @@ -0,0 +1,4 @@ +{ + "animation": { + } +} \ No newline at end of file diff --git a/src/assets/warpdrive/textures/blocks/radarSideInactive.png b/src/assets/warpdrive/textures/blocks/radarSideInactive.png new file mode 100644 index 00000000..73795af1 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/radarSideInactive.png differ diff --git a/src/assets/warpdrive/textures/blocks/shipScannerSide.png b/src/assets/warpdrive/textures/blocks/shipScannerSide.png new file mode 100644 index 00000000..f4a65ce9 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/shipScannerSide.png differ diff --git a/src/assets/warpdrive/textures/blocks/shipScannerUp.png b/src/assets/warpdrive/textures/blocks/shipScannerUp.png new file mode 100644 index 00000000..0bc463ac Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/shipScannerUp.png differ diff --git a/src/assets/warpdrive/textures/blocks/warpIsolation.png b/src/assets/warpdrive/textures/blocks/warpIsolation.png new file mode 100644 index 00000000..b4d7583e Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/warpIsolation.png differ diff --git a/src/assets/warpdrive/textures/blocks/warpcont_side_active_7.png b/src/assets/warpdrive/textures/blocks/warpcont_side_active_7.png new file mode 100644 index 00000000..eff142f8 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/warpcont_side_active_7.png differ diff --git a/src/assets/warpdrive/textures/blocks/warpcont_side_active_unwrapped.png b/src/assets/warpdrive/textures/blocks/warpcont_side_active_unwrapped.png new file mode 100644 index 00000000..6895ffc4 Binary files /dev/null and b/src/assets/warpdrive/textures/blocks/warpcont_side_active_unwrapped.png differ diff --git a/src/cr0s/WarpDrive/BlockAir.java b/src/cr0s/WarpDrive/BlockAir.java index a99e2157..1de83d80 100644 --- a/src/cr0s/WarpDrive/BlockAir.java +++ b/src/cr0s/WarpDrive/BlockAir.java @@ -10,280 +10,279 @@ import net.minecraft.world.World; public class BlockAir extends Block { - private final boolean TRANSPARENT_AIR = true; + private final boolean TRANSPARENT_AIR = true; - public BlockAir(int par1) - { - super(par1, Material.air); - } + public BlockAir(int par1) + { + super(par1, Material.air); + } - @Override - public boolean isOpaqueCube() - { - return false; - } + @Override + public boolean isOpaqueCube() + { + return false; + } - @Override - public boolean isAirBlock(World var1, int var2, int var3, int var4) - { - return true; - } + @Override + public boolean isAirBlock(World var1, int var2, int var3, int var4) + { + return true; + } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World var1, int var2, int var3, int var4) - { - return null; - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World var1, int var2, int var3, int var4) + { + return null; + } - @Override - public boolean isBlockReplaceable(World var1, int var2, int var3, int var4) - { - return true; - } + @Override + public boolean isBlockReplaceable(World var1, int var2, int var3, int var4) + { + return true; + } - @Override - public boolean canPlaceBlockAt(World var1, int var2, int var3, int var4) - { - return true; - } + @Override + public boolean canPlaceBlockAt(World var1, int var2, int var3, int var4) + { + return true; + } - @Override - public boolean canCollideCheck(int var1, boolean var2) - { - return false; - } + @Override + public boolean canCollideCheck(int var1, boolean var2) + { + return false; + } - @Override - public int getRenderBlockPass() - { - return TRANSPARENT_AIR ? 1 : 0; - } + @Override + public int getRenderBlockPass() + { + return TRANSPARENT_AIR ? 1 : 0; + } - @Override - public void registerIcons(IconRegister par1IconRegister) - { - this.blockIcon = par1IconRegister.registerIcon("warpdrive:airBlock"); - } + @Override + public void registerIcons(IconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon("warpdrive:airBlock"); + } - @Override - public int getMobilityFlag() - { - return 1; - } + @Override + public int getMobilityFlag() + { + return 1; + } - @Override - public int idDropped(int var1, Random var2, int var3) - { - return -1; - } + @Override + public int idDropped(int var1, Random var2, int var3) + { + return -1; + } - /** - * Returns the quantity of items to drop on block destruction. - */ - @Override - public int quantityDropped(Random par1Random) - { - return 0; - } + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random par1Random) + { + return 0; + } - /** - * How many world ticks before ticking - */ - @Override - public int tickRate(World par1World) - { - return 20; - } + /** + * How many world ticks before ticking + */ + @Override + public int tickRate(World par1World) + { + return 20; + } - /** - * Ticks the block if it's been scheduled - */ - @Override - public void updateTick(World par1World, int x, int y, int z, Random par5Random) - { - int concentration = par1World.getBlockMetadata(x, y, z); - boolean isInSpaceWorld = par1World.provider.dimensionId == WarpDrive.instance.spaceDimID || par1World.provider.dimensionId == WarpDrive.instance.hyperSpaceDimID; + /** + * Ticks the block if it's been scheduled + */ + @Override + public void updateTick(World par1World, int x, int y, int z, Random par5Random) + { + int concentration = par1World.getBlockMetadata(x, y, z); + boolean isInSpaceWorld = par1World.provider.dimensionId == WarpDrive.instance.spaceDimID || par1World.provider.dimensionId == WarpDrive.instance.hyperSpaceDimID; - // Remove air block to vacuum block - if (concentration <= 0 || !isInSpaceWorld) - { - //System.out.println("Killing air block"); - par1World.setBlock(x, y, z, 0, 0, 2); // replace our air block to vacuum block - } - else - { - //System.out.println("Conc: current " + concentration + " new: " + (concentration - 1) + " to spread: " + (concentration - 2)); - // Try to spread the air - spreadAirBlock(par1World, x, y, z, concentration); - } + // Remove air block to vacuum block + if (concentration <= 0 || !isInSpaceWorld) + { + //System.out.println("Killing air block"); + par1World.setBlock(x, y, z, 0, 0, 2); // replace our air block to vacuum block + } + else + { + //System.out.println("Conc: current " + concentration + " new: " + (concentration - 1) + " to spread: " + (concentration - 2)); + // Try to spread the air + spreadAirBlock(par1World, x, y, z, concentration); + } - par1World.scheduleBlockUpdate(x, y, z, this.blockID, 20); - } + par1World.scheduleBlockUpdate(x, y, z, this.blockID, 20); + } - @Override - public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) - { - if (par1IBlockAccess.getBlockId(par2, par3, par4) == this.blockID) - { - return false; - } - else - { - final int i = par1IBlockAccess.getBlockId(par2, par3, par4); - boolean var6 = false; + @Override + public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + if (par1IBlockAccess.getBlockId(par2, par3, par4) == this.blockID) + { + return false; + } + else + { + final int i = par1IBlockAccess.getBlockId(par2, par3, par4); + boolean var6 = false; - if (Block.blocksList[i] != null) - { - var6 = !Block.blocksList[i].isOpaqueCube(); - } + if (Block.blocksList[i] != null) + { + var6 = !Block.blocksList[i].isOpaqueCube(); + } - final boolean var7 = i == 0; + final boolean var7 = i == 0; - if ((var6 || var7) && par5 == 3 && !var6) - { - return true; - } - else if ((var6 || var7) && par5 == 4 && !var6) - { - return true; - } - else if ((var6 || var7) && par5 == 5 && !var6) - { - return true; - } - else if ((var6 || var7) && par5 == 2 && !var6) - { - return true; - } - else if ((var6 || var7) && par5 == 0 && !var6) - { - return true; - } - else if ((var6 || var7) && par5 == 1 && !var6) - { - return true; - } - else - { - return false; - } - } - } + if ((var6 || var7) && par5 == 3 && !var6) + { + return true; + } + else if ((var6 || var7) && par5 == 4 && !var6) + { + return true; + } + else if ((var6 || var7) && par5 == 5 && !var6) + { + return true; + } + else if ((var6 || var7) && par5 == 2 && !var6) + { + return true; + } + else if ((var6 || var7) && par5 == 0 && !var6) + { + return true; + } + else if ((var6 || var7) && par5 == 1 && !var6) + { + return true; + } + else + { + return false; + } + } + } - private void spreadAirBlock(World worldObj, int x, int y, int z, int concentration) - { - if (concentration <= 0) - { - return; - } + private void spreadAirBlock(World worldObj, int x, int y, int z, int concentration) + { + if (concentration <= 0) + { + return; + } - int mid_concentration; - int block_count = 1; - //final int K = 128; - mid_concentration = worldObj.getBlockMetadata(x, y, z);// * K; + int mid_concentration; + int block_count = 1; + mid_concentration = worldObj.getBlockMetadata(x, y, z); - // Count air in adjacent blocks - if (worldObj.isAirBlock(x + 1, y, z)) - { - block_count++; - mid_concentration += worldObj.getBlockMetadata(x + 1, y, z);// * K; - } + // Count air in adjacent blocks + if (worldObj.isAirBlock(x + 1, y, z)) + { + block_count++; + mid_concentration += worldObj.getBlockMetadata(x + 1, y, z); + } - if (worldObj.isAirBlock(x - 1, y, z)) - { - block_count++; - mid_concentration += worldObj.getBlockMetadata(x - 1, y, z);// * K; - } + if (worldObj.isAirBlock(x - 1, y, z)) + { + block_count++; + mid_concentration += worldObj.getBlockMetadata(x - 1, y, z); + } - if (worldObj.isAirBlock(x, y + 1, z)) - { - block_count++; - mid_concentration += worldObj.getBlockMetadata(x, y + 1, z);// * K; - } + if (worldObj.isAirBlock(x, y + 1, z)) + { + block_count++; + mid_concentration += worldObj.getBlockMetadata(x, y + 1, z); + } - if (worldObj.isAirBlock(x, y - 1, z)) - { - block_count++; - mid_concentration += worldObj.getBlockMetadata(x, y - 1, z);// * K; - } + if (worldObj.isAirBlock(x, y - 1, z)) + { + block_count++; + mid_concentration += worldObj.getBlockMetadata(x, y - 1, z); + } - if (worldObj.isAirBlock(x, y, z + 1)) - { - block_count++; - mid_concentration += worldObj.getBlockMetadata(x, y, z + 1);// * K; - } + if (worldObj.isAirBlock(x, y, z + 1)) + { + block_count++; + mid_concentration += worldObj.getBlockMetadata(x, y, z + 1); + } - if (worldObj.isAirBlock(x, y, z - 1)) - { - block_count++; - mid_concentration += worldObj.getBlockMetadata(x, y, z - 1);// * K; - } + if (worldObj.isAirBlock(x, y, z - 1)) + { + block_count++; + mid_concentration += worldObj.getBlockMetadata(x, y, z - 1); + } - mid_concentration = (int) Math.floor(mid_concentration * 1.0f / block_count); - setNewAirBlockWithConcentration(worldObj, x, y, z, mid_concentration);// / K); + mid_concentration = (int)Math.floor(mid_concentration / block_count); + setNewAirBlockWithConcentration(worldObj, x, y, z, mid_concentration); - // Check and setup air to adjacent blocks - if (worldObj.isAirBlock(x + 1, y, z) && (mid_concentration > worldObj.getBlockMetadata(x + 1, y, z)))// * K)) - { - setNewAirBlockWithConcentration(worldObj, x + 1, y, z, mid_concentration);// / K); - } + // Check and setup air to adjacent blocks + if (worldObj.isAirBlock(x + 1, y, z) && (mid_concentration > worldObj.getBlockMetadata(x + 1, y, z))) + { + setNewAirBlockWithConcentration(worldObj, x + 1, y, z, mid_concentration); + } - if (worldObj.isAirBlock(x - 1, y, z) && (mid_concentration > worldObj.getBlockMetadata(x - 1, y, z)))// * K)) - { - setNewAirBlockWithConcentration(worldObj, x - 1, y, z, mid_concentration);// / K); - } + if (worldObj.isAirBlock(x - 1, y, z) && (mid_concentration > worldObj.getBlockMetadata(x - 1, y, z))) + { + setNewAirBlockWithConcentration(worldObj, x - 1, y, z, mid_concentration); + } - if (worldObj.isAirBlock(x, y + 1, z) && (mid_concentration > worldObj.getBlockMetadata(x, y + 1, z)))// * K)) - { - setNewAirBlockWithConcentration(worldObj, x, y + 1, z, mid_concentration);// / K); - } + if (worldObj.isAirBlock(x, y + 1, z) && (mid_concentration > worldObj.getBlockMetadata(x, y + 1, z))) + { + setNewAirBlockWithConcentration(worldObj, x, y + 1, z, mid_concentration); + } - if (worldObj.isAirBlock(x, y - 1, z) && (mid_concentration > worldObj.getBlockMetadata(x, y - 1, z)))// * K)) - { - setNewAirBlockWithConcentration(worldObj, x, y - 1, z, mid_concentration);// / K); - } + if (worldObj.isAirBlock(x, y - 1, z) && (mid_concentration > worldObj.getBlockMetadata(x, y - 1, z))) + { + setNewAirBlockWithConcentration(worldObj, x, y - 1, z, mid_concentration); + } - if (worldObj.isAirBlock(x, y, z + 1) && (mid_concentration > worldObj.getBlockMetadata(x, y, z + 1)))// * K)) - { - setNewAirBlockWithConcentration(worldObj, x, y, z + 1, mid_concentration);// / K); - } + if (worldObj.isAirBlock(x, y, z + 1) && (mid_concentration > worldObj.getBlockMetadata(x, y, z + 1))) + { + setNewAirBlockWithConcentration(worldObj, x, y, z + 1, mid_concentration); + } - if (worldObj.isAirBlock(x, y, z - 1) && (mid_concentration > worldObj.getBlockMetadata(x, y, z - 1)))// * K)) - { - setNewAirBlockWithConcentration(worldObj, x, y, z - 1, mid_concentration);// / K); - } - } + if (worldObj.isAirBlock(x, y, z - 1) && (mid_concentration > worldObj.getBlockMetadata(x, y, z - 1))) + { + setNewAirBlockWithConcentration(worldObj, x, y, z - 1, mid_concentration); + } + } - private void setNewAirBlockWithConcentration(World worldObj, int x, int y, int z, int concentration) - { - worldObj.setBlock(x, y, z, this.blockID, concentration, 2); - } + private void setNewAirBlockWithConcentration(World worldObj, int x, int y, int z, int concentration) + { + worldObj.setBlock(x, y, z, this.blockID, concentration, 2); + } - @Override - public boolean func_82506_l() - { - return false; - } + @Override + public boolean func_82506_l() + { + return false; + } - /** - * Returns if this block is collidable. Args: x, y, z - */ - @Override - public boolean isCollidable() - { - return false; - } + /** + * Returns if this block is collidable. Args: x, y, z + */ + @Override + public boolean isCollidable() + { + return false; + } - @Override - public void onBlockAdded(World par1World, int par2, int par3, int par4) - { - if (par1World.provider.dimensionId == WarpDrive.instance.spaceDimID || par1World.provider.dimensionId == WarpDrive.instance.hyperSpaceDimID) - { - par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World)); - } - else - { - par1World.setBlockToAir(par2, par3, par4); - } - } + @Override + public void onBlockAdded(World par1World, int par2, int par3, int par4) + { + if (par1World.provider.dimensionId == WarpDrive.instance.spaceDimID || par1World.provider.dimensionId == WarpDrive.instance.hyperSpaceDimID) + { + par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World)); + } + else + { + par1World.setBlockToAir(par2, par3, par4); + } + } } \ No newline at end of file diff --git a/src/cr0s/WarpDrive/BlockCloakingCoil.java b/src/cr0s/WarpDrive/BlockCloakingCoil.java index 5991a9fa..db908dea 100644 --- a/src/cr0s/WarpDrive/BlockCloakingCoil.java +++ b/src/cr0s/WarpDrive/BlockCloakingCoil.java @@ -17,56 +17,56 @@ import net.minecraft.world.World; public class BlockCloakingCoil extends Block { - private Icon[] iconBuffer; + private Icon[] iconBuffer; - public BlockCloakingCoil(int id, int texture, Material material) - { - super(id, material); - } + public BlockCloakingCoil(int id, int texture, Material material) + { + super(id, material); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - iconBuffer = new Icon[2]; - iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:cloakCoilSide"); - iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:cloakCoilSideActive"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister par1IconRegister) + { + iconBuffer = new Icon[2]; + iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:cloakCoilSide"); + iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:cloakCoilSideActive"); + } - @Override - public Icon getIcon(int side, int metadata) - { - return iconBuffer[metadata]; - } + @Override + public Icon getIcon(int side, int metadata) + { + return iconBuffer[metadata]; + } - /** - * Returns the quantity of items to drop on block destruction. - */ - @Override - public int quantityDropped(Random par1Random) - { - return 1; - } + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random par1Random) + { + return 1; + } - /** - * Returns the ID of the items to drop on destruction. - */ - @Override - public int idDropped(int par1, Random par2Random, int par3) - { - return this.blockID; - } + /** + * Returns the ID of the items to drop on destruction. + */ + @Override + public int idDropped(int par1, Random par2Random, int par3) + { + return this.blockID; + } - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) - { - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) + { + TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - if (te != null) - { - te.invalidate(); - } + if (te != null) + { + te.invalidate(); + } - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } } diff --git a/src/cr0s/WarpDrive/BlockCloakingDeviceCore.java b/src/cr0s/WarpDrive/BlockCloakingDeviceCore.java index 1160518d..f94f4d41 100644 --- a/src/cr0s/WarpDrive/BlockCloakingDeviceCore.java +++ b/src/cr0s/WarpDrive/BlockCloakingDeviceCore.java @@ -16,83 +16,83 @@ import net.minecraft.world.World; public class BlockCloakingDeviceCore extends BlockContainer { - private Icon[] iconBuffer; + private Icon[] iconBuffer; - public BlockCloakingDeviceCore(int id, int texture, Material material) - { - super(id, material); - } + public BlockCloakingDeviceCore(int id, int texture, Material material) + { + super(id, material); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - iconBuffer = new Icon[2]; - iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:cloakingCoreInactive"); - iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:cloakingCoreActive"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister par1IconRegister) + { + iconBuffer = new Icon[2]; + iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:cloakingCoreInactive"); + iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:cloakingCoreActive"); + } - @Override - public Icon getIcon(int side, int metadata) - { - return iconBuffer[metadata]; - } + @Override + public Icon getIcon(int side, int metadata) + { + return iconBuffer[metadata]; + } - @Override - public TileEntity createNewTileEntity(World var1) - { - return new TileEntityCloakingDeviceCore(); - } + @Override + public TileEntity createNewTileEntity(World var1) + { + return new TileEntityCloakingDeviceCore(); + } - /** - * Returns the quantity of items to drop on block destruction. - */ - @Override - public int quantityDropped(Random par1Random) - { - return 1; - } + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random par1Random) + { + return 1; + } - /** - * Returns the ID of the items to drop on destruction. - */ - @Override - public int idDropped(int par1, Random par2Random, int par3) - { - return this.blockID; - } + /** + * Returns the ID of the items to drop on destruction. + */ + @Override + public int idDropped(int par1, Random par2Random, int par3) + { + return this.blockID; + } - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) - { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return false; - } + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) + { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) + { + return false; + } - TileEntityCloakingDeviceCore me = (TileEntityCloakingDeviceCore)par1World.getBlockTileEntity(par2, par3, par4); + TileEntityCloakingDeviceCore me = (TileEntityCloakingDeviceCore)par1World.getBlockTileEntity(par2, par3, par4); - if (me != null) - { - par5EntityPlayer.addChatMessage("[CloakDeviceCore] Energy level: " + me.getCurrentEnergyValue() + " Eu"); - } + if (me != null) + { + par5EntityPlayer.addChatMessage("[CloakDeviceCore] Energy level: " + me.getCurrentEnergyValue() + " Eu"); + } - return true; - } + return true; + } - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) - { - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) + { + TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - if (te != null) - { - if (((TileEntityCloakingDeviceCore)te).isEnabled) - ((TileEntityCloakingDeviceCore)te).disableCloakingField(); - - te.invalidate(); - } + if (te != null) + { + if (((TileEntityCloakingDeviceCore)te).isEnabled) + ((TileEntityCloakingDeviceCore)te).disableCloakingField(); + + te.invalidate(); + } - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } } diff --git a/src/cr0s/WarpDrive/BlockProtocol.java b/src/cr0s/WarpDrive/BlockProtocol.java index 84cda5d7..e51563f6 100644 --- a/src/cr0s/WarpDrive/BlockProtocol.java +++ b/src/cr0s/WarpDrive/BlockProtocol.java @@ -14,101 +14,104 @@ import net.minecraft.world.World; public class BlockProtocol extends BlockContainer { - private Icon[] iconBuffer; + private Icon[] iconBuffer; - private final int ICON_INACTIVE_SIDE = 0, ICON_BOTTOM = 1, ICON_TOP = 2, ICON_SIDE_ACTIVATED = 3; - //private final int ANIMATION_ - //private int currentTexture; + private final int ICON_INACTIVE_SIDE = 0, ICON_BOTTOM = 1, ICON_TOP = 2, ICON_SIDE_ACTIVATED = 3; + //private final int ANIMATION_ + //private int currentTexture; - public BlockProtocol(int id, int texture, Material material) - { - super(id, material); - } + public BlockProtocol(int id, int texture, Material material) + { + super(id, material); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - iconBuffer = new Icon[9]; - // Solid textures - iconBuffer[ICON_INACTIVE_SIDE] = par1IconRegister.registerIcon("warpdrive:contSideInactive"); - iconBuffer[ICON_BOTTOM] = par1IconRegister.registerIcon("warpdrive:contBottom"); - iconBuffer[ICON_TOP] = par1IconRegister.registerIcon("warpdrive:contTop"); - // Animated textures - iconBuffer[ICON_SIDE_ACTIVATED] = par1IconRegister.registerIcon("warpdrive:contSideActive1"); - iconBuffer[ICON_SIDE_ACTIVATED + 1] = par1IconRegister.registerIcon("warpdrive:contSideActive2"); - iconBuffer[ICON_SIDE_ACTIVATED + 2] = par1IconRegister.registerIcon("warpdrive:contSideActive3"); - iconBuffer[ICON_SIDE_ACTIVATED + 3] = par1IconRegister.registerIcon("warpdrive:contSideActive4"); - iconBuffer[ICON_SIDE_ACTIVATED + 4] = par1IconRegister.registerIcon("warpdrive:contSideActive5"); - iconBuffer[ICON_SIDE_ACTIVATED + 5] = par1IconRegister.registerIcon("warpdrive:contSideActive6"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister par1IconRegister) + { + iconBuffer = new Icon[9]; + // Solid textures + iconBuffer[ICON_INACTIVE_SIDE] = par1IconRegister.registerIcon("warpdrive:contSideInactive"); + iconBuffer[ICON_BOTTOM] = par1IconRegister.registerIcon("warpdrive:contBottom"); + iconBuffer[ICON_TOP] = par1IconRegister.registerIcon("warpdrive:contTop"); + // Animated textures + iconBuffer[ICON_SIDE_ACTIVATED] = par1IconRegister.registerIcon("warpdrive:contSideActive1"); + iconBuffer[ICON_SIDE_ACTIVATED + 1] = par1IconRegister.registerIcon("warpdrive:contSideActive2"); + iconBuffer[ICON_SIDE_ACTIVATED + 2] = par1IconRegister.registerIcon("warpdrive:contSideActive3"); + iconBuffer[ICON_SIDE_ACTIVATED + 3] = par1IconRegister.registerIcon("warpdrive:contSideActive4"); + iconBuffer[ICON_SIDE_ACTIVATED + 4] = par1IconRegister.registerIcon("warpdrive:contSideActive5"); + iconBuffer[ICON_SIDE_ACTIVATED + 5] = par1IconRegister.registerIcon("warpdrive:contSideActive6"); + } - @Override - public Icon getIcon(int side, int metadata) - { - if (side == 0) - { - return iconBuffer[ICON_BOTTOM]; - } - else if (side == 1) - { - return iconBuffer[ICON_TOP]; - } + @Override + public Icon getIcon(int side, int metadata) + { + if (side == 0) + { + return iconBuffer[ICON_BOTTOM]; + } + else if (side == 1) + { + return iconBuffer[ICON_TOP]; + } - if (metadata == 0) // Inactive state - { - return iconBuffer[ICON_INACTIVE_SIDE]; - } - else if (metadata > 0) // Activated, in metadata stored mode number - { - return iconBuffer[ICON_SIDE_ACTIVATED + metadata - 1]; - } + if (metadata == 0) // Inactive state + { + return iconBuffer[ICON_INACTIVE_SIDE]; + } + else if (metadata > 0) // Activated, in metadata stored mode number + { + if (ICON_SIDE_ACTIVATED + metadata - 1 < iconBuffer.length) + return iconBuffer[ICON_SIDE_ACTIVATED + metadata - 1]; + else + return iconBuffer[ICON_SIDE_ACTIVATED]; + } + else + return iconBuffer[ICON_SIDE_ACTIVATED]; + } - return null; - } + @Override + public TileEntity createNewTileEntity(World var1) + { + return new TileEntityProtocol(); + } - @Override - public TileEntity createNewTileEntity(World var1) - { - return new TileEntityProtocol(); - } + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random par1Random) + { + return 1; + } - /** - * Returns the quantity of items to drop on block destruction. - */ - @Override - public int quantityDropped(Random par1Random) - { - return 1; - } + /** + * Returns the ID of the items to drop on destruction. + */ + @Override + public int idDropped(int par1, Random par2Random, int par3) + { + return this.blockID; + } + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) + { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) + { + return false; + } - /** - * Returns the ID of the items to drop on destruction. - */ - @Override - public int idDropped(int par1, Random par2Random, int par3) - { - return this.blockID; - } - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) - { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return false; - } + TileEntityProtocol controller = (TileEntityProtocol)par1World.getBlockTileEntity(par2, par3, par4); - TileEntityProtocol controller = (TileEntityProtocol)par1World.getBlockTileEntity(par2, par3, par4); + if (controller != null) + { + controller.attachPlayer(par5EntityPlayer); + par5EntityPlayer.addChatMessage("[WarpCtrlr] Attached players: " + controller.getAttachedPlayersList()); + } - if (controller != null) - { - controller.attachPlayer(par5EntityPlayer); - par5EntityPlayer.addChatMessage("[WarpCtrlr] Attached players: " + controller.getAttachedPlayersList()); - } - - return true; - } + return true; + } } \ No newline at end of file diff --git a/src/cr0s/WarpDrive/BlockReactor.java b/src/cr0s/WarpDrive/BlockReactor.java index e19ad4cc..83b7c4c5 100644 --- a/src/cr0s/WarpDrive/BlockReactor.java +++ b/src/cr0s/WarpDrive/BlockReactor.java @@ -27,7 +27,7 @@ public class BlockReactor extends BlockContainer @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { - iconBuffer = new Icon[5]; + iconBuffer = new Icon[4]; iconBuffer[ICON_INACTIVE_SIDE] = par1IconRegister.registerIcon("warpdrive:coreSideInactive"); iconBuffer[ICON_BOTTOM] = par1IconRegister.registerIcon("warpdrive:coreBottom"); iconBuffer[ICON_TOP] = par1IconRegister.registerIcon("warpdrive:coreTop"); diff --git a/src/cr0s/WarpDrive/BlockShipScanner.java b/src/cr0s/WarpDrive/BlockShipScanner.java index 26631027..7e69bb34 100644 --- a/src/cr0s/WarpDrive/BlockShipScanner.java +++ b/src/cr0s/WarpDrive/BlockShipScanner.java @@ -16,91 +16,91 @@ import net.minecraft.world.World; public class BlockShipScanner extends BlockContainer { - private Icon[] iconBuffer; + private Icon[] iconBuffer; - public BlockShipScanner(int id, int texture, Material material) - { - super(id, material); - } + public BlockShipScanner(int id, int texture, Material material) + { + super(id, material); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - iconBuffer = new Icon[3]; - iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:shipScannerUp"); - iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:shipScannerSide"); - iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:contBottom"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister par1IconRegister) + { + iconBuffer = new Icon[3]; + iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:shipScannerUp"); + iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:shipScannerSide"); + iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:contBottom"); + } - @Override - public Icon getIcon(int side, int metadata) - { - if (side == 1) // UP - { - return iconBuffer[0]; - } - else if (side == 0) // DOWN - { - return iconBuffer[2]; - } + @Override + public Icon getIcon(int side, int metadata) + { + if (side == 1) // UP + { + return iconBuffer[0]; + } + else if (side == 0) // DOWN + { + return iconBuffer[2]; + } - return iconBuffer[1]; - } + return iconBuffer[1]; + } - @Override - public TileEntity createNewTileEntity(World var1) - { - return new TileEntityShipScanner(); - } + @Override + public TileEntity createNewTileEntity(World var1) + { + return new TileEntityShipScanner(); + } - /** - * Returns the quantity of items to drop on block destruction. - */ - @Override - public int quantityDropped(Random par1Random) - { - return 1; - } + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random par1Random) + { + return 1; + } - /** - * Returns the ID of the items to drop on destruction. - */ - @Override - public int idDropped(int par1, Random par2Random, int par3) - { - return this.blockID; - } + /** + * Returns the ID of the items to drop on destruction. + */ + @Override + public int idDropped(int par1, Random par2Random, int par3) + { + return this.blockID; + } - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) - { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return false; - } + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) + { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) + { + return false; + } - TileEntityShipScanner me = (TileEntityShipScanner)par1World.getBlockTileEntity(par2, par3, par4); + TileEntityShipScanner me = (TileEntityShipScanner)par1World.getBlockTileEntity(par2, par3, par4); - if (me != null) - { - par5EntityPlayer.addChatMessage("[Ship Scanner] Energy level: " + me.getCurrentEnergyValue()); - } + if (me != null) + { + par5EntityPlayer.addChatMessage("[Ship Scanner] Energy level: " + me.getCurrentEnergyValue()); + } - return true; - } + return true; + } - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) - { - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) + { + TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - if (te != null) - { - te.invalidate(); - } - } + if (te != null) + { + te.invalidate(); + } + } } \ No newline at end of file diff --git a/src/cr0s/WarpDrive/CloakChunkWatcher.java b/src/cr0s/WarpDrive/CloakChunkWatcher.java index 36f5386d..0c23f044 100644 --- a/src/cr0s/WarpDrive/CloakChunkWatcher.java +++ b/src/cr0s/WarpDrive/CloakChunkWatcher.java @@ -3,7 +3,6 @@ package cr0s.WarpDrive; import java.util.ArrayList; import java.util.List; -import cr0s.WarpDrive.CloakManager.CloakedArea; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.packet.Packet56MapChunks; import net.minecraft.world.ChunkCoordIntPair; @@ -11,29 +10,17 @@ import net.minecraft.world.chunk.Chunk; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.world.ChunkWatchEvent; -public class CloakChunkWatcher { +public class CloakChunkWatcher +{ @ForgeSubscribe public void chunkLoaded(ChunkWatchEvent event) { EntityPlayerMP p = event.player; ChunkCoordIntPair chunk = event.chunk; - - // Check chunk for locating in cloaked areas ArrayList<CloakedArea> cloaks = WarpDrive.instance.cloaks.getCloaksForPoint(p.worldObj.provider.dimensionId, chunk.getCenterXPos(), 0, chunk.getCenterZPosition(), true); if (cloaks.size() == 0) return; - - //Chunk c = p.worldObj.getChunkFromChunkCoords(chunk.chunkXPos, chunk.chunkZPos); - for (CloakedArea area : cloaks) { + for (CloakedArea area : cloaks) area.sendCloakPacketToPlayer(p, false); - } - - /*List<Chunk> list = new ArrayList<Chunk>(); - list.add(c); - - // Send obscured chunk - System.out.println("[Cloak] Sending to player " + p.username + " obscured chunk at (" + chunk.chunkXPos + "; " + chunk.chunkZPos + ")"); - ((EntityPlayerMP)p).playerNetServerHandler.sendPacketToPlayer(new Packet56MapChunks(list));*/ - } } diff --git a/src/cr0s/WarpDrive/CloakManager.java b/src/cr0s/WarpDrive/CloakManager.java index 79292baa..c06e4027 100644 --- a/src/cr0s/WarpDrive/CloakManager.java +++ b/src/cr0s/WarpDrive/CloakManager.java @@ -60,8 +60,8 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage; * */ -public class CloakManager { - +public class CloakManager +{ private ArrayList<CloakedArea> cloaks; public CloakManager() { @@ -186,345 +186,158 @@ public class CloakManager { */ } - public class CloakedArea { - public int frequency; - public AxisAlignedBB aabb; - public LinkedList<EntityPlayer> playersInArea; - public byte tier = 0; - public World world = null; - - public boolean isPlayerInArea(EntityPlayer player) { - for (EntityPlayer p : this.playersInArea) { - //System.outprintln("[Cloak] Checking player: " + p.username + "(" + p.entityId + ")" + " =? " + player.username + " (" + p.entityId + ")"); - if (p.username.equals(player.username)) - return true; - } - - return false; - } - - public void removePlayerFromArea(EntityPlayer p) { - for (int i = 0; i < this.playersInArea.size(); i++) { - if (this.playersInArea.get(i).username.equals(p.username)) { - this.playersInArea.remove(i); - return; - } - } - } - - public boolean isPlayerWithinArea(EntityPlayer player) { - return (aabb.minX <= player.posX && aabb.maxX >= player.posX && aabb.minY <= player.posY && aabb.maxY >= player.posY && aabb.minZ <= player.posZ && aabb.maxZ >= player.posZ); - } - - public CloakedArea(World worldObj, int frequency, AxisAlignedBB aabb, byte tier) { - this.frequency = frequency; - this.aabb = aabb; - this.tier = tier; - this.playersInArea = new LinkedList<EntityPlayer>(); - - if (worldObj == null || aabb == null) - return; - - this.world = worldObj; - - if (this.world == null) - return; - - try { - // Added all players, who inside the field - List<Entity> list = worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, this.aabb); - for (Entity e : list) { - if (e instanceof EntityPlayer) - this.playersInArea.add((EntityPlayer)e); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public Chunk obscureChunkBlocksWithinArea(Chunk chunk) { - for (int x = (int)this.aabb.minX; x < (int)this.aabb.maxX; x++) - for (int z = (int)this.aabb.minZ; z < (int)this.aabb.maxZ; z++) - for (int y = (int)this.aabb.minY; y < (int)this.aabb.maxY; y++) { - myChunkSBIDWMT(chunk, x & 15, y, z & 15, 0, 0); - } - - return chunk; - } - - // Sending only if field changes: sets up or collapsing - public void sendCloakPacketToPlayersEx(boolean decloak) { - final int RADIUS = 250; - - double midX = this.aabb.minX + (Math.abs(this.aabb.maxX - this.aabb.minX) / 2); - double midY = this.aabb.minY + (Math.abs(this.aabb.maxY - this.aabb.minY) / 2); - double midZ = this.aabb.minZ + (Math.abs(this.aabb.maxZ - this.aabb.minZ) / 2); - - for (int j = 0; j < MinecraftServer.getServer().getConfigurationManager().playerEntityList.size(); ++j) - { - EntityPlayerMP entityplayermp = (EntityPlayerMP)MinecraftServer.getServer().getConfigurationManager().playerEntityList.get(j); - - if (entityplayermp.dimension == this.world.provider.dimensionId) - { - double d4 = midX - entityplayermp.posX; - double d5 = midY - entityplayermp.posY; - double d6 = midZ - entityplayermp.posZ; - - if (d4 * d4 + d5 * d5 + d6 * d6 < RADIUS * RADIUS) - { - if (decloak) { - revealChunksToPlayer(this, (EntityPlayer)entityplayermp); - revealEntityToPlayer(this, (EntityPlayer)entityplayermp); - } - - if (!isPlayerWithinArea((EntityPlayer)entityplayermp) && !decloak) - sendCloakPacketToPlayer((EntityPlayer)entityplayermp, false); - else if (decloak) { - sendCloakPacketToPlayer((EntityPlayer)entityplayermp, true); - } - } - } - } - } - - public void sendCloakPacketToPlayer(EntityPlayer player, boolean decloak) { - //System.outprintln("[Cloak] Sending cloak packet to player " + player.username); - if (isPlayerInArea(player)) { - //System.outprintln("[Cloak] Player " + player.username + " is inside cloaking field"); - return; - } - - ByteArrayOutputStream bos = new ByteArrayOutputStream(8); - DataOutputStream outputStream = new DataOutputStream(bos); - - try - { - outputStream.writeInt((int) this.aabb.minX); - outputStream.writeInt((int) this.aabb.minY); - outputStream.writeInt((int) this.aabb.minZ); - - outputStream.writeInt((int) this.aabb.maxX); - outputStream.writeInt((int) this.aabb.maxY); - outputStream.writeInt((int) this.aabb.maxZ); - - outputStream.writeBoolean(decloak); - - outputStream.writeByte(this.tier); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - Packet250CustomPayload packet = new Packet250CustomPayload(); - packet.channel = "WarpDriveCloaks"; - packet.data = bos.toByteArray(); - packet.length = bos.size(); - - ((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet); - } - - public boolean myChunkSBIDWMT(Chunk c, int x, int y, int z, int blockId, int blockMeta) + private Packet getPacketForThisEntity(Entity e) + { + if (e.isDead) { - int j1 = z << 4 | x; + e.worldObj.getWorldLogAgent().logWarning("Fetching addPacket for removed entity"); + } - if (y >= c.precipitationHeightMap[j1] - 1) + Packet pkt = FMLNetworkHandler.getEntitySpawningPacket(e); + + if (pkt != null) + { + return pkt; + } + + if (e instanceof EntityItem) + { + return new Packet23VehicleSpawn(e, 2, 1); + } + else if (e instanceof EntityPlayerMP) + { + return new Packet20NamedEntitySpawn((EntityPlayer)e); + } + else if (e instanceof EntityMinecart) + { + EntityMinecart entityminecart = (EntityMinecart)e; + return new Packet23VehicleSpawn(e, 10, entityminecart.getMinecartType()); + } + else if (e instanceof EntityBoat) + { + return new Packet23VehicleSpawn(e, 1); + } + else if (!(e instanceof IAnimals) && !(e instanceof EntityDragon)) + { + if (e instanceof EntityFishHook) { - c.precipitationHeightMap[j1] = -999; + EntityPlayer entityplayer = ((EntityFishHook)e).angler; + return new Packet23VehicleSpawn(e, 90, entityplayer != null ? entityplayer.entityId : e.entityId); } - - int l1 = c.getBlockID(x, y, z); - int i2 = c.getBlockMetadata(x, y, z); - - if (l1 == blockId && i2 == blockMeta) + else if (e instanceof EntityArrow) { - return false; + Entity entity = ((EntityArrow)e).shootingEntity; + return new Packet23VehicleSpawn(e, 60, entity != null ? entity.entityId : e.entityId); + } + else if (e instanceof EntitySnowball) + { + return new Packet23VehicleSpawn(e, 61); + } + else if (e instanceof EntityPotion) + { + return new Packet23VehicleSpawn(e, 73, ((EntityPotion)e).getPotionDamage()); + } + else if (e instanceof EntityExpBottle) + { + return new Packet23VehicleSpawn(e, 75); + } + else if (e instanceof EntityEnderPearl) + { + return new Packet23VehicleSpawn(e, 65); + } + else if (e instanceof EntityEnderEye) + { + return new Packet23VehicleSpawn(e, 72); + } + else if (e instanceof EntityFireworkRocket) + { + return new Packet23VehicleSpawn(e, 76); } else { - ExtendedBlockStorage[] storageArrays = c.getBlockStorageArray(); - ExtendedBlockStorage extendedblockstorage = storageArrays[y >> 4]; + Packet23VehicleSpawn packet23vehiclespawn; - if (extendedblockstorage == null) + if (e instanceof EntityFireball) { - if (blockId == 0) + EntityFireball entityfireball = (EntityFireball)e; + packet23vehiclespawn = null; + byte b0 = 63; + + if (e instanceof EntitySmallFireball) { - return false; + b0 = 64; + } + else if (e instanceof EntityWitherSkull) + { + b0 = 66; } - extendedblockstorage = storageArrays[y >> 4] = new ExtendedBlockStorage(y >> 4 << 4, !c.worldObj.provider.hasNoSky); + if (entityfireball.shootingEntity != null) + { + packet23vehiclespawn = new Packet23VehicleSpawn(e, b0, ((EntityFireball)e).shootingEntity.entityId); + } + else + { + packet23vehiclespawn = new Packet23VehicleSpawn(e, b0, 0); + } + + packet23vehiclespawn.speedX = (int)(entityfireball.accelerationX * 8000.0D); + packet23vehiclespawn.speedY = (int)(entityfireball.accelerationY * 8000.0D); + packet23vehiclespawn.speedZ = (int)(entityfireball.accelerationZ * 8000.0D); + return packet23vehiclespawn; } - - int j2 = c.xPosition * 16 + x; - int k2 = c.zPosition * 16 + z; - extendedblockstorage.setExtBlockID(x, y & 15, z, blockId); - - if (extendedblockstorage.getExtBlockID(x, y & 15, z) != blockId) + else if (e instanceof EntityEgg) { - return false; + return new Packet23VehicleSpawn(e, 62); + } + else if (e instanceof EntityTNTPrimed) + { + return new Packet23VehicleSpawn(e, 50); + } + else if (e instanceof EntityEnderCrystal) + { + return new Packet23VehicleSpawn(e, 51); + } + else if (e instanceof EntityFallingSand) + { + EntityFallingSand entityfallingsand = (EntityFallingSand)e; + return new Packet23VehicleSpawn(e, 70, entityfallingsand.blockID | entityfallingsand.metadata << 16); + } + else if (e instanceof EntityPainting) + { + return new Packet25EntityPainting((EntityPainting)e); + } + else if (e instanceof EntityItemFrame) + { + EntityItemFrame entityitemframe = (EntityItemFrame)e; + packet23vehiclespawn = new Packet23VehicleSpawn(e, 71, entityitemframe.hangingDirection); + packet23vehiclespawn.xPosition = MathHelper.floor_float((float)(entityitemframe.xPosition * 32)); + packet23vehiclespawn.yPosition = MathHelper.floor_float((float)(entityitemframe.yPosition * 32)); + packet23vehiclespawn.zPosition = MathHelper.floor_float((float)(entityitemframe.zPosition * 32)); + return packet23vehiclespawn; + } + else if (e instanceof EntityLeashKnot) + { + EntityLeashKnot entityleashknot = (EntityLeashKnot)e; + packet23vehiclespawn = new Packet23VehicleSpawn(e, 77); + packet23vehiclespawn.xPosition = MathHelper.floor_float((float)(entityleashknot.xPosition * 32)); + packet23vehiclespawn.yPosition = MathHelper.floor_float((float)(entityleashknot.yPosition * 32)); + packet23vehiclespawn.zPosition = MathHelper.floor_float((float)(entityleashknot.zPosition * 32)); + return packet23vehiclespawn; + } + else if (e instanceof EntityXPOrb) + { + return new Packet26EntityExpOrb((EntityXPOrb)e); } else { - extendedblockstorage.setExtBlockMetadata(x, y & 15, z, blockMeta); - c.isModified = true; - return true; + throw new IllegalArgumentException("Don\'t know how to add " + e.getClass() + "!"); } } - } - } - - private Packet getPacketForThisEntity(Entity e) - { - if (e.isDead) - { - e.worldObj.getWorldLogAgent().logWarning("Fetching addPacket for removed entity"); - } - - Packet pkt = FMLNetworkHandler.getEntitySpawningPacket(e); - - if (pkt != null) - { - return pkt; - } - - if (e instanceof EntityItem) - { - return new Packet23VehicleSpawn(e, 2, 1); - } - else if (e instanceof EntityPlayerMP) - { - return new Packet20NamedEntitySpawn((EntityPlayer)e); - } - else if (e instanceof EntityMinecart) - { - EntityMinecart entityminecart = (EntityMinecart)e; - return new Packet23VehicleSpawn(e, 10, entityminecart.getMinecartType()); - } - else if (e instanceof EntityBoat) - { - return new Packet23VehicleSpawn(e, 1); - } - else if (!(e instanceof IAnimals) && !(e instanceof EntityDragon)) - { - if (e instanceof EntityFishHook) - { - EntityPlayer entityplayer = ((EntityFishHook)e).angler; - return new Packet23VehicleSpawn(e, 90, entityplayer != null ? entityplayer.entityId : e.entityId); - } - else if (e instanceof EntityArrow) - { - Entity entity = ((EntityArrow)e).shootingEntity; - return new Packet23VehicleSpawn(e, 60, entity != null ? entity.entityId : e.entityId); - } - else if (e instanceof EntitySnowball) - { - return new Packet23VehicleSpawn(e, 61); - } - else if (e instanceof EntityPotion) - { - return new Packet23VehicleSpawn(e, 73, ((EntityPotion)e).getPotionDamage()); - } - else if (e instanceof EntityExpBottle) - { - return new Packet23VehicleSpawn(e, 75); - } - else if (e instanceof EntityEnderPearl) - { - return new Packet23VehicleSpawn(e, 65); - } - else if (e instanceof EntityEnderEye) - { - return new Packet23VehicleSpawn(e, 72); - } - else if (e instanceof EntityFireworkRocket) - { - return new Packet23VehicleSpawn(e, 76); - } - else - { - Packet23VehicleSpawn packet23vehiclespawn; - - if (e instanceof EntityFireball) - { - EntityFireball entityfireball = (EntityFireball)e; - packet23vehiclespawn = null; - byte b0 = 63; - - if (e instanceof EntitySmallFireball) - { - b0 = 64; - } - else if (e instanceof EntityWitherSkull) - { - b0 = 66; - } - - if (entityfireball.shootingEntity != null) - { - packet23vehiclespawn = new Packet23VehicleSpawn(e, b0, ((EntityFireball)e).shootingEntity.entityId); - } - else - { - packet23vehiclespawn = new Packet23VehicleSpawn(e, b0, 0); - } - - packet23vehiclespawn.speedX = (int)(entityfireball.accelerationX * 8000.0D); - packet23vehiclespawn.speedY = (int)(entityfireball.accelerationY * 8000.0D); - packet23vehiclespawn.speedZ = (int)(entityfireball.accelerationZ * 8000.0D); - return packet23vehiclespawn; - } - else if (e instanceof EntityEgg) - { - return new Packet23VehicleSpawn(e, 62); - } - else if (e instanceof EntityTNTPrimed) - { - return new Packet23VehicleSpawn(e, 50); - } - else if (e instanceof EntityEnderCrystal) - { - return new Packet23VehicleSpawn(e, 51); - } - else if (e instanceof EntityFallingSand) - { - EntityFallingSand entityfallingsand = (EntityFallingSand)e; - return new Packet23VehicleSpawn(e, 70, entityfallingsand.blockID | entityfallingsand.metadata << 16); - } - else if (e instanceof EntityPainting) - { - return new Packet25EntityPainting((EntityPainting)e); - } - else if (e instanceof EntityItemFrame) - { - EntityItemFrame entityitemframe = (EntityItemFrame)e; - packet23vehiclespawn = new Packet23VehicleSpawn(e, 71, entityitemframe.hangingDirection); - packet23vehiclespawn.xPosition = MathHelper.floor_float((float)(entityitemframe.xPosition * 32)); - packet23vehiclespawn.yPosition = MathHelper.floor_float((float)(entityitemframe.yPosition * 32)); - packet23vehiclespawn.zPosition = MathHelper.floor_float((float)(entityitemframe.zPosition * 32)); - return packet23vehiclespawn; - } - else if (e instanceof EntityLeashKnot) - { - EntityLeashKnot entityleashknot = (EntityLeashKnot)e; - packet23vehiclespawn = new Packet23VehicleSpawn(e, 77); - packet23vehiclespawn.xPosition = MathHelper.floor_float((float)(entityleashknot.xPosition * 32)); - packet23vehiclespawn.yPosition = MathHelper.floor_float((float)(entityleashknot.yPosition * 32)); - packet23vehiclespawn.zPosition = MathHelper.floor_float((float)(entityleashknot.zPosition * 32)); - return packet23vehiclespawn; - } - else if (e instanceof EntityXPOrb) - { - return new Packet26EntityExpOrb((EntityXPOrb)e); - } - else - { - throw new IllegalArgumentException("Don\'t know how to add " + e.getClass() + "!"); - } - } - } - else - { - return new Packet24MobSpawn((EntityLivingBase)e); - } - } + } + else + { + return new Packet24MobSpawn((EntityLivingBase)e); + } + } } diff --git a/src/cr0s/WarpDrive/CloakedArea.java b/src/cr0s/WarpDrive/CloakedArea.java new file mode 100644 index 00000000..dbae7818 --- /dev/null +++ b/src/cr0s/WarpDrive/CloakedArea.java @@ -0,0 +1,206 @@ +package cr0s.WarpDrive; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.util.LinkedList; +import java.util.List; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.FMLNetworkHandler; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; + +public class CloakedArea +{ + public int frequency; + public AxisAlignedBB aabb; + public LinkedList<EntityPlayer> playersInArea; + public byte tier = 0; + public World world = null; + + public boolean isPlayerInArea(EntityPlayer player) { + for (EntityPlayer p : this.playersInArea) { + //System.outprintln("[Cloak] Checking player: " + p.username + "(" + p.entityId + ")" + " =? " + player.username + " (" + p.entityId + ")"); + if (p.username.equals(player.username)) + return true; + } + + return false; + } + + public void removePlayerFromArea(EntityPlayer p) { + for (int i = 0; i < this.playersInArea.size(); i++) { + if (this.playersInArea.get(i).username.equals(p.username)) { + this.playersInArea.remove(i); + return; + } + } + } + + public boolean isPlayerWithinArea(EntityPlayer player) { + return (aabb.minX <= player.posX && aabb.maxX >= player.posX && aabb.minY <= player.posY && aabb.maxY >= player.posY && aabb.minZ <= player.posZ && aabb.maxZ >= player.posZ); + } + + public CloakedArea(World worldObj, int frequency, AxisAlignedBB aabb, byte tier) { + this.frequency = frequency; + this.aabb = aabb; + this.tier = tier; + this.playersInArea = new LinkedList<EntityPlayer>(); + + if (worldObj == null || aabb == null) + return; + + this.world = worldObj; + + if (this.world == null) + return; + + try { + // Added all players, who inside the field + List<Entity> list = worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, this.aabb); + for (Entity e : list) { + if (e instanceof EntityPlayer) + this.playersInArea.add((EntityPlayer)e); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public Chunk obscureChunkBlocksWithinArea(Chunk chunk) { + for (int x = (int)this.aabb.minX; x < (int)this.aabb.maxX; x++) + for (int z = (int)this.aabb.minZ; z < (int)this.aabb.maxZ; z++) + for (int y = (int)this.aabb.minY; y < (int)this.aabb.maxY; y++) { + myChunkSBIDWMT(chunk, x & 15, y, z & 15, 0, 0); + } + + return chunk; + } + + // Sending only if field changes: sets up or collapsing + public void sendCloakPacketToPlayersEx(boolean decloak) { + final int RADIUS = 250; + + double midX = this.aabb.minX + (Math.abs(this.aabb.maxX - this.aabb.minX) / 2); + double midY = this.aabb.minY + (Math.abs(this.aabb.maxY - this.aabb.minY) / 2); + double midZ = this.aabb.minZ + (Math.abs(this.aabb.maxZ - this.aabb.minZ) / 2); + + for (int j = 0; j < MinecraftServer.getServer().getConfigurationManager().playerEntityList.size(); ++j) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)MinecraftServer.getServer().getConfigurationManager().playerEntityList.get(j); + + if (entityplayermp.dimension == this.world.provider.dimensionId) + { + double d4 = midX - entityplayermp.posX; + double d5 = midY - entityplayermp.posY; + double d6 = midZ - entityplayermp.posZ; + + if (d4 * d4 + d5 * d5 + d6 * d6 < RADIUS * RADIUS) + { + if (decloak) { + WarpDrive.instance.cloaks.revealChunksToPlayer(this, (EntityPlayer)entityplayermp); + WarpDrive.instance.cloaks.revealEntityToPlayer(this, (EntityPlayer)entityplayermp); + } + + if (!isPlayerWithinArea((EntityPlayer)entityplayermp) && !decloak) + sendCloakPacketToPlayer((EntityPlayer)entityplayermp, false); + else if (decloak) { + sendCloakPacketToPlayer((EntityPlayer)entityplayermp, true); + } + } + } + } + } + + public void sendCloakPacketToPlayer(EntityPlayer player, boolean decloak) { + //System.outprintln("[Cloak] Sending cloak packet to player " + player.username); + if (isPlayerInArea(player)) { + //System.outprintln("[Cloak] Player " + player.username + " is inside cloaking field"); + return; + } + + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + + try + { + outputStream.writeInt((int) this.aabb.minX); + outputStream.writeInt((int) this.aabb.minY); + outputStream.writeInt((int) this.aabb.minZ); + + outputStream.writeInt((int) this.aabb.maxX); + outputStream.writeInt((int) this.aabb.maxY); + outputStream.writeInt((int) this.aabb.maxZ); + + outputStream.writeBoolean(decloak); + + outputStream.writeByte(this.tier); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "WarpDriveCloaks"; + packet.data = bos.toByteArray(); + packet.length = bos.size(); + + ((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet); + } + + public boolean myChunkSBIDWMT(Chunk c, int x, int y, int z, int blockId, int blockMeta) + { + int j1 = z << 4 | x; + + if (y >= c.precipitationHeightMap[j1] - 1) + { + c.precipitationHeightMap[j1] = -999; + } + + int l1 = c.getBlockID(x, y, z); + int i2 = c.getBlockMetadata(x, y, z); + + if (l1 == blockId && i2 == blockMeta) + { + return false; + } + else + { + ExtendedBlockStorage[] storageArrays = c.getBlockStorageArray(); + ExtendedBlockStorage extendedblockstorage = storageArrays[y >> 4]; + + if (extendedblockstorage == null) + { + if (blockId == 0) + { + return false; + } + + extendedblockstorage = storageArrays[y >> 4] = new ExtendedBlockStorage(y >> 4 << 4, !c.worldObj.provider.hasNoSky); + } + + int j2 = c.xPosition * 16 + x; + int k2 = c.zPosition * 16 + z; + extendedblockstorage.setExtBlockID(x, y & 15, z, blockId); + + if (extendedblockstorage.getExtBlockID(x, y & 15, z) != blockId) + { + return false; + } + else + { + extendedblockstorage.setExtBlockMetadata(x, y & 15, z, blockMeta); + c.isModified = true; + return true; + } + } + } +} diff --git a/src/cr0s/WarpDrive/EntityJump.java b/src/cr0s/WarpDrive/EntityJump.java index 1b71afee..64055e2c 100644 --- a/src/cr0s/WarpDrive/EntityJump.java +++ b/src/cr0s/WarpDrive/EntityJump.java @@ -501,7 +501,7 @@ public class EntityJump extends Entity if (c.getName().equals("atomicscience.jiqi.TTurbine")) try { - if (c.getField("shiDa").getBoolean(te)) // F*king Chinese + if (c.getField("shiDa").getBoolean(te)) ASTurbines.add(te); } catch (Exception e) @@ -766,7 +766,6 @@ public class EntityJump extends Entity if (entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) entity; - ChunkCoordinates bedLocation = player.getBedLocation(); if (bedLocation != null && testBB(axisalignedbb, bedLocation.posX, bedLocation.posY, bedLocation.posZ)) @@ -990,6 +989,8 @@ public class EntityJump extends Entity newTileEntity = TileEntity.createAndLoadEntity(oldnbt); newTileEntity.invalidate(); } + else if (blockID == WarpDriveConfig.i.GT_Machine) + newTileEntity = TileEntity.createAndLoadEntity(oldnbt); else if (blockID == WarpDriveConfig.i.AS_Turbine) { if (oldnbt.hasKey("zhuYao")) @@ -1002,13 +1003,19 @@ public class EntityJump extends Entity } newTileEntity = TileEntity.createAndLoadEntity(oldnbt); } - - if (newTileEntity == null) - newTileEntity = TileEntity.createAndLoadEntity(oldnbt); - + else + { + newTileEntity = targetWorld.getBlockTileEntity(newX, newY, newZ); + if (newTileEntity == null) + { + System.out.println("[EJ] Error moving tileEntity! TE is null"); + return false; + } + newTileEntity.invalidate(); + newTileEntity.readFromNBT(oldnbt); + } newTileEntity.worldObj = targetWorld; newTileEntity.validate(); - worldObj.removeBlockTileEntity(oldX, oldY, oldZ); targetWorld.setBlockTileEntity(newX, newY, newZ, newTileEntity); } @@ -1213,10 +1220,4 @@ public class EntityJump extends Entity e.printStackTrace(); } } - - @Override - public boolean shouldRenderInPass(int pass) - { - return false; - } } \ No newline at end of file diff --git a/src/cr0s/WarpDrive/EntitySphereGen.java b/src/cr0s/WarpDrive/EntitySphereGen.java index a2e9ce69..6c88825d 100644 --- a/src/cr0s/WarpDrive/EntitySphereGen.java +++ b/src/cr0s/WarpDrive/EntitySphereGen.java @@ -265,10 +265,4 @@ System.out.println("ZLO EntitySphereGen THE FUCK create"); c.isModified = true; return true; } - - @Override - public boolean shouldRenderInPass(int pass) - { - return false; - } } \ No newline at end of file diff --git a/src/cr0s/WarpDrive/JumpGatesRegistry.java b/src/cr0s/WarpDrive/JumpGatesRegistry.java index 362e906a..87c570ad 100644 --- a/src/cr0s/WarpDrive/JumpGatesRegistry.java +++ b/src/cr0s/WarpDrive/JumpGatesRegistry.java @@ -21,17 +21,8 @@ public final class JumpGatesRegistry //@SideOnly(Side.CLIENT) public JumpGatesRegistry() { - db = new File("gates.txt"); - System.out.println("Gates.txt file: " + db); - - if (db != null && !db.exists()) { - try { - db.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - } - } - + db = MinecraftServer.getServer().getFile("gates.txt"); + try { loadGates(); diff --git a/src/cr0s/WarpDrive/PacketHandler.java b/src/cr0s/WarpDrive/PacketHandler.java index 7d0728ee..508a02fd 100644 --- a/src/cr0s/WarpDrive/PacketHandler.java +++ b/src/cr0s/WarpDrive/PacketHandler.java @@ -21,95 +21,103 @@ import net.minecraft.client.multiplayer.WorldClient; public class PacketHandler implements IPacketHandler { - @Override - public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) - { - if (packet.channel.equals("WarpDriveBeam")) - { - handleBeam(packet, (EntityPlayer)player); - } - else if (packet.channel.equals("WarpDriveFreq")) - { - handleFreqUpdate(packet, (EntityPlayer)player); - } - else if (packet.channel.equals("WarpDriveLaserT")) - { - handleLaserTargeting(packet, (EntityPlayer)player); - } - else if (packet.channel.equals("WarpDriveCloaks")) - { - handleCloak(packet, (EntityPlayer)player); - } - } + @Override + public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) + { + if (packet.channel.equals("WarpDriveBeam")) + { + handleBeam(packet, (EntityPlayer)player); + } + else if (packet.channel.equals("WarpDriveFreq")) + { + handleFreqUpdate(packet, (EntityPlayer)player); + } + else if (packet.channel.equals("WarpDriveLaserT")) + { + handleLaserTargeting(packet, (EntityPlayer)player); + } + else if (packet.channel.equals("WarpDriveCloaks")) + { + handleCloak(packet, (EntityPlayer)player); + } + } - public void handleCloak(Packet250CustomPayload packet, EntityPlayer player) { - DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); + public void handleCloak(Packet250CustomPayload packet, EntityPlayer player) { + DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); - try - { - // Read cloaked area parameters - int minX = inputStream.readInt(); - int minY = inputStream.readInt(); - int minZ = inputStream.readInt(); - - int maxX = inputStream.readInt(); - int maxY = inputStream.readInt(); - int maxZ = inputStream.readInt(); - - boolean decloak = inputStream.readBoolean(); - - byte tier = inputStream.readByte(); - - int w = Math.abs(maxX - minX); - int h = Math.abs(maxY - minY); - int l = Math.abs(maxZ - minZ); - - int size = w * h * l; - - //System.out.println("[Cloak Packet] Received " + ((decloak) ? "DEcloaked" : "cloaked") + "area: (" + minX + "; " + minY + "; " + minZ + ") -> (" + maxX + "; " + maxY + "; " + maxZ + ")"); - - if (minX <= player.posX && maxX >= player.posY && minY <= player.posZ && maxY >= player.posX && minZ <= player.posY && maxZ >= player.posZ) - return; - - // Hide the area - if (!decloak) { - //System.out.println("[Cloak Packet] Removing " + size + " blocks..."); - - // Now hide the blocks within area - World worldObj = player.worldObj; - for (int y = minY; y <= maxY; y++) - for (int x = minX; x <= maxX; x++) - for(int z = minZ; z <= maxZ; z++) - if (worldObj.getBlockId(x, y, z) != 0) - worldObj.setBlock(x, y, z, (tier == 1) ? WarpDriveConfig.i.gasID : 0, 5, 4); - - //System.out.println("[Cloak Packet] Removing entity..."); - // Hide any entities inside area - AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); - List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(player, aabb); - for (Entity e : list) { - worldObj.removeEntity(e); - ((WorldClient)worldObj).removeEntityFromWorld(e.entityId); - } - } else { // reveal the area - player.worldObj.markBlockRangeForRenderUpdate(minX + 1, minY + 1, minZ + 1, maxX + 1, maxY + 1, maxZ + 1); - - // Make some graphics - int numLasers = 25 + player.worldObj.rand.nextInt(300); - - for (int i = 0; i < numLasers; i++) { - int randX1 = minX + player.worldObj.rand.nextInt(maxX - minX); - int randX2 = minX + player.worldObj.rand.nextInt(maxX - minX); - - int randY1 = minY + player.worldObj.rand.nextInt(maxY - minY); - int randY2 = minY + player.worldObj.rand.nextInt(maxY - minY); - - int randZ1 = minZ + player.worldObj.rand.nextInt(maxZ - minZ); - int randZ2 = minZ + player.worldObj.rand.nextInt(maxZ - minZ); - - float r = 0, g = 0, b = 0; - - switch (player.worldObj.rand.nextInt(6)) { + try + { + // Read cloaked area parameters + int minX = inputStream.readInt(); + int minY = inputStream.readInt(); + int minZ = inputStream.readInt(); + + int maxX = inputStream.readInt(); + int maxY = inputStream.readInt(); + int maxZ = inputStream.readInt(); + + boolean decloak = inputStream.readBoolean(); + + byte tier = inputStream.readByte(); + + int w = Math.abs(maxX - minX); + int h = Math.abs(maxY - minY); + int l = Math.abs(maxZ - minZ); + + //(-2099; 208; 423) -> (-2069; 243; 453) + // + int size = w * h * l; + + //System.out.println("[Cloak Packet] Received " + ((decloak) ? "DEcloaked" : "cloaked") + "area: (" + minX + "; " + minY + "; " + minZ + ") -> (" + maxX + "; " + maxY + "; " + maxZ + ")"); + + if (minX <= player.chunkCoordX && maxX >= player.chunkCoordY && minY <= player.chunkCoordY && maxY >= player.chunkCoordY && minZ <= player.chunkCoordZ && maxZ >= player.chunkCoordZ) + return; + + // Hide the area + if (!decloak) + { + //System.out.println("[Cloak Packet] Removing " + size + " blocks..."); + + // Now hide the blocks within area + World worldObj = player.worldObj; + for (int y = minY; y <= maxY; y++) + for (int x = minX; x <= maxX; x++) + for(int z = minZ; z <= maxZ; z++) + if (worldObj.getBlockId(x, y, z) != 0) + worldObj.setBlock(x, y, z, (tier == 1) ? WarpDriveConfig.i.gasID : 0, 5, 4); + + //System.out.println("[Cloak Packet] Removing entity..."); + // Hide any entities inside area + AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); + List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(player, aabb); + for (Entity e : list) + { + worldObj.removeEntity(e); + ((WorldClient)worldObj).removeEntityFromWorld(e.entityId); + } + } + else + { // reveal the area + player.worldObj.markBlockRangeForRenderUpdate(minX, minY, minZ, maxX, maxY, maxZ); + + // Make some graphics + int numLasers = 25 + player.worldObj.rand.nextInt(300); + + for (int i = 0; i < numLasers; i++) + { + int randX1 = minX + player.worldObj.rand.nextInt(maxX - minX); + int randX2 = minX + player.worldObj.rand.nextInt(maxX - minX); + + int randY1 = minY + player.worldObj.rand.nextInt(maxY - minY); + int randY2 = minY + player.worldObj.rand.nextInt(maxY - minY); + + int randZ1 = minZ + player.worldObj.rand.nextInt(maxZ - minZ); + int randZ2 = minZ + player.worldObj.rand.nextInt(maxZ - minZ); + + float r = 0, g = 0, b = 0; + + switch (player.worldObj.rand.nextInt(6)) + { case 0: r = 1.0f; g = b = 0; @@ -134,147 +142,146 @@ public class PacketHandler implements IPacketHandler r = 1.0f; b = 0.5f; g = 0f; - } - - WarpDrive.proxy.renderBeam(player.worldObj, new Vector3(randX1, randY1, randZ1), new Vector3(randX2, randY2, randZ2), r, g, b, 10, 100); - } - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public void handleLaserTargeting(Packet250CustomPayload packet, EntityPlayer player) - { - DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); + } + WarpDrive.proxy.renderBeam(player.worldObj, new Vector3(randX1, randY1, randZ1), new Vector3(randX2, randY2, randZ2), r, g, b, 10, 100); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void handleLaserTargeting(Packet250CustomPayload packet, EntityPlayer player) + { + DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); - try - { - int x = inputStream.readInt(); - int y = inputStream.readInt(); - int z = inputStream.readInt(); - float yaw = inputStream.readFloat(); - float pitch = inputStream.readFloat(); - System.out.println("Got target packet: (" + x + "; " + y + "; " + z + ") | yaw: " + yaw + " | pitch: " + pitch); - TileEntity te = player.worldObj.getBlockTileEntity(x, y, z); + try + { + int x = inputStream.readInt(); + int y = inputStream.readInt(); + int z = inputStream.readInt(); + float yaw = inputStream.readFloat(); + float pitch = inputStream.readFloat(); + System.out.println("Got target packet: (" + x + "; " + y + "; " + z + ") | yaw: " + yaw + " | pitch: " + pitch); + TileEntity te = player.worldObj.getBlockTileEntity(x, y, z); - if (te != null) - { - System.out.println("TE is NULL"); + if (te != null) + { + System.out.println("TE is NULL"); - if (te instanceof TileEntityLaser) - { - TileEntityLaser l = (TileEntityLaser)te; - l.yaw = yaw; - l.pitch = pitch; - l.delayTicks = 0; - l.isEmitting = true; - } - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } + if (te instanceof TileEntityLaser) + { + TileEntityLaser l = (TileEntityLaser)te; + l.yaw = yaw; + l.pitch = pitch; + l.delayTicks = 0; + l.isEmitting = true; + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } - public void handleFreqUpdate(Packet250CustomPayload packet, EntityPlayer player) - { - DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); + public void handleFreqUpdate(Packet250CustomPayload packet, EntityPlayer player) + { + DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); - try - { - int x = inputStream.readInt(); - int y = inputStream.readInt(); - int z = inputStream.readInt(); - int freq = inputStream.readInt(); - //System.out.println("Got freq packet: (" + x + "; " + y + "; " + z + ") | freq: " + freq); - TileEntity te = player.worldObj.getBlockTileEntity(x, y, z); + try + { + int x = inputStream.readInt(); + int y = inputStream.readInt(); + int z = inputStream.readInt(); + int freq = inputStream.readInt(); + //System.out.println("Got freq packet: (" + x + "; " + y + "; " + z + ") | freq: " + freq); + TileEntity te = player.worldObj.getBlockTileEntity(x, y, z); - if (te != null) - { - if (te instanceof TileEntityMonitor) - { - ((TileEntityMonitor)te).setFrequency(freq); - } - else if (te instanceof TileEntityCamera) - { - ((TileEntityCamera)te).setFrequency(freq); - WarpDrive.instance.cams.updateInRegistry(new CamRegistryItem(freq, new ChunkPosition(x, y, z), player.worldObj).setType(0)); - } - else if (te instanceof TileEntityLaser) - { - ((TileEntityLaser)te).camFreq = freq; - WarpDrive.instance.cams.updateInRegistry(new CamRegistryItem(freq, new ChunkPosition(x, y, z), player.worldObj).setType(1)); - } - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } + if (te != null) + { + if (te instanceof TileEntityMonitor) + { + ((TileEntityMonitor)te).setFrequency(freq); + } + else if (te instanceof TileEntityCamera) + { + ((TileEntityCamera)te).setFrequency(freq); + WarpDrive.instance.cams.updateInRegistry(new CamRegistryItem(freq, new ChunkPosition(x, y, z), player.worldObj).setType(0)); + } + else if (te instanceof TileEntityLaser) + { + ((TileEntityLaser)te).camFreq = freq; + WarpDrive.instance.cams.updateInRegistry(new CamRegistryItem(freq, new ChunkPosition(x, y, z), player.worldObj).setType(1)); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } - private void handleBeam(Packet250CustomPayload packet, EntityPlayer player) - { - DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); - int dimID; - Vector3 source, target; - double sx, sy, sz; - double tx, ty, tz; - float r, g, b; - int age; - int energy; - World worldObj = player.worldObj; + private void handleBeam(Packet250CustomPayload packet, EntityPlayer player) + { + DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); + int dimID; + Vector3 source, target; + double sx, sy, sz; + double tx, ty, tz; + float r, g, b; + int age; + int energy; + World worldObj = player.worldObj; - try - { - // Read source vector - sx = inputStream.readDouble(); - sy = inputStream.readDouble(); - sz = inputStream.readDouble(); - source = new Vector3(sx, sy, sz); - // Read target vector - tx = inputStream.readDouble(); - ty = inputStream.readDouble(); - tz = inputStream.readDouble(); - target = new Vector3(tx, ty, tz); - // Read r, g, b of laser - r = inputStream.readFloat(); - g = inputStream.readFloat(); - b = inputStream.readFloat(); - // Read age - age = inputStream.readByte(); - // Read energy value - energy = inputStream.readInt(); + try + { + // Read source vector + sx = inputStream.readDouble(); + sy = inputStream.readDouble(); + sz = inputStream.readDouble(); + source = new Vector3(sx, sy, sz); + // Read target vector + tx = inputStream.readDouble(); + ty = inputStream.readDouble(); + tz = inputStream.readDouble(); + target = new Vector3(tx, ty, tz); + // Read r, g, b of laser + r = inputStream.readFloat(); + g = inputStream.readFloat(); + b = inputStream.readFloat(); + // Read age + age = inputStream.readByte(); + // Read energy value + energy = inputStream.readInt(); - // Render beam - /*System.out.println("sx: " + sx + " sy: " + sy + " sz: " + sz); - System.out.println("tx: " + sx + " ty: " + sy + " tz: " + sz); + // Render beam + /*System.out.println("sx: " + sx + " sy: " + sy + " sz: " + sz); + System.out.println("tx: " + sx + " ty: " + sy + " tz: " + sz); - System.out.println("source: " + source); - System.out.println("target: " + target); - System.out.println("r: " + r); - System.out.println("g: " + g); - System.out.println("b " + b); - System.out.println("age: " + age); - System.out.println("energy: " + energy);*/ + System.out.println("source: " + source); + System.out.println("target: " + target); + System.out.println("r: " + r); + System.out.println("g: " + g); + System.out.println("b " + b); + System.out.println("age: " + age); + System.out.println("energy: " + energy);*/ - // To avoid NPE at logging in - if (worldObj == null) - { - System.out.println("WorldObj is null"); - return; - } + // To avoid NPE at logging in + if (worldObj == null) + { + System.out.println("WorldObj is null"); + return; + } - WarpDrive.proxy.renderBeam(worldObj, source.clone(), target.clone(), r, g, b, age, energy); - } - catch (IOException e) - { - e.printStackTrace(); - return; - } - } + WarpDrive.proxy.renderBeam(worldObj, source.clone(), target.clone(), r, g, b, age, energy); + } + catch (IOException e) + { + e.printStackTrace(); + return; + } + } } \ No newline at end of file diff --git a/src/cr0s/WarpDrive/SoundHandler.java b/src/cr0s/WarpDrive/SoundHandler.java index 187dc155..c76e5814 100644 --- a/src/cr0s/WarpDrive/SoundHandler.java +++ b/src/cr0s/WarpDrive/SoundHandler.java @@ -18,8 +18,6 @@ public class SoundHandler event.manager.addSound("warpdrive:hilaser.ogg"); event.manager.addSound("warpdrive:midlaser.ogg"); event.manager.addSound("warpdrive:lowlaser.ogg"); - event.manager.addSound("warpdrive:cl.ogg"); - event.manager.addSound("warpdrive:dcl.ogg"); } catch (Exception e) { diff --git a/src/cr0s/WarpDrive/SpaceEventHandler.java b/src/cr0s/WarpDrive/SpaceEventHandler.java index 5012f157..d761ca10 100644 --- a/src/cr0s/WarpDrive/SpaceEventHandler.java +++ b/src/cr0s/WarpDrive/SpaceEventHandler.java @@ -1,21 +1,16 @@ package cr0s.WarpDrive; -import ic2.api.item.Items; - import java.util.HashMap; import java.util.List; -import cr0s.WarpDrive.CloakManager.CloakedArea; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.event.ForgeSubscribe; -import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; /** @@ -41,8 +36,7 @@ public class SpaceEventHandler public void livingUpdate(LivingUpdateEvent event) { EntityLivingBase entity = event.entityLiving; - - // Instant kill if entity exceeds world's limit + if (Math.abs(MathHelper.floor_double(entity.posX)) > WarpDrive.WORLD_LIMIT_BLOCKS || Math.abs(MathHelper.floor_double(entity.posZ)) > WarpDrive.WORLD_LIMIT_BLOCKS) { if (entity instanceof EntityPlayerMP) @@ -56,10 +50,8 @@ public class SpaceEventHandler entity.attackEntityFrom(DamageSource.outOfWorld, 9000); return; } - - if (entity instanceof EntityPlayerMP) { + if (entity instanceof EntityPlayerMP) updatePlayerCloakState(entity); - } // If player in vaccum, check and start consuming air cells if (entity.worldObj.provider.dimensionId == WarpDrive.instance.spaceDimID || entity.worldObj.provider.dimensionId == WarpDrive.instance.hyperSpaceDimID) @@ -120,7 +112,8 @@ public class SpaceEventHandler } } - private void updatePlayerCloakState(EntityLivingBase entity) { + private void updatePlayerCloakState(EntityLivingBase entity) + { // Make sure for elapsed time is second after last update if (System.currentTimeMillis() - this.lastTimer > 1000) lastTimer = System.currentTimeMillis(); @@ -131,31 +124,39 @@ public class SpaceEventHandler EntityPlayerMP p = (EntityPlayerMP)entity; Integer cloakTicks = this.cloakPlayersTimers.get(p.username); - if (cloakTicks == null) { + if (cloakTicks == null) + { this.cloakPlayersTimers.remove(p.username); this.cloakPlayersTimers.put(p.username, 0); return; } - if (cloakTicks >= CLOAK_CHECK_TIMEOUT_SEC) { + if (cloakTicks >= CLOAK_CHECK_TIMEOUT_SEC) + { this.cloakPlayersTimers.remove(p.username); this.cloakPlayersTimers.put(p.username, 0); List<CloakedArea> cloaks = WarpDrive.instance.cloaks.getCloaksForPoint(p.worldObj.provider.dimensionId, MathHelper.floor_double(p.posX), MathHelper.floor_double(p.posY), MathHelper.floor_double(p.posZ), false); - if (cloaks.size() != 0) { + if (cloaks.size() != 0) + { //System.out.println("[Cloak] Player inside " + cloaks.size() + " cloaked areas"); - for (CloakedArea area : cloaks) { + for (CloakedArea area : cloaks) + { //System.out.println("[Cloak] Frequency: " + area.frequency + ". In: " + area.isPlayerInArea(p) + ", W: " + area.isPlayerWithinArea(p)); - if (!area.isPlayerInArea(p) && area.isPlayerWithinArea(p)) { + if (!area.isPlayerInArea(p) && area.isPlayerWithinArea(p)) + { WarpDrive.instance.cloaks.playerEnteringCloakedArea(area, p); } } - } else { + } else + { //System.out.println("[Cloak] Player is not inside any cloak fields. Check, which field player may left..."); WarpDrive.instance.cloaks.checkPlayerLeavedArea(p); } - } else { + } + else + { this.cloakPlayersTimers.remove(p.username); this.cloakPlayersTimers.put(p.username, cloakTicks + 1); } @@ -197,26 +198,4 @@ public class SpaceEventHandler } return false; } - - @ForgeSubscribe - public void livingFall(LivingFallEvent event) - { - EntityLivingBase entity = event.entityLiving; - float distance = event.distance; - - if (entity instanceof EntityPlayer) - { - EntityPlayer player = (EntityPlayer) entity; - int check = MathHelper.ceiling_float_int(distance - 3.0F); - - if (check > 0) - { - if ((player.getCurrentArmor(0) != null && player.getCurrentArmor(0).itemID == Items.getItem("quantumBoots").itemID) || - (player.getCurrentArmor(2) != null && WarpDriveConfig.i.Jetpacks.contains(player.getCurrentArmor(2).itemID))) - { - event.setCanceled(true); // Don't damage player - } - } - } - } } diff --git a/src/cr0s/WarpDrive/TileEntityCloakingDeviceCore.java b/src/cr0s/WarpDrive/TileEntityCloakingDeviceCore.java index 339b60ca..cc4d8396 100644 --- a/src/cr0s/WarpDrive/TileEntityCloakingDeviceCore.java +++ b/src/cr0s/WarpDrive/TileEntityCloakingDeviceCore.java @@ -3,7 +3,6 @@ package cr0s.WarpDrive; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import cr0s.WarpDrive.CloakManager.CloakedArea; import dan200.computer.api.IComputerAccess; import dan200.computer.api.ILuaContext; import dan200.computer.api.IPeripheral; @@ -68,9 +67,6 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS private int updateTicks = 0; private int laserDrawingTicks = 0; - private boolean soundPlayed = false; - private int soundTicks = 0; - @Override public void updateEntity() { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { @@ -82,14 +78,7 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS addedToEnergyNet = true; } - // Reset sound timer - if (soundTicks++ >= 40) { - this.soundTicks = 0; - this.soundPlayed = false; - } - if (--this.updateTicks <= 0) { - //System.out.println("[CloakDev] Updating cloaking state..."); this.updateTicks = ((this.tier == 1) ? 20 : (tier == 2) ? 10 : 20) * WarpDriveConfig.i.CD_FIELD_REFRESH_INTERVAL_SECONDS; // resetting timer if (validateAssembly() && isEnabled) { @@ -100,10 +89,7 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS if (!WarpDrive.instance.cloaks.isAreaExists(this.frequency)) { WarpDrive.instance.cloaks.addCloakedAreaWorld(worldObj, minX, minY, minZ, maxX, maxY, maxZ, frequency, tier); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); - if (!soundPlayed) { - soundPlayed = true; - worldObj.playSoundEffect(xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, "warpdrive:cl", 4F, 1F); - } + worldObj.playSoundEffect(xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, "warpdrive:cloak", 4F, 1F); // Enable coils setCoilsState(true); @@ -114,13 +100,11 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS area.sendCloakPacketToPlayersEx(false); // recloak field } } else { - System.out.println("[CloakDev] Low power, cloak field collapsing..."); currentEnergyValue = 0; setCoilsState(false); disableCloakingField(); } } else if (!validateAssembly() && isEnabled) { - System.out.println("[CloakDev] Device lost coils, field collapsing"); currentEnergyValue = 0; setCoilsState(false); disableCloakingField(); @@ -226,11 +210,7 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS if (WarpDrive.instance.cloaks.isAreaExists(this.frequency)) WarpDrive.instance.cloaks.removeCloakedArea(this.frequency); - if (!soundPlayed) { - soundPlayed = true; - worldObj.playSoundEffect(xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, "warpdrive:dcl", 4F, 1F); - } - + worldObj.playSoundEffect(xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, "warpdrive:decloak", 4F, 1F); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); } public void countBlocksAndConsumeEnergy() { @@ -242,7 +222,6 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS blocksCount++; int energyToConsume = blocksCount * ((this.tier == 1) ? WarpDriveConfig.i.CD_ENERGY_PER_BLOCK_TIER1 : WarpDriveConfig.i.CD_ENERGY_PER_BLOCK_TIER2); - //System.out.println("[CloakDev] Consuming " + energyToConsume + " eU for " + blocksCount + " blocks"); this.currentEnergyValue -= energyToConsume; } @@ -333,7 +312,7 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS this.right = searchCoilInDirection((byte)-1, (byte)0, (byte)0) + WarpDriveConfig.i.CD_COIL_CAPTURE_BLOCKS; if (this.right == WarpDriveConfig.i.CD_COIL_CAPTURE_BLOCKS) return false; - this.up = searchCoilInDirection((byte)0, (byte)1, (byte)0) + WarpDriveConfig.i.CD_COIL_CAPTURE_BLOCKS; + this.up = searchCoilInDirection((byte)0, (byte)1, (byte)0) + WarpDriveConfig.i.CD_COIL_CAPTURE_BLOCKS; if (this.up == WarpDriveConfig.i.CD_COIL_CAPTURE_BLOCKS) return false; this.down = searchCoilInDirection((byte)0, (byte)-1, (byte)0) + WarpDriveConfig.i.CD_COIL_CAPTURE_BLOCKS; if (this.down == WarpDriveConfig.i.CD_COIL_CAPTURE_BLOCKS) return false; @@ -343,31 +322,31 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS this.back = searchCoilInDirection((byte)0, (byte)0, (byte)-1) + WarpDriveConfig.i.CD_COIL_CAPTURE_BLOCKS; if (this.back == WarpDriveConfig.i.CD_COIL_CAPTURE_BLOCKS) return false; - int x1 = 0, x2 = 0, z1 = 0, z2 = 0; + int x1 = 0, x2 = 0, z1 = 0, z2 = 0; - z1 = zCoord - this.back; - z2 = zCoord + this.front; - x1 = xCoord - this.right; - x2 = xCoord + this.left; + z1 = zCoord - this.back; + z2 = zCoord + this.front; + x1 = xCoord - this.right; + x2 = xCoord + this.left; - if (x1 < x2) { - this.minX = x1;this. maxX = x2; - } - else { - this.minX = x2; this.maxX = x1; - } + if (x1 < x2) { + this.minX = x1;this. maxX = x2; + } + else { + this.minX = x2; this.maxX = x1; + } - if (z1 < z2) { - this.minZ = z1; this.maxZ = z2; - } - else { - this.minZ = z2; this.maxZ = z1; - } + if (z1 < z2) { + this.minZ = z1; this.maxZ = z2; + } + else { + this.minZ = z2; this.maxZ = z1; + } + + this.minY = yCoord - this.down; + this.maxY = yCoord + this.up; - this.minY = yCoord - this.down; - this.maxY = yCoord + this.up; - return true; } @@ -389,10 +368,7 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS switch (method) { case 0: // setFieldTier(1 or 2) if (arguments.length == 1) { - if (((Double)arguments[0]).byteValue() != 1 && ((Double)arguments[0]).byteValue() != 2) { - this.tier = 1; - } else - this.tier = ((Double)arguments[0]).byteValue(); + this.tier = ((Double)arguments[0]).byteValue(); } break; diff --git a/src/cr0s/WarpDrive/TileEntityLaser.java b/src/cr0s/WarpDrive/TileEntityLaser.java index 3fae6c7a..f0973455 100644 --- a/src/cr0s/WarpDrive/TileEntityLaser.java +++ b/src/cr0s/WarpDrive/TileEntityLaser.java @@ -56,7 +56,13 @@ public class TileEntityLaser extends TileEntity implements IPeripheral public int delayTicks = 0; private int energyFromOtherBeams = 0; - private MovingObjectPosition firstHit; + private MovingObjectPosition firstHit = null; + private int hitX = 0; + private int hitY = 0; + private int hitZ = 0; + private int hitBlockId = 0; + private int hitBlockMeta = 0; + private float hitBlockResistance = 0; private int camUpdateTicks = 20; private int registryUpdateTicks = 20 * 10; @@ -65,7 +71,7 @@ public class TileEntityLaser extends TileEntity implements IPeripheral public void updateEntity() { // Frequency is not set - if (frequency <= 0) + if (frequency <= 0 || frequency > 65000) { return; } @@ -85,7 +91,7 @@ public class TileEntityLaser extends TileEntity implements IPeripheral } } - if (isEmitting && (frequency != 1420 && ++delayTicks > WarpDriveConfig.i.LE_EMIT_DELAY_TICKS) || ((frequency == 1420) && ++delayTicks > WarpDriveConfig.i.LE_EMIT_SCAN_DELAY_TICKS)) + if (isEmitting && ((frequency != 1420 && ++delayTicks > WarpDriveConfig.i.LE_EMIT_DELAY_TICKS) || ((frequency == 1420) && ++delayTicks > WarpDriveConfig.i.LE_EMIT_SCAN_DELAY_TICKS))) { delayTicks = 0; isEmitting = false; @@ -97,14 +103,7 @@ public class TileEntityLaser extends TileEntity implements IPeripheral public void addBeamEnergy(int amount) { if (isEmitting) - { energyFromOtherBeams += amount; - System.out.println("[LE] Added energy: " + amount); - } - else - { - System.out.println("[LE] Ignored energy: " + amount); - } } private int collectEnergyFromBoosters() @@ -139,7 +138,6 @@ public class TileEntityLaser extends TileEntity implements IPeripheral { // Beam power calculations int beamLengthBlocks = energy / WarpDriveConfig.i.LE_BEAM_LENGTH_PER_ENERGY_DIVIDER; - System.out.println("Energy: " + energy + " | beamLengthBlocks: " + beamLengthBlocks); if (energy == 0 || beamLengthBlocks < 1 || frequency > 65000 || frequency <= 0) { @@ -147,7 +145,6 @@ public class TileEntityLaser extends TileEntity implements IPeripheral } Vector3 beamVector = new Vector3(this).add(0.5); - System.out.println("beamVector: " + beamVector); float yawz = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI); float yawx = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI); float pitchhorizontal = -MathHelper.cos(-pitch * 0.017453292F); @@ -157,11 +154,9 @@ public class TileEntityLaser extends TileEntity implements IPeripheral Vector3 lookVector = new Vector3((double) directionx, (double) pitchvertical, (double) directionz); Vector3.translate(beamVector, lookVector); Vector3 reachPoint = beamVector.clone().translate(beamVector.clone(), beamVector.clone().scale(lookVector.clone(), beamLengthBlocks)); - System.out.println("Look vector: " + lookVector); - System.out.println("reachPoint: " + reachPoint); - System.out.println("translatedBeamVector: " + beamVector); Vector3 endPoint = reachPoint.clone(); playSoundCorrespondsEnergy(energy); + int distanceTravelled = 0; //distance travelled from beam emitter to previous hit if there were any // This is scanning beam, do not deal damage to blocks @@ -171,7 +166,15 @@ public class TileEntityLaser extends TileEntity implements IPeripheral if (firstHit != null) { - sendLaserPacket(beamVector, new Vector3(firstHit), r, g, b, 50, energy, 200); + hitBlockId = worldObj.getBlockId(firstHit.blockX, firstHit.blockY, firstHit.blockZ); + hitBlockMeta = worldObj.getBlockMetadata(firstHit.blockX, firstHit.blockY, firstHit.blockZ); + hitBlockResistance = Block.blocksList[hitBlockId].blockResistance; + hitX = firstHit.blockX; + hitY = firstHit.blockY; + hitZ = firstHit.blockZ; + sendLaserPacket(beamVector, new Vector3(firstHit.hitVec), r, g, b, 50, energy, 200); + } else { + sendLaserPacket(beamVector, reachPoint, r, g, b, 50, energy, 200); } return; @@ -184,15 +187,6 @@ public class TileEntityLaser extends TileEntity implements IPeripheral // FIXME entity ray-tracing MovingObjectPosition entityHit = raytraceEntities(beamVector.clone(), lookVector.clone(), true, beamLengthBlocks); - if (entityHit == null) - { - System.out.println("Entity hit is null."); - } - else - { - System.out.println("Entity hit: " + entityHit); - } - if (entityHit != null && entityHit.entityHit instanceof EntityLivingBase) { EntityLivingBase e = (EntityLivingBase)entityHit.entityHit; @@ -616,7 +610,7 @@ public class TileEntityLaser extends TileEntity implements IPeripheral { double dx = (Double)arguments[0]; double dy = (Double)arguments[1]; - double dz = (Double)arguments[2]; + double dz = -(Double)arguments[2]; //FIXME kostyl double targetX = xCoord + dx; double targetY = yCoord + dy; double targetZ = zCoord + dz; @@ -647,8 +641,7 @@ public class TileEntityLaser extends TileEntity implements IPeripheral int blockID = worldObj.getBlockId(firstHit.blockX, firstHit.blockY, firstHit.blockZ); int blockMeta = worldObj.getBlockMetadata(firstHit.blockX, firstHit.blockY, firstHit.blockZ); float blockResistance = Block.blocksList[blockID].blockResistance; - Object[] info = { firstHit.blockX, firstHit.blockY, firstHit.blockZ, blockID, blockMeta, (Float)blockResistance }; - firstHit = null; + Object[] info = { hitX, hitY, hitZ, hitBlockId, hitBlockMeta, (Float)hitBlockResistance }; return info; } else diff --git a/src/cr0s/WarpDrive/TileEntityMiningLaser.java b/src/cr0s/WarpDrive/TileEntityMiningLaser.java index f0319b07..e62b2dfb 100644 --- a/src/cr0s/WarpDrive/TileEntityMiningLaser.java +++ b/src/cr0s/WarpDrive/TileEntityMiningLaser.java @@ -47,8 +47,6 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG Boolean powerStatus = false; private IGridInterface grid; - private final int MAX_BOOSTERS_NUMBER = 1; - private int dx, dz, dy; private boolean isMining = false; private boolean isQuarry = false; @@ -131,30 +129,23 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG } else { - if (++delayTicksMine > WarpDriveConfig.i.ML_MINE_DELAY) + if (++delayTicksMine > WarpDriveConfig.i.ML_MINE_DELAY && isMining) { delayTicksMine = 0; - - if (valuableIndex < valuablesInLayer.size()) + while(valuableIndex < valuablesInLayer.size() && isMining) { - //System.out.println("[ML] Mining: " + (valuableIndex + 1) + "/" + valuablesInLayer.size()); Vector3 valuable = valuablesInLayer.get(valuableIndex++); - // Mine valuable ore int blockID = worldObj.getBlockId(valuable.intX(), valuable.intY(), valuable.intZ()); - - // Skip if block is too hard or its empty block - if (!canDig(blockID)) - return; - + if (blockID == 0 || !canDig(blockID)) + continue; sendLaserPacket(minerVector, new Vector3(valuable.intX(), valuable.intY(), valuable.intZ()).add(0.5), 1, 1, 0, 2 * WarpDriveConfig.i.ML_MINE_DELAY, 0, 50); worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F); harvestBlock(valuable); + return;//top lel, yes yes } - else - { - currentMode = 0; - --currentLayer; - } + delayTicksMine = 0; + currentMode = 0; + --currentLayer; } } } @@ -163,8 +154,13 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG private boolean canDig(int blockID) { + if (blockID == 0) + return false; if (Block.blocksList[blockID] != null) - return ((blockID == WarpDriveConfig.i.GT_Granite || blockID == WarpDriveConfig.i.GT_Ores || blockID == WarpDriveConfig.i.iridiumID || Block.blocksList[blockID].blockResistance <= Block.obsidian.blockResistance) && blockID != WarpDriveConfig.i.MFFS_Field && blockID != Block.bedrock.blockID); + return ( (WarpDriveConfig.i.MinerOres.contains(blockID) || + Block.blocksList[blockID].blockHardness <= Block.obsidian.blockHardness) && + blockID !=WarpDriveConfig.i.MFFS_Field && + blockID != Block.bedrock.blockID ); else return (blockID != WarpDriveConfig.i.MFFS_Field && blockID != Block.bedrock.blockID); } @@ -275,7 +271,8 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG { if (inventory == null || itemStackSource == null) { - return 0; + isMining = false; //stopping operation + return 0; } int transferred = 0; @@ -341,7 +338,6 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG private void scanLayer() { - //System.out.println("Scanning layer"); valuablesInLayer.clear(); int xmax, zmax, x1, x2, z1, z2; int xmin, zmin; @@ -374,9 +370,6 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG zmax = z1; } - //System.out.println("Layer: xmax: " + xmax + ", xmin: " + xmin); - //System.out.println("Layer: zmax: " + zmax + ", zmin: " + zmin); - // Search for valuable blocks for (int x = xmin; x <= xmax; x++) for (int z = zmin; z <= zmax; z++) @@ -394,7 +387,6 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG } valuableIndex = 0; - //System.out.println("[ML] Found " + valuablesInLayer.size() + " valuables"); } private boolean collectEnergyPacketFromBooster(int packet, boolean test) diff --git a/src/cr0s/WarpDrive/TileEntityProtocol.java b/src/cr0s/WarpDrive/TileEntityProtocol.java index 2200d7d4..cb4cf021 100644 --- a/src/cr0s/WarpDrive/TileEntityProtocol.java +++ b/src/cr0s/WarpDrive/TileEntityProtocol.java @@ -84,13 +84,11 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral private void setJumpDistance(int distance) { - System.out.println("Setting jump distance: " + distance); this.distance = distance; } private void setMode(int mode) { - // System.out.println("Setting mode: " + mode); this.mode = mode; } @@ -109,7 +107,6 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral dir = 270; } - System.out.println("Setting direction: " + dir); this.direction = dir; } @@ -206,20 +203,20 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral public String getAttachedPlayersList() { - StringBuilder list = new StringBuilder(""); + String list = ""; for (int i = 0; i < this.players.size(); i++) { String nick = this.players.get(i); - list.append(nick + ((i == this.players.size() - 1) ? "" : ", ")); + list += nick + ((i == this.players.size() - 1) ? "" : ", "); } if (players.isEmpty()) { - list = new StringBuilder("<nobody>"); + list = "<nobody>"; } - return list.toString(); + return list; } /** @@ -433,7 +430,6 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral */ public void setBeaconFrequency(String beaconFrequency) { - //System.out.println("Setting beacon freqency: " + beaconFrequency); this.beaconFrequency = beaconFrequency; } @@ -473,18 +469,22 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral @Override public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { - //System.out.println("[ProtoBlock] Method " + method + " " + methodsArray[method] + " called!"); switch (method) { case 0: // dim_getp () return new Integer[] { getFront(), getRight(), getUp() }; case 1: // dim_setp (front, right, up) - if (arguments.length != 3 || (((Double)arguments[0]).intValue() < 0 || ((Double)arguments[1]).intValue() < 0 || ((Double)arguments[2]).intValue() < 0)) + if ( arguments.length != 3 || + ( ( (Double)arguments[0] ).intValue() < 0 || + ( (Double)arguments[1] ).intValue() < 0 || + ( (Double)arguments[2] ).intValue() < 0 || + ( (Double)arguments[0] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || + ( (Double)arguments[1] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || + ( (Double)arguments[2] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE ) ) { return new Integer[] { -1 }; } - System.out.println("Setting positive gabarits: f: " + ((Double)arguments[0]).intValue() + " r: " + ((Double)arguments[1]).intValue() + " u: " + ((Double)arguments[2]).intValue()); setFront(((Double)arguments[0]).intValue()); setRight(((Double)arguments[1]).intValue()); setUp(((Double)arguments[2]).intValue()); @@ -494,12 +494,17 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral case 2: // dim_getn () return new Integer[] { getBack(), getLeft(), getDown() }; case 3: // dim_setn (back, left, down) - if (arguments.length != 3 || (((Double)arguments[0]).intValue() < 0 || ((Double)arguments[1]).intValue() < 0 || ((Double)arguments[2]).intValue() < 0)) + if ( arguments.length != 3 || + ( ( (Double)arguments[0] ).intValue() < 0 || + ( (Double)arguments[1] ).intValue() < 0 || + ( (Double)arguments[2] ).intValue() < 0 || + ( (Double)arguments[0] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || + ( (Double)arguments[1] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || + ( (Double)arguments[2] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE ) ) { return new Integer[] { -1 }; } - System.out.println("Setting negative gabarits: b: " + ((Double)arguments[0]).intValue() + " l: " + ((Double)arguments[1]).intValue() + " d: " + ((Double)arguments[2]).intValue()); setBack(((Double)arguments[0]).intValue()); setLeft(((Double)arguments[1]).intValue()); setDown(((Double)arguments[2]).intValue()); diff --git a/src/cr0s/WarpDrive/TileEntityRadar.java b/src/cr0s/WarpDrive/TileEntityRadar.java index c4d5ca1d..2a6d6630 100644 --- a/src/cr0s/WarpDrive/TileEntityRadar.java +++ b/src/cr0s/WarpDrive/TileEntityRadar.java @@ -69,7 +69,6 @@ public class TileEntityRadar extends TileEntity implements IPeripheral, IEnergyS { if (cooldownTime++ > (20 * ((scanRadius / 1000) + 1))) { - //System.out.println("Scanning..."); WarpDrive.instance.registry.removeDeadCores(); results = WarpDrive.instance.registry.searchWarpCoresInRadius(xCoord, yCoord, zCoord, scanRadius); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 + 2); @@ -138,7 +137,6 @@ public class TileEntityRadar extends TileEntity implements IPeripheral, IEnergyS else { results = null; - System.out.println("Radius: " + radius + " | Enough energy: " + isEnergyEnoughForScanRadiusW(radius)); return new Boolean[] { false }; } } diff --git a/src/cr0s/WarpDrive/TileEntityReactor.java b/src/cr0s/WarpDrive/TileEntityReactor.java index 574113a9..6c206f5e 100644 --- a/src/cr0s/WarpDrive/TileEntityReactor.java +++ b/src/cr0s/WarpDrive/TileEntityReactor.java @@ -24,6 +24,7 @@ import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.common.FMLCommonHandler; + /** * @author Cr0s */ @@ -52,8 +53,8 @@ public class TileEntityReactor extends TileEntity implements IEnergySink public int shipLeft, shipRight; public int shipUp, shipDown; public int shipHeight, shipWidth, shipLength; - int shipSize = 0; - int shipVolume; + int shipSize = 0; //ship length in the direction of a jump + int shipVolume = 0; //number of all blocks the ship consists of int currentMode = 0; int currentEnergyValue = 0; @@ -64,7 +65,7 @@ public class TileEntityReactor extends TileEntity implements IEnergySink private final byte MODE_HYPERSPACE = 5; // Jump to Hyperspace private final byte MODE_TELEPORT = -1; private final byte MODE_GATE_JUMP = 6; // Jump via jumpgate - + int cooldownTime = 0; public int randomCooldownAddition = 0; @@ -198,13 +199,11 @@ public class TileEntityReactor extends TileEntity implements IEnergySink if (!prepareToJump()) { - System.out.println("[WC] Prepare to jump returns false"); return; } if (WarpDrive.instance.registry.isWarpCoreIntersectsWithOthers(this)) { - System.out.println("[WD] Intersect"); this.controller.setJumpFlag(false); messageToAllPlayersOnShip("Warp field intersects with other ship's field. Cannot jump."); return; @@ -212,13 +211,11 @@ public class TileEntityReactor extends TileEntity implements IEnergySink if (WarpDrive.instance.cloaks.isInCloak(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, false)) { - System.out.println("[WD] Core inside cloaking field"); this.controller.setJumpFlag(false); messageToAllPlayersOnShip("Wap-Core is inside cloaking field. Can't jump. Disable cloaking field to jump!"); return; } - System.out.println("[W-C] Jumping!"); doJump(); controller.setJumpFlag(false); } @@ -243,7 +240,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink continue; } - System.out.println(msg); ((EntityPlayer)o).addChatMessage("[WarpCore] " + msg); } } @@ -454,32 +450,32 @@ public class TileEntityReactor extends TileEntity implements IEnergySink minY = yCoord - shipDown; maxY = yCoord + shipUp; this.shipSize = 0; - + + int sizeFrontBack = shipFront + shipBack; + int sizeRightLeft = shipRight + shipLeft; + int sizeUpDown = shipUp + shipDown; + switch (this.direction) { case 0: case 180: - this.shipSize = this.shipBack + this.shipFront; + this.shipSize = sizeFrontBack; break; case 90: case 270: - this.shipSize = this.shipLeft + shipRight; + this.shipSize = sizeRightLeft; break; case -1: case -2: - this.shipSize = this.shipDown + this.shipUp; + this.shipSize = sizeUpDown; break; - - default: - this.controller.setJumpFlag(false); - return false; - } - - // Ship side is too big - if (shipLength > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || shipWidth > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || shipHeight > WarpDriveConfig.i.WC_MAX_SHIP_SIDE) + } + // Ship size is too big + if (sizeFrontBack > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || sizeRightLeft > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || sizeUpDown > WarpDriveConfig.i.WC_MAX_SHIP_SIDE) { + messageToAllPlayersOnShip("Ship is too long. Cannot jump."); this.controller.setJumpFlag(false); return false; } @@ -499,7 +495,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink { if (currentEnergyValue - calculateRequiredEnergy(shipVolume, distance) < 0) { - System.out.println("[WP-TE] Insufficient energy to jump"); this.controller.setJumpFlag(false); return; } @@ -539,7 +534,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink { // Consume all energy currentEnergyValue -= calculateRequiredEnergy(shipVolume, distance); - System.out.println("[TE-WC] Moving ship to a beacon (" + beaconX + "; " + yCoord + "; " + beaconZ + ")"); EntityJump jump = new EntityJump(worldObj, xCoord, yCoord, zCoord, 1, 0, dx, dz, this); jump.maxX = maxX; jump.minX = minX; @@ -565,16 +559,11 @@ public class TileEntityReactor extends TileEntity implements IEnergySink worldObj.spawnEntityInWorld(jump); coreState = ""; } - else - { - System.out.println("[TE-WC] Beacon not found."); - } } private boolean isShipInJumpgate(JumpGate jg) { AxisAlignedBB aabb = jg.getGateAABB(); - System.out.println("Gate AABB: " + aabb); int numBlocks = 0; if (aabb.isVecInside(worldObj.getWorldVec3Pool().getVecFromPool(maxX - minX, maxY - minY, maxZ - minZ))) @@ -601,12 +590,9 @@ public class TileEntityReactor extends TileEntity implements IEnergySink if (numBlocks == 0) { - System.out.println("[GATE] Is 0 blocks inside gate."); return false; } - System.out.println("[GATE] Ship volume: " + shipVolume + ", blocks in gate: " + numBlocks + ". Percentage: " + ((shipVolume / numBlocks) * 100)); - // At least 80% of ship must be inside jumpgate if (shipVolume / numBlocks > 0.8F) { @@ -657,7 +643,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink { if (currentEnergyValue - calculateRequiredEnergy(shipVolume, distance) < 0) { - System.out.println("[WP-TE] Insufficient energy to jump"); this.controller.setJumpFlag(false); return; } @@ -717,12 +702,10 @@ public class TileEntityReactor extends TileEntity implements IEnergySink return; } - System.out.println("[GATE] Place found over " + (10 - numTries) + " tries."); } // Consume energy currentEnergyValue -= calculateRequiredEnergy(shipVolume, distance); - System.out.println("[TE-WC] Moving ship to a place around gate '" + jg.name + "' (" + destX + "; " + destY + "; " + destZ + ")"); EntityJump jump = new EntityJump(worldObj, xCoord, yCoord, zCoord, 1, 0, dx, dz, this); jump.maxX = maxX; jump.minX = minX; @@ -757,7 +740,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink public void doJump() { - System.out.println("[WC] doJump() called"); if (currentMode == this.MODE_GATE_JUMP) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) @@ -765,14 +747,12 @@ public class TileEntityReactor extends TileEntity implements IEnergySink return; } - System.out.println("[TE-WC] Performing gate jump..."); doGateJump(); return; } if (currentMode == this.MODE_BEACON_JUMP) { - System.out.println("[TE-WC] Performing beacon jump..."); doBeaconJump(); return; } @@ -787,11 +767,7 @@ public class TileEntityReactor extends TileEntity implements IEnergySink JumpGate t = WarpDrive.instance.jumpGates.findNearestGate(xCoord, yCoord, zCoord); - - if (WarpDrive.instance.jumpGates == null) - System.out.println("[JumpGates] WarpDrive.instance.jumpGates is NULL!"); - - if (WarpDrive.instance.jumpGates != null && t != null && !isShipInJumpgate(t)) + if (t != null && !isShipInJumpgate(t)) { if (shipVolume < WarpDriveConfig.i.WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE) { @@ -804,23 +780,14 @@ public class TileEntityReactor extends TileEntity implements IEnergySink if (currentMode == this.MODE_BASIC_JUMP || currentMode == this.MODE_LONG_JUMP || currentMode == MODE_HYPERSPACE) { - System.out.println("[WP-TE] Energy: " + currentEnergyValue + " eU"); - System.out.println("[WP-TE] Need to jump: " + calculateRequiredEnergy(shipVolume, distance) + " eU"); - if (this.currentEnergyValue - calculateRequiredEnergy(shipVolume, distance) < 0) { - System.out.println("[WP-TE] Insufficient energy to jump"); messageToAllPlayersOnShip("Insufficient energy to jump!"); this.controller.setJumpFlag(false); return; } this.currentEnergyValue -= calculateRequiredEnergy(shipVolume, distance); - System.out.println((new StringBuilder()).append("Jump params: X ").append(minX).append(" -> ").append(maxX).append(" blocks").toString()); - System.out.println((new StringBuilder()).append("Jump params: Y ").append(minY).append(" -> ").append(maxY).append(" blocks").toString()); - System.out.println((new StringBuilder()).append("Jump params: Z ").append(minZ).append(" -> ").append(maxZ).append(" blocks").toString()); - - //System.out.println("[WC-TE] Distance: " + distance + "; shipSize: " + shipSize); if (this.currentMode == this.MODE_BASIC_JUMP) { distance += shipSize; @@ -834,7 +801,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink } } - System.out.println((new StringBuilder()).append("[JUMP] Totally moving ").append((new StringBuilder()).append(shipVolume).append(" blocks to length ").append(distance).append(" blocks, direction: ").append(direction).toString()).toString()); EntityJump jump = new EntityJump(worldObj, xCoord, yCoord, zCoord, distance, direction, dx, dz, this); jump.maxX = maxX; jump.minX = minX; @@ -855,7 +821,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink { jump.toHyperSpace = (worldObj.provider.dimensionId == WarpDrive.instance.spaceDimID); jump.fromHyperSpace = (worldObj.provider.dimensionId == WarpDrive.instance.hyperSpaceDimID); - System.out.println("[JUMP] From HS: " + jump.fromHyperSpace + " | To HS: " + jump.fromHyperSpace); } jump.xCoord = xCoord; @@ -946,7 +911,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink if (checkPlayerInventory(chest, player)) { - System.out.println("[P] Summoning " + player.username); summonPlayer(player, xCoord, yCoord + 2, zCoord); } } @@ -982,7 +946,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink if (keyLength < MIN_KEY_LENGTH) { - System.out.println("[ChestCode] Key is too short: " + keyLength + " < " + MIN_KEY_LENGTH); return false; } diff --git a/src/cr0s/WarpDrive/TileEntityShipScanner.java b/src/cr0s/WarpDrive/TileEntityShipScanner.java index c2ef9649..8a8096f0 100644 --- a/src/cr0s/WarpDrive/TileEntityShipScanner.java +++ b/src/cr0s/WarpDrive/TileEntityShipScanner.java @@ -58,17 +58,17 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, int warpCoreSearchTicks = 0; - // Config - private final String SCHEMATICS_DIR = "/home/cros/mc_site/schematics/"; + // Config //TODO add to WarpDriveConfig + private final String SCHEMATICS_DIR = "schematics"; private final int EU_PER_BLOCK_SCAN = 100; // eU per block of ship volume (including air) private final int EU_PER_BLOCK_DEPLOY = 5000; - private final int BLOCK_TO_DEPLOY_PER_TICK = 3000; + private final int BLOCK_TO_DEPLOY_PER_TICK = 1000; private final int ALLOWED_DEPLOY_RADIUS = 50; // blocks - private String[] methodsArray = { "scanShip", // 0 - "getSchematicFileName", // 1 - "getEnergyLevel", // 2 - "deployShipFromSchematic" // 3 deployShipFromSchematic(file, offsetX, offsetY, offsetZ) + private String[] methodsArray = { "scan", // 0 + "fileName", // 1 + "energy", // 2 + "deploy" // 3 deploy(file, offsetX, offsetY, offsetZ) }; private String schematicFileName; @@ -83,9 +83,8 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, @Override public void updateEntity() { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return; - } if (!addedToEnergyNet && !this.tileEntityInvalid) { MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); @@ -168,7 +167,6 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, deployDelayTicks = 0; int blocks = Math.min(BLOCK_TO_DEPLOY_PER_TICK, blocksToDeployCount - currentDeployIndex); - System.out.println("[ShipScanner] Deploying ship part: " + currentDeployIndex + "/" + blocksToDeployCount + " [remains: " + blocks + "]"); if (blocks == 0) { isDeploying = false; @@ -188,7 +186,10 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, // Deploy single block JumpBlock block = blocksToDeploy[currentDeployIndex]; - if (block != null && worldObj.isAirBlock(newX + block.x, newY + block.y, newZ + block.z)) + if (block != null && + block.blockID != Block.bedrock.blockID && + !WarpDriveConfig.i.scannerIgnoreBlocks.contains(block.blockID) && + worldObj.isAirBlock(newX + block.x, newY + block.y, newZ + block.z)) { moveBlockSimple(block); @@ -335,14 +336,12 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, schematic.setShort("Length", length); schematic.setShort("Height", height); - System.out.println("[ShipScanner] Ship parameters: w: " + width + ", l: " + length + ", h:" + height); int size = width * length * height; // Consume energy currentEnergyValue = Math.abs(currentEnergyValue - size * EU_PER_BLOCK_SCAN); - System.out.println("[ShipScanner] Size: " + size); byte localBlocks[] = new byte[size]; byte localMetadata[] = new byte[size]; @@ -357,8 +356,8 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, for (int z = 0; z < length; z++) { int blockID = worldObj.getBlockId(core.minX + x, core.minY + y, core.minZ + z); - // Do not scan air, bedrock and specified forbidden blocks (like ore or Warp-Cores) - if (worldObj.isAirBlock(core.minX + x, core.minY + y, core.minZ + z) || blockID == Block.bedrock.blockID || WarpDriveConfig.i.scannerIgnoreBlocks.contains(blockID)) + // Do not scan air and bedrock + if ( worldObj.isAirBlock(core.minX + x, core.minY + y, core.minZ + z) || blockID == Block.bedrock.blockID ) blockID = 0; int blockMetadata = (byte) worldObj.getBlockMetadata(core.minX + x, core.minY + y, core.minZ + z); @@ -417,7 +416,6 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, } private void writeNBTToFile(String fileName, NBTTagCompound nbttagcompound) { - System.out.println("[ShipScanner] Filename: " + fileName); try { File file = new File(fileName); @@ -440,15 +438,17 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, private void scanShip() { // Enable scanner switchState(1); + File f = new File(SCHEMATICS_DIR); + if (!f.exists() || !f.isDirectory()) + f.mkdirs(); // Generate unique file name do { schematicFileName = (new StringBuilder().append(core.coreFrequency) .append(System.currentTimeMillis()).append(".schematic")) .toString(); - } while (new File(this.SCHEMATICS_DIR + schematicFileName).exists()); - - saveShipToSchematic(this.SCHEMATICS_DIR + schematicFileName); + } while (new File(SCHEMATICS_DIR + "/" + schematicFileName).exists()); + saveShipToSchematic(SCHEMATICS_DIR + "/" + schematicFileName); } private NBTTagCompound readNBTFromFile(String fileName) { @@ -473,15 +473,14 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, } private boolean isEnoughEnergyForDeploy(int size) { - return size * EU_PER_BLOCK_DEPLOY <= currentEnergyValue; + return MAX_ENERGY_VALUE <= currentEnergyValue; } // Returns result array for CC interface: [ code, "message" ] private Object[] deployShip(String fileName, int offsetX, int offsetY, int offsetZ) { - NBTTagCompound schematic = readNBTFromFile(SCHEMATICS_DIR + fileName); + NBTTagCompound schematic = readNBTFromFile(SCHEMATICS_DIR + "/" + fileName); if (schematic == null) { - System.out.println("[ShipScanner] Schematic is null!"); return new Object[] { -1, "Unknow error. Schematic NBT is null" }; } @@ -503,11 +502,9 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, int size = width* height * length; - System.out.println("[ShipScanner] Deploying ship: (size: " + size + ", h: " + height + ", w: " + width + ", l: " + length + ")"); // Check energy level if (!isEnoughEnergyForDeploy(size)) { - System.out.println("[ShipScanner] Not enough energy! Need at least " + (Math.abs(size * EU_PER_BLOCK_DEPLOY - currentEnergyValue)) + " Eu"); return new Object[] { 1, "Not enough energy! Need at least " + (Math.abs(size * EU_PER_BLOCK_DEPLOY - currentEnergyValue)) + " Eu" }; } @@ -524,12 +521,11 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, } if (occupiedBlockCount > 0) { - System.out.println("[ShipScanner] Deploying area occupied with " + occupiedBlockCount + " blocks. Can't deploy ship."); return new Object[] { 2, "Deploying area occupied with " + occupiedBlockCount + " blocks. Can't deploy ship." }; } // Consume energy - currentEnergyValue = Math.abs(currentEnergyValue - size * EU_PER_BLOCK_DEPLOY); + currentEnergyValue = 0; // Set deployment vars this.blocksToDeploy = new JumpBlock[size]; @@ -541,11 +537,9 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, this.newY = targetY; this.newZ = targetZ; - System.out.println("[ShipScanner] Target to deploy: (" + targetX + ", " + targetY + ", " + targetZ + ")"); // Read blocks and TileEntities from NBT to internal storage array - System.out.println("[ShipScanner] Loading blocks..."); byte localBlocks[] = schematic.getByteArray("Blocks"); byte localMetadata[] = schematic.getByteArray("Data"); @@ -564,7 +558,6 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, } // Load Tile Entities - System.out.println("[ShipScanner] Loading TileEntities..."); NBTTagCompound[] tileEntities = new NBTTagCompound[size]; NBTTagList tileEntitiesList = schematic.getTagList("TileEntities"); @@ -574,7 +567,6 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, int teY = teTag.getInteger("y"); int teZ = teTag.getInteger("z"); - System.out.println("[ShipScanner] Loaded TE: " + teTag.getString("id")); tileEntities[teX + (teY * length + teZ) * width] = teTag; } @@ -590,34 +582,16 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, jb.blockMeta = (localMetadata[x + (y * length + z) * width]) & 0xFF; jb.blockNBT = tileEntities[x + (y * length + z) * width]; - - - + jb.x = x; jb.y = y; jb.z = z; - - if (jb.blockID != 0 && Block.blocksList[jb.blockID] != null) { - System.out.print("[ShipScanner] Saving block: " + Block.blocksList[jb.blockID].getUnlocalizedName() + ", TE: "); - if (tileEntities[x + (y * length + z) * width] == null) { - System.out.println("null!"); - } else { - System.out.println(tileEntities[x + (y * length + z) * width].getString("id")); - } - - blocksToDeploy[x + (y * length + z) * width] = jb; - } else { - jb = null; - - blocksToDeploy[x + (y * length + z) * width] = jb; - } - + blocksToDeploy[x + (y * length + z) * width] = jb; } } } switchState(1); - System.out.println("[ShipScanner] Ship deployed."); return new Object[] { 3, "Ship deployed." }; } @@ -679,11 +653,10 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, int y = ((Double)arguments[2]).intValue(); int z = ((Double)arguments[3]).intValue(); - if (!new File(SCHEMATICS_DIR + fileName).exists()) + if (!new File(SCHEMATICS_DIR + "/" + fileName).exists()) return new Object[] { 0, "Specified .schematic file not found!" }; else { - System.out.println("[ShipScanner] Trying to deploy ship"); return deployShip(fileName, x, y, z); } } else @@ -806,7 +779,7 @@ public class TileEntityShipScanner extends TileEntity implements IEnergySink, // Own implementation of setting blocks without light recalculation in optimization purposes public boolean mySetBlock(World w, int x, int y, int z, int blockId, int blockMeta, int par6) { - if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000) + if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000) //FIXME magic numbers { if (y < 0) { diff --git a/src/cr0s/WarpDrive/WarpCoresRegistry.java b/src/cr0s/WarpDrive/WarpCoresRegistry.java index c8438380..f4649451 100644 --- a/src/cr0s/WarpDrive/WarpCoresRegistry.java +++ b/src/cr0s/WarpDrive/WarpCoresRegistry.java @@ -148,7 +148,6 @@ public class WarpCoresRegistry // Check for warpfields intersections core.prepareToJump(); // calculate spatial parameters c.prepareToJump(); - // Compare warp-fields for intersection aabb1 = AxisAlignedBB.getBoundingBox(core.minX, core.minY, core.minZ, core.maxX, core.maxY, core.maxZ); aabb2 = AxisAlignedBB.getBoundingBox(c.minX, c.minY, c.minZ, c.maxX, c.maxY, c.maxZ); diff --git a/src/cr0s/WarpDrive/WarpDrive.java b/src/cr0s/WarpDrive/WarpDrive.java index 596b41c7..2628c648 100644 --- a/src/cr0s/WarpDrive/WarpDrive.java +++ b/src/cr0s/WarpDrive/WarpDrive.java @@ -34,16 +34,17 @@ import net.minecraftforge.common.ForgeChunkManager.LoadingCallback; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.MinecraftForge; -@Mod(modid = "WarpDrive", name = "WarpDrive", version = "1.2.0", dependencies = "required-after:IC2; required-after:ComputerCraft; after:CCTurtle; after:gregtech_addon; after:AppliedEnergistics; after:AdvancedSolarPanel; after:AtomicScience; after:ICBM|Explosion; after:MFFS; after:GraviSuite") +@Mod(modid = "WarpDrive", name = "WarpDrive", version = "1.2.0_ZLO", dependencies="required-after:IC2; after:required-AppliedEnergistics; after:extracells; required-after:ComputerCraft; after:CCTurtle; after:gregtech_addon; after:AdvancedSolarPanel; after:AtomicScience; after:ICBM|Explosion; after:MFFS; after:GraviSuite") @NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = { - "WarpDriveBeam", - "WarpDriveFreq", + "WarpDriveBeam", + "WarpDriveFreq", "WarpDriveLaserT", "WarpDriveCloaks" }, packetHandler = PacketHandler.class) /** * @author Cr0s */ -public class WarpDrive implements LoadingCallback { +public class WarpDrive implements LoadingCallback +{ // World limits public final static int WORLD_LIMIT_BLOCKS = 100000; @@ -62,7 +63,7 @@ public class WarpDrive implements LoadingCallback { public static Block scannerBlock; public static Block cloakBlock; public static Block cloakCoilBlock; - + public static Block airBlock; public static Block gasBlock; @@ -94,194 +95,147 @@ public class WarpDrive implements LoadingCallback { public int overlayType = 0; @EventHandler - // @PreInit - public void preInit(FMLPreInitializationEvent event) { - WarpDriveConfig.Init(new Configuration(event - .getSuggestedConfigurationFile())); + //@PreInit + public void preInit(FMLPreInitializationEvent event) + { + WarpDriveConfig.Init(new Configuration(event.getSuggestedConfigurationFile())); - if (FMLCommonHandler.instance().getSide().isClient()) { - System.out - .println("[WarpDrive] Registering sounds event handler..."); + if (FMLCommonHandler.instance().getSide().isClient()) + { + System.out.println("[WarpDrive] Registering sounds event handler..."); MinecraftForge.EVENT_BUS.register(new SoundHandler()); } } @Init - public void load(FMLInitializationEvent event) { - WarpDriveConfig.i.Init2(); - - // CORE CONTROLLER - this.protocolBlock = new BlockProtocol(WarpDriveConfig.i.controllerID, - 0, Material.rock).setHardness(0.5F) - .setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Warp Controller"); - - LanguageRegistry.addName(protocolBlock, "Warp Controller"); - GameRegistry.registerBlock(protocolBlock, "protocolBlock"); - GameRegistry.registerTileEntity(TileEntityProtocol.class, - "protocolBlock"); - + public void load(FMLInitializationEvent event) + { + WarpDriveConfig.i.Init2(); // WARP CORE - this.warpCore = new BlockReactor(WarpDriveConfig.i.coreID, 0, Material.rock).setHardness(0.5F).setStepSound(Block.soundMetalFootstep).setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Warp Core"); - + this.warpCore = new BlockReactor(WarpDriveConfig.i.coreID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Warp Core"); LanguageRegistry.addName(warpCore, "Warp Core"); GameRegistry.registerBlock(warpCore, "warpCore"); - GameRegistry.registerTileEntity(TileEntityReactor.class, "warpCore"); - + GameRegistry.registerTileEntity(TileEntityReactor.class, "warpCore"); + // CORE CONTROLLER + this.protocolBlock = new BlockProtocol(WarpDriveConfig.i.controllerID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Warp Controller"); + LanguageRegistry.addName(protocolBlock, "Warp Controller"); + GameRegistry.registerBlock(protocolBlock, "protocolBlock"); + GameRegistry.registerTileEntity(TileEntityProtocol.class, "protocolBlock"); // WARP RADAR - this.radarBlock = new BlockRadar(WarpDriveConfig.i.radarID, 0, - Material.rock).setHardness(0.5F) - .setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("W-Radar"); - + this.radarBlock = new BlockRadar(WarpDriveConfig.i.radarID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("W-Radar"); LanguageRegistry.addName(radarBlock, "W-Radar"); GameRegistry.registerBlock(radarBlock, "radarBlock"); GameRegistry.registerTileEntity(TileEntityRadar.class, "radarBlock"); - // WARP ISOLATION - this.isolationBlock = new BlockWarpIsolation( - WarpDriveConfig.i.isolationID, 0, Material.rock) + this.isolationBlock = new BlockWarpIsolation(WarpDriveConfig.i.isolationID, 0, Material.rock) .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Warp-Field Isolation Block"); - + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Warp-Field Isolation Block"); LanguageRegistry.addName(isolationBlock, "Warp-Field Isolation Block"); GameRegistry.registerBlock(isolationBlock, "isolationBlock"); - // AIR GENERATOR - this.airgenBlock = new BlockAirGenerator(WarpDriveConfig.i.airgenID, 0, - Material.rock).setHardness(0.5F) - .setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Air Generator"); + this.airgenBlock = new BlockAirGenerator(WarpDriveConfig.i.airgenID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Air Generator"); LanguageRegistry.addName(airgenBlock, "Air Generator"); GameRegistry.registerBlock(airgenBlock, "airgenBlock"); - GameRegistry.registerTileEntity(TileEntityAirGenerator.class, - "airgenBlock"); - + GameRegistry.registerTileEntity(TileEntityAirGenerator.class, "airgenBlock"); // AIR BLOCK - this.airBlock = (new BlockAir(WarpDriveConfig.i.airID)).setHardness( - 0.0F).setUnlocalizedName("Air block"); + this.airBlock = (new BlockAir(WarpDriveConfig.i.airID)).setHardness(0.0F).setUnlocalizedName("Air block"); LanguageRegistry.addName(airBlock, "Air block"); GameRegistry.registerBlock(airBlock, "airBlock"); - // GAS BLOCK - this.gasBlock = (new BlockGas(WarpDriveConfig.i.gasID)).setHardness( - 0.0F).setUnlocalizedName("Gas block"); + this.gasBlock = (new BlockGas(WarpDriveConfig.i.gasID)).setHardness(0.0F).setUnlocalizedName("Gas block"); LanguageRegistry.addName(gasBlock, "Gas block"); GameRegistry.registerBlock(gasBlock, "gasBlock"); - // LASER EMITTER - this.laserBlock = new BlockLaser(WarpDriveConfig.i.laserID, 0, - Material.rock).setHardness(0.5F) - .setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Laser Emitter"); + this.laserBlock = new BlockLaser(WarpDriveConfig.i.laserID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Laser Emitter"); LanguageRegistry.addName(laserBlock, "Laser Emitter"); GameRegistry.registerBlock(laserBlock, "laserBlock"); GameRegistry.registerTileEntity(TileEntityLaser.class, "laserBlock"); - // LASER EMITTER WITH CAMERA - this.laserCamBlock = new BlockLaserCam(WarpDriveConfig.i.laserCamID, 0, - Material.rock).setHardness(0.5F) - .setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Laser Emitter + Camera"); + this.laserCamBlock = new BlockLaserCam(WarpDriveConfig.i.laserCamID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Laser Emitter + Camera"); LanguageRegistry.addName(laserCamBlock, "Laser Emitter + Camera"); GameRegistry.registerBlock(laserCamBlock, "laserCamBlock"); - // CAMERA - this.cameraBlock = new BlockCamera(WarpDriveConfig.i.camID, 0, - Material.rock).setHardness(0.5F) - .setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Camera block"); + this.cameraBlock = new BlockCamera(WarpDriveConfig.i.camID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Camera block"); LanguageRegistry.addName(cameraBlock, "Camera"); GameRegistry.registerBlock(cameraBlock, "cameraBlock"); GameRegistry.registerTileEntity(TileEntityCamera.class, "cameraBlock"); - // MONITOR this.monitorBlock = new BlockMonitor(WarpDriveConfig.i.monitorID) .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Monitor"); + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Monitor"); LanguageRegistry.addName(monitorBlock, "Monitor"); GameRegistry.registerBlock(monitorBlock, "monitorBlock"); - GameRegistry - .registerTileEntity(TileEntityMonitor.class, "monitorBlock"); - + GameRegistry.registerTileEntity(TileEntityMonitor.class, "monitorBlock"); // MINING LASER - this.miningLaserBlock = new BlockMiningLaser( - WarpDriveConfig.i.miningLaserID, 0, Material.rock) + this.miningLaserBlock = new BlockMiningLaser(WarpDriveConfig.i.miningLaserID, 0, Material.rock) .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Mining Laser"); + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Mining Laser"); LanguageRegistry.addName(miningLaserBlock, "Mining Laser"); GameRegistry.registerBlock(miningLaserBlock, "miningLaserBlock"); - GameRegistry.registerTileEntity(TileEntityMiningLaser.class, - "miningLaserBlock"); - + GameRegistry.registerTileEntity(TileEntityMiningLaser.class, "miningLaserBlock"); // PARTICLE BOOSTER - this.boosterBlock = new BlockParticleBooster( - WarpDriveConfig.i.particleBoosterID, 0, Material.rock) + this.boosterBlock = new BlockParticleBooster(WarpDriveConfig.i.particleBoosterID, 0, Material.rock) .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Particle Booster"); + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Particle Booster"); LanguageRegistry.addName(boosterBlock, "Particle Booster"); GameRegistry.registerBlock(boosterBlock, "boosterBlock"); - GameRegistry.registerTileEntity(TileEntityParticleBooster.class, - "boosterBlock"); - + GameRegistry.registerTileEntity(TileEntityParticleBooster.class, "boosterBlock"); // LASER LIFT - this.liftBlock = new BlockLift(WarpDriveConfig.i.liftID, 0, - Material.rock).setHardness(0.5F) - .setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Laser lift"); + this.liftBlock = new BlockLift(WarpDriveConfig.i.liftID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Laser lift"); LanguageRegistry.addName(liftBlock, "Laser lift"); GameRegistry.registerBlock(liftBlock, "liftBlock"); GameRegistry.registerTileEntity(TileEntityLift.class, "liftBlock"); - // IRIDIUM BLOCK this.iridiumBlock = new BlockIridium(WarpDriveConfig.i.iridiumID) - .setHardness(0.8F).setResistance(150 * 4) - .setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone) - .setUnlocalizedName("Block of Iridium"); - + .setHardness(0.8F).setResistance(150 * 4).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Block of Iridium"); LanguageRegistry.addName(iridiumBlock, "Block of Iridium"); GameRegistry.registerBlock(iridiumBlock, "iridiumBlock"); - - // SHIP SCANNER - this.scannerBlock = new BlockShipScanner(WarpDriveConfig.i.shipScannerID, 0, Material.rock) - .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Ship Scanner"); - - LanguageRegistry.addName(scannerBlock, "Ship Scanner"); - GameRegistry.registerBlock(scannerBlock, "scannerBlock"); - GameRegistry.registerTileEntity(TileEntityShipScanner.class, "scannerBlock"); - // CLOAKING DEVICE CORE - this.cloakBlock = new BlockCloakingDeviceCore(WarpDriveConfig.i.cloakCoreID, 0, Material.rock) - .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) - .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Cloaking Device Core"); - - LanguageRegistry.addName(cloakBlock, "Cloaking Device Core"); - GameRegistry.registerBlock(cloakBlock, "cloakBlock"); - GameRegistry.registerTileEntity(TileEntityCloakingDeviceCore.class, "cloakBlock"); - - // CLOAKING DEVICE COIL + // SHIP SCANNER + this.scannerBlock = new BlockShipScanner(WarpDriveConfig.i.shipScannerID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Ship Scanner"); + + LanguageRegistry.addName(scannerBlock, "Ship Scanner"); + GameRegistry.registerBlock(scannerBlock, "scannerBlock"); + GameRegistry.registerTileEntity(TileEntityShipScanner.class, "scannerBlock"); + + // CLOAKING DEVICE CORE + this.cloakBlock = new BlockCloakingDeviceCore(WarpDriveConfig.i.cloakCoreID, 0, Material.rock) + .setHardness(0.5F).setStepSound(Block.soundMetalFootstep) + .setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Cloaking Device Core"); + + LanguageRegistry.addName(cloakBlock, "Cloaking Device Core"); + GameRegistry.registerBlock(cloakBlock, "cloakBlock"); + GameRegistry.registerTileEntity(TileEntityCloakingDeviceCore.class, "cloakBlock"); + + // CLOAKING DEVICE COIL this.cloakCoilBlock = new BlockCloakingCoil(WarpDriveConfig.i.cloakCoilID, 0, Material.rock) .setHardness(0.5F) .setStepSound(Block.soundMetalFootstep) .setCreativeTab(CreativeTabs.tabRedstone) .setUnlocalizedName("Cloaking Device Coil"); - + LanguageRegistry.addName(cloakCoilBlock, "Cloaking Device Coil"); - GameRegistry.registerBlock(cloakCoilBlock, "cloakCoilBlock"); - + GameRegistry.registerBlock(cloakCoilBlock, "cloakCoilBlock"); + proxy.registerEntities(); ForgeChunkManager.setForcedChunkLoadingCallback(instance, instance); spaceWorldGenerator = new SpaceWorldGenerator(); @@ -292,143 +246,95 @@ public class WarpDrive implements LoadingCallback { registerHyperSpaceDimension(); MinecraftForge.EVENT_BUS.register(new SpaceEventHandler()); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { - MinecraftForge.EVENT_BUS.register(new CameraOverlay(Minecraft - .getMinecraft())); + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) + { + MinecraftForge.EVENT_BUS.register(new CameraOverlay(Minecraft.getMinecraft())); } } @PostInit - public void postInit(FMLPostInitializationEvent event) { + public void postInit(FMLPostInitializationEvent event) + { space = DimensionManager.getWorld(spaceDimID); hyperSpace = DimensionManager.getWorld(hyperSpaceDimID); - GameRegistry.addRecipe(new ItemStack(warpCore), "ici", "cmc", "ici", - 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', - WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', - WarpDriveConfig.i.getIC2Item("advancedCircuit")); - - GameRegistry.addRecipe(new ItemStack(protocolBlock), "iic", "imi", - "cii", 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', - WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', - WarpDriveConfig.i.getIC2Item("advancedCircuit")); - + 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit")); + GameRegistry.addRecipe(new ItemStack(protocolBlock), "iic", "imi", "cii", + 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit")); GameRegistry.addRecipe(new ItemStack(radarBlock), "ifi", "imi", "imi", - 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', - WarpDriveConfig.i.getIC2Item("advancedMachine"), 'f', - WarpDriveConfig.i.getIC2Item("frequencyTransmitter")); - - GameRegistry.addRecipe(new ItemStack(isolationBlock), "iii", "idi", - "iii", 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', - WarpDriveConfig.i.getIC2Item("advancedMachine"), 'd', - Block.blockDiamond); - + 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'f', WarpDriveConfig.i.getIC2Item("frequencyTransmitter")); + GameRegistry.addRecipe(new ItemStack(isolationBlock), "iii", "idi", "iii", + 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'd', Block.blockDiamond); GameRegistry.addRecipe(new ItemStack(airgenBlock), "lcl", "lml", "lll", - 'l', Block.leaves, 'm', - WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', - WarpDriveConfig.i.getIC2Item("advancedCircuit")); - + 'l', Block.leaves, 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit")); GameRegistry.addRecipe(new ItemStack(laserBlock), "sss", "ama", "aaa", - 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'a', - WarpDriveConfig.i.getIC2Item("advancedAlloy"), 's', - WarpDriveConfig.i.getIC2Item("advancedCircuit")); - - GameRegistry.addRecipe(new ItemStack(miningLaserBlock), "aaa", "ama", - "ccc", 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), - 'a', WarpDriveConfig.i.getIC2Item("advancedAlloy"), 'm', - WarpDriveConfig.i.getIC2Item("miner")); - - GameRegistry.addRecipe(new ItemStack(boosterBlock), "afc", "ama", - "cfa", 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), - 'a', WarpDriveConfig.i.getIC2Item("advancedAlloy"), 'f', - WarpDriveConfig.i.getIC2Item("glassFiberCableItem"), 'm', - WarpDriveConfig.i.getIC2Item("mfeUnit")); - + 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'a', WarpDriveConfig.i.getIC2Item("advancedAlloy"), 's', WarpDriveConfig.i.getIC2Item("advancedCircuit")); + GameRegistry.addRecipe(new ItemStack(miningLaserBlock), "aaa", "ama", "ccc", + 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'a', WarpDriveConfig.i.getIC2Item("advancedAlloy"), 'm', WarpDriveConfig.i.getIC2Item("miner")); + GameRegistry.addRecipe(new ItemStack(boosterBlock), "afc", "ama", "cfa", + 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'a', WarpDriveConfig.i.getIC2Item("advancedAlloy"), 'f', WarpDriveConfig.i.getIC2Item("glassFiberCableItem"), 'm', WarpDriveConfig.i.getIC2Item("mfeUnit")); GameRegistry.addRecipe(new ItemStack(liftBlock), "aca", "ama", "a#a", - 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'a', - WarpDriveConfig.i.getIC2Item("advancedAlloy"), 'm', - WarpDriveConfig.i.getIC2Item("magnetizer")); + 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'a', WarpDriveConfig.i.getIC2Item("advancedAlloy"), 'm', WarpDriveConfig.i.getIC2Item("magnetizer")); + GameRegistry.addRecipe(new ItemStack(iridiumBlock), "iii", "iii", "iii", + 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate")); + GameRegistry.addShapelessRecipe(new ItemStack(WarpDriveConfig.i.getIC2Item("iridiumPlate").getItem(), 9), new ItemStack(iridiumBlock)); - GameRegistry.addRecipe(new ItemStack(iridiumBlock), "iii", "iii", - "iii", 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate")); - - GameRegistry.addShapelessRecipe(new ItemStack(WarpDriveConfig.i - .getIC2Item("iridiumPlate").getItem(), 9), new ItemStack( - iridiumBlock)); - - GameRegistry.addRecipe(new ItemStack(laserCamBlock), "imi", "cec", - "#k#", 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', - WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', - WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'e', - laserBlock, 'k', cameraBlock); - + GameRegistry.addRecipe(new ItemStack(laserCamBlock), "imi", "cec", "#k#", + 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'e', laserBlock, 'k', cameraBlock); GameRegistry.addRecipe(new ItemStack(cameraBlock), "cgc", "gmg", "cgc", - 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', - WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'g', - Block.glass); - - GameRegistry.addRecipe(new ItemStack(monitorBlock), "gcg", "gmg", - "ggg", 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), - 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'g', - Block.glass); - + 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'g', Block.glass); + GameRegistry.addRecipe(new ItemStack(monitorBlock), "gcg", "gmg", "ggg", + 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'g', Block.glass); GameRegistry.addRecipe(new ItemStack(scannerBlock), "sgs", "mma", "amm", - 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'a', - WarpDriveConfig.i.getIC2Item("advancedAlloy"), 's', - WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'g', Block.glass); - - GameRegistry.addRecipe(new ItemStack(cloakBlock), - "imi", - "mcm", - "imi", + 'm', WarpDriveConfig.i.getIC2Item("advancedMachine"), 'a', WarpDriveConfig.i.getIC2Item("advancedAlloy"), 's', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'g', Block.glass); + GameRegistry.addRecipe(new ItemStack(cloakBlock), "imi", "mcm", "imi", 'i', iridiumBlock, 'c', cloakCoilBlock, 'm', WarpDriveConfig.i.getIC2Item("advancedMachine")); - - GameRegistry.addRecipe(new ItemStack(cloakCoilBlock), - "iai", - "aca", - "iai", + GameRegistry.addRecipe(new ItemStack(cloakCoilBlock), "iai", "aca", "iai", 'i', WarpDriveConfig.i.getIC2Item("iridiumPlate"), 'c', WarpDriveConfig.i.getIC2Item("advancedCircuit"), 'a', WarpDriveConfig.i.getIC2Item("advancedAlloy")); - registry = new WarpCoresRegistry(); - - jumpGates = new JumpGatesRegistry(); - cams = new CamRegistry(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) + { + jumpGates = new JumpGatesRegistry(); + } + else + { + cams = new CamRegistry(); + } } - private void registerSpaceDimension() { - spaceBiome = (new BiomeSpace(23)).setColor(0).setDisableRain() - .setBiomeName("Space"); + private void registerSpaceDimension() + { + spaceBiome = (new BiomeSpace(23)).setColor(0).setDisableRain().setBiomeName("Space"); this.spaceProviderID = 14; - DimensionManager.registerProviderType(this.spaceProviderID, - SpaceProvider.class, true); + DimensionManager.registerProviderType(this.spaceProviderID, SpaceProvider.class, true); this.spaceDimID = DimensionManager.getNextFreeDimId(); - DimensionManager.registerDimension(this.spaceDimID, - this.spaceProviderID); + DimensionManager.registerDimension(this.spaceDimID, this.spaceProviderID); } - private void registerHyperSpaceDimension() { + private void registerHyperSpaceDimension() + { this.hyperSpaceProviderID = 15; - DimensionManager.registerProviderType(this.hyperSpaceProviderID, - HyperSpaceProvider.class, true); + DimensionManager.registerProviderType(this.hyperSpaceProviderID, HyperSpaceProvider.class, true); this.hyperSpaceDimID = DimensionManager.getNextFreeDimId(); - DimensionManager.registerDimension(this.hyperSpaceDimID, - this.hyperSpaceProviderID); + DimensionManager.registerDimension(this.hyperSpaceDimID, this.hyperSpaceProviderID); } - @EventHandler - public void serverLoad(FMLServerStartingEvent event) { + @ServerStarting + public void serverLoad(FMLServerStartingEvent event) + { cloaks = new CloakManager(); MinecraftForge.EVENT_BUS.register(new CloakChunkWatcher()); - event.registerServerCommand(new GenerateCommand()); event.registerServerCommand(new SpaceTpCommand()); event.registerServerCommand(new InvisibleCommand()); } @Override - public void ticketsLoaded(List<Ticket> tickets, World world) { - for (Ticket ticket : tickets) { + public void ticketsLoaded(List<Ticket> tickets, World world) + { + for (Ticket ticket : tickets) + { ForgeChunkManager.releaseTicket(ticket); } } diff --git a/src/cr0s/WarpDrive/WarpDriveConfig.java b/src/cr0s/WarpDrive/WarpDriveConfig.java index 88b528d3..50f7d2fd 100644 --- a/src/cr0s/WarpDrive/WarpDriveConfig.java +++ b/src/cr0s/WarpDrive/WarpDriveConfig.java @@ -7,7 +7,6 @@ import java.util.HashSet; import java.util.Set; import java.util.Random; import java.lang.reflect.*; - import cpw.mods.fml.common.Loader; import net.minecraftforge.common.Configuration; import net.minecraft.block.Block; @@ -21,67 +20,67 @@ public class WarpDriveConfig private Configuration config; public int coreID, controllerID, radarID, isolationID, airID, airgenID, gasID, laserID, miningLaserID, particleBoosterID, liftID, laserCamID, camID, monitorID, iridiumID, shipScannerID, cloakCoreID, cloakCoilID; // - public boolean isGregLoaded = false, isAELoaded = false, isAdvSolPanelLoaded = false, isASLoaded = false, isAEExtraLoaded = false, isICBMLoaded = false, isMFFSLoaded = false, isGraviSuiteLoaded = false; + public boolean isGregLoaded = false, isAELoaded = false, isAEExtraLoaded = false, isAdvSolPanelLoaded = false, isASLoaded = false, isICBMLoaded = false, isMFFSLoaded = false, isGraviSuiteLoaded = false; // public int[] IC2_Air; - public int CC_Computer = 0, CC_peripheral = 0, CCT_Turtle = 0, CCT_Upgraded = 0, CCT_Advanced = 0, GT_Ores = 0, GT_Granite = 0, GT_Machine = 0, ASP = 0, AS_Turbine = 0, ICBM_Machine = 0, ICBM_Missile = 0, MFFS_Field = 0; + public int CC_Computer = 0, CC_peripheral = 0, CCT_Turtle = 0, CCT_Upgraded = 0, CCT_Advanced = 0, GT_Ores = 0, GT_Granite = 0, GT_Machine = 0, ASP = 0, AS_Turbine = 0, ICBM_Machine = 0, ICBM_Missile = 0, ICBM_Explosive = 0, MFFS_Field = 0; public Set<Integer> SpaceHelmets, Jetpacks, MinerOres, scannerIgnoreBlocks; private Class<?> AEBlocks; private Class<?> AEMaterials; private Class<?> AEItems; - public ArrayList<int[]> CommonWorldGenOres; public Item AEExtraFDI; + public ArrayList<int[]> CommonWorldGenOres; // Mod config - // Warp Core - public int WC_MAX_ENERGY_VALUE = 100000000; - public int WC_ENERGY_PER_BLOCK_MODE1 = 10; // eU - public int WC_ENERGY_PER_DISTANCE_MODE1 = 100; // eU - public int WC_ENERGY_PER_BLOCK_MODE2 = 1000; // eU - public int WC_ENERGY_PER_DISTANCE_MODE2 = 1000; // eU - public int WC_ENERGY_PER_ENTITY_TO_SPACE = 1000000; // eU - public int WC_MAX_JUMP_DISTANCE = 128; // Maximum jump length value - public int WC_MAX_SHIP_VOLUME_ON_SURFACE = 15000; // Maximum ship mass to jump on earth (15k blocks) - public int WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE = 500; // Minimum ship volume value for - public int WC_MAX_SHIP_SIDE = 100; - public int WC_COOLDOWN_INTERVAL_SECONDS = 4; - public int WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS = 10; - public int WC_ISOLATION_UPDATE_INTARVAL_SECONDS = 10; + // Warp Core + public int WC_MAX_ENERGY_VALUE = 100000000; + public int WC_ENERGY_PER_BLOCK_MODE1 = 10; // eU + public int WC_ENERGY_PER_DISTANCE_MODE1 = 100; // eU + public int WC_ENERGY_PER_BLOCK_MODE2 = 1000; // eU + public int WC_ENERGY_PER_DISTANCE_MODE2 = 1000; // eU + public int WC_ENERGY_PER_ENTITY_TO_SPACE = 1000000; // eU + public int WC_MAX_JUMP_DISTANCE = 128; // Maximum jump length value + public int WC_MAX_SHIP_VOLUME_ON_SURFACE = 15000; // Maximum ship volume to jump on earth + public int WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE = 500; // Minimum ship volume value for hyperspace travel + public int WC_MAX_SHIP_SIDE = 199; //miaximum ship length - 1 + public int WC_COOLDOWN_INTERVAL_SECONDS = 4; + public int WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS = 10; + public int WC_ISOLATION_UPDATE_INTARVAL_SECONDS = 10; - // Warp Radar - public int WR_MAX_ENERGY_VALUE = 100000000; // 100kk eU - - // Particle Booster - public int PB_MAX_ENERGY_VALUE = 100000; - - // Mining Laser - public int ML_MAX_BOOSTERS_NUMBER = 1; - public int ML_SCAN_DELAY = 20 * 5; - public int ML_MINE_DELAY = 10; - public int ML_EU_PER_LAYER_SPACE = 500; - public int ML_EU_PER_LAYER_EARTH = 5000; - - // Laser Emitter - public int LE_MAX_BOOSTERS_NUMBER = 10; - public int LE_MAX_LASER_ENERGY = 4000000; - public int LE_EMIT_DELAY_TICKS = 20 * 3; - public int LE_EMIT_SCAN_DELAY_TICKS = 10; - public double LE_COLLECT_ENERGY_MULTIPLIER = 0.60D; - public int LE_BEAM_LENGTH_PER_ENERGY_DIVIDER = 5000; - public int LE_ENTITY_HIT_SET_ON_FIRE_TIME = 100; - public int LE_ENTITY_HIT_DAMAGE_PER_ENERGY_DIVIDER = 10000; - public int LE_ENTITY_HIT_EXPLOSION_LASER_ENERGY = 1000000; - public int LE_BLOCK_HIT_CONSUME_ENERGY = 70000; - public int LE_BLOCK_HIT_CONSUME_ENERGY_PER_BLOCK_RESISTANCE = 1000; - public int LE_BLOCK_HIT_CONSUME_ENERGY_PER_DISTANCE = 10; - - // Cloaking device core - public int CD_MAX_CLOAKING_FIELD_SIDE = 100; - public int CD_ENERGY_PER_BLOCK_TIER1 = 1000; - public int CD_ENERGY_PER_BLOCK_TIER2 = 5000; - public int CD_FIELD_REFRESH_INTERVAL_SECONDS = 10; - public int CD_COIL_CAPTURE_BLOCKS = 5; - + // Warp Radar + public int WR_MAX_ENERGY_VALUE = 100000000; // 100kk eU + + // Particle Booster + public int PB_MAX_ENERGY_VALUE = 100000; + + // Mining Laser + public int ML_MAX_BOOSTERS_NUMBER = 1; + public int ML_SCAN_DELAY = 20 * 5; + public int ML_MINE_DELAY = 10; + public int ML_EU_PER_LAYER_SPACE = 500; + public int ML_EU_PER_LAYER_EARTH = 5000; + + // Laser Emitter + public int LE_MAX_BOOSTERS_NUMBER = 10; + public int LE_MAX_LASER_ENERGY = 4000000; + public int LE_EMIT_DELAY_TICKS = 20 * 3; + public int LE_EMIT_SCAN_DELAY_TICKS = 10; + public double LE_COLLECT_ENERGY_MULTIPLIER = 0.60D; + public int LE_BEAM_LENGTH_PER_ENERGY_DIVIDER = 5000; + public int LE_ENTITY_HIT_SET_ON_FIRE_TIME = 100; + public int LE_ENTITY_HIT_DAMAGE_PER_ENERGY_DIVIDER = 10000; + public int LE_ENTITY_HIT_EXPLOSION_LASER_ENERGY = 1000000; + public int LE_BLOCK_HIT_CONSUME_ENERGY = 70000; + public int LE_BLOCK_HIT_CONSUME_ENERGY_PER_BLOCK_RESISTANCE = 1000; + public int LE_BLOCK_HIT_CONSUME_ENERGY_PER_DISTANCE = 10; + + // Cloaking device core + public int CD_MAX_CLOAKING_FIELD_SIDE = 100; + public int CD_ENERGY_PER_BLOCK_TIER1 = 1000; + public int CD_ENERGY_PER_BLOCK_TIER2 = 5000; + public int CD_FIELD_REFRESH_INTERVAL_SECONDS = 10; + public int CD_COIL_CAPTURE_BLOCKS = 5; + private WarpDriveConfig() {} public ItemStack getIC2Item(String id) @@ -141,30 +140,31 @@ public class WarpDriveConfig i.config = config; } - public void loadWarpDriveConfig() { + public void loadWarpDriveConfig() + { // Warp Core WC_MAX_ENERGY_VALUE = config.get("WarpCore", "max_energy_value", 100000000).getInt(); WC_ENERGY_PER_BLOCK_MODE1 = config.get("WarpCore", "energy_per_block_mode1", 10).getInt(); WC_ENERGY_PER_DISTANCE_MODE1 = config.get("WarpCore", "energy_per_distance_mode1", 100).getInt(); - WC_ENERGY_PER_DISTANCE_MODE2 = config.get("WarpCore", "energy_per_distance_mode2", 1000).getInt(); - WC_ENERGY_PER_BLOCK_MODE2 = config.get("WarpCore", "energy_per_block_mode2", 1000).getInt(); - WC_ENERGY_PER_ENTITY_TO_SPACE = config.get("WarpCore", "energy_per_entity_to_space", 1000000).getInt(); - WC_MAX_JUMP_DISTANCE = config.get("WarpCore", "max_jump_distance", 128).getInt(); - WC_MAX_SHIP_VOLUME_ON_SURFACE = config.get("WarpCore", "max_ship_volume_on_surface", 15000).getInt(); // Maximum ship mass to jump on earth (15k blocks) - WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE = config.get("WarpCore", "min_ship_volume_for_hyperspace", 500).getInt(); // Minimum ship volume value for hyper space - WC_MAX_SHIP_SIDE = config.get("WarpCore", "max_ship_side", 100).getInt(); - - WC_COOLDOWN_INTERVAL_SECONDS = config.get("WarpCore", "cooldown_interval_seconds", 4).getInt(); - WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS = config.get("WarpCore", "cores_registry_update_interval", 10).getInt(); - WC_ISOLATION_UPDATE_INTARVAL_SECONDS = config.get("WarpCore", "isolation_update_interval", 10).getInt(); - - // Warp Radar - WR_MAX_ENERGY_VALUE = config.get("WarpRadar", "max_energy_value", 100000000).getInt(); - - // Particle Booster - PB_MAX_ENERGY_VALUE = config.get("ParticleBooster", "max_energy_value", 100000).getInt(); - - // Mining Laser + WC_ENERGY_PER_DISTANCE_MODE2 = config.get("WarpCore", "energy_per_distance_mode2", 1000).getInt(); + WC_ENERGY_PER_BLOCK_MODE2 = config.get("WarpCore", "energy_per_block_mode2", 1000).getInt(); + WC_ENERGY_PER_ENTITY_TO_SPACE = config.get("WarpCore", "energy_ped_entity_to_space", 1000000).getInt(); + WC_MAX_JUMP_DISTANCE = config.get("WarpCore", "max_jump_distance", 128).getInt(); + WC_MAX_SHIP_VOLUME_ON_SURFACE = config.get("WarpCore", "max_ship_volume_on_surface", 15000).getInt(); // Maximum ship mass to jump on earth (15k blocks) + WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE = config.get("WarpCore", "min_ship_volume_for_hyperspace", 500).getInt(); ; // Minimum ship volume value for hyper space + WC_MAX_SHIP_SIDE = config.get("WarpCore", "max_ship_side", 100).getInt(); + + WC_COOLDOWN_INTERVAL_SECONDS = config.get("WarpCore", "cooldown_interval_seconds", 4).getInt(); + WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS = config.get("WarpCore", "cores_registry_update_interval", 10).getInt(); + WC_ISOLATION_UPDATE_INTARVAL_SECONDS = config.get("WarpCore", "isolation_update_interval", 10).getInt(); + + // Warp Radar + WR_MAX_ENERGY_VALUE = config.get("WarpRadar", "max_energy_value", 100000000).getInt(); + + // Particle Booster + PB_MAX_ENERGY_VALUE = config.get("ParticleBooster", "max_energy_value", 100000).getInt(); + + // Mining Laser ML_MAX_BOOSTERS_NUMBER = config.get("MiningLaser", "max_boosters_number", 1).getInt(); ML_SCAN_DELAY = 20 * config.get("MiningLaser", "scan_delay_seconds", 5).getInt(); ML_MINE_DELAY = config.get("MiningLaser", "mine_delay_ticks", 10).getInt(); @@ -229,42 +229,34 @@ public class WarpDriveConfig shipScannerID = config.getBlock("shipscanner", 516).getInt(); cloakCoreID = config.getBlock("cloakcore", 517).getInt(); cloakCoilID = config.getBlock("cloakcoil", 518).getInt(); - LoadIC2(); LoadCC(); - isGregLoaded = Loader.isModLoaded("gregtech_addon"); if (isGregLoaded) LoadGT(); - isAELoaded = Loader.isModLoaded("AppliedEnergistics"); if (isAELoaded) LoadAE(); - isAEExtraLoaded = Loader.isModLoaded("extracells"); if (isAEExtraLoaded) - LoadAEExtra(); - + LoadAEExtra(); isAdvSolPanelLoaded = Loader.isModLoaded("AdvancedSolarPanel"); if (isAdvSolPanelLoaded) LoadASP(); - isASLoaded = Loader.isModLoaded("AtomicScience"); if (isASLoaded) LoadAS(); - isICBMLoaded = Loader.isModLoaded("ICBM|Explosion"); if (isICBMLoaded) LoadICBM(); - isMFFSLoaded = Loader.isModLoaded("MFFS"); if (isMFFSLoaded) LoadMFFS(); - isGraviSuiteLoaded = Loader.isModLoaded("GraviSuite"); if (isGraviSuiteLoaded) LoadGS(); // + MinerOres.add(iridiumID); MinerOres.add(Block.oreNetherQuartz.blockID); for (int[] t : CommonWorldGenOres) MinerOres.add(t[0]); @@ -276,6 +268,7 @@ public class WarpDriveConfig MinerOres.add(Block.web.blockID); MinerOres.add(Block.fence.blockID); MinerOres.add(Block.torchWood.blockID); + MinerOres.add(Block.glowStone.blockID); // Ignore WarpDrive blocks (which potentially will be duplicated by cheaters using ship scan/deploy) scannerIgnoreBlocks.add(coreID); @@ -287,7 +280,7 @@ public class WarpDriveConfig scannerIgnoreBlocks.add(Items.getItem("cesuUnit").itemID); scannerIgnoreBlocks.add(Items.getItem("batBox").itemID); - // Do not scan ores and valuables + // Do not deploy ores and valuables for (int[] t : CommonWorldGenOres) // each element of this set is pair [id, meta] scannerIgnoreBlocks.add(t[0]); // we adding ID only @@ -303,19 +296,10 @@ public class WarpDriveConfig Jetpacks.add(Items.getItem("jetpack").itemID); Jetpacks.add(Items.getItem("electricJetpack").itemID); IC2_Air = new int[] {Items.getItem("airCell").itemID, Items.getItem("airCell").getItemDamage()}; - - if (Items.getItem("uraniumOre") != null) { - CommonWorldGenOres.add(new int[] {Items.getItem("uraniumOre").itemID, Items.getItem("uraniumOre").getItemDamage()}); - } - - if (Items.getItem("copperOre") != null) { - CommonWorldGenOres.add(new int[] {Items.getItem("copperOre").itemID, Items.getItem("copperOre").getItemDamage()}); - } - - if (Items.getItem("tinOre") != null) { - CommonWorldGenOres.add(new int[] {Items.getItem("tinOre").itemID, Items.getItem("tinOre").getItemDamage()}); - } - + CommonWorldGenOres.add(new int[] {Items.getItem("uraniumOre").itemID, Items.getItem("uraniumOre").getItemDamage()}); + CommonWorldGenOres.add(new int[] {Items.getItem("copperOre").itemID, Items.getItem("copperOre").getItemDamage()}); + CommonWorldGenOres.add(new int[] {Items.getItem("tinOre").itemID, Items.getItem("tinOre").getItemDamage()}); + CommonWorldGenOres.add(new int[] {Items.getItem("leadOre").itemID, Items.getItem("leadOre").getItemDamage()}); MinerOres.add(Items.getItem("rubberWood").itemID); AEExtraFDI = Items.getItem("FluidCell").getItem(); } @@ -331,6 +315,10 @@ public class WarpDriveConfig CCT_Turtle = z.getField("turtleBlockID").getInt(null); CCT_Upgraded = z.getField("turtleUpgradedBlockID").getInt(null); CCT_Advanced = z.getField("turtleAdvancedBlockID").getInt(null); + scannerIgnoreBlocks.add(CC_Computer); + scannerIgnoreBlocks.add(CCT_Turtle); + scannerIgnoreBlocks.add(CCT_Upgraded); + scannerIgnoreBlocks.add(CCT_Advanced); } catch (Exception e) { @@ -343,8 +331,7 @@ public class WarpDriveConfig { try { - Class<?> z = Class.forName("gregtechmod.GT_Mod"); - int[] t = (int[])z.getField("sBlockIDs").get(null); + int[] t = (int[])Class.forName("gregtechmod.GT_Mod").getField("sBlockIDs").get(null); GT_Machine = t[1]; GT_Ores = t[2]; // meta 1-15 = ores GT_Granite = t[5]; // 0 - black, 1 - black cobble, 8 - red, 9 - red cobble @@ -390,8 +377,8 @@ public class WarpDriveConfig e.printStackTrace(); isAEExtraLoaded = false; } - } - + } + private void LoadASP() { try @@ -414,13 +401,19 @@ public class WarpDriveConfig { try { +/* Class<?> z = Class.forName("atomicscience.AtomicScience"); + CommonWorldGenOres.add(new int[] {((Block)z.getField("blockUraniumOre").get(null)).blockID, 0}); + AS_Turbine = ((Block)z.getField("blockElectricTurbine").get(null)).blockID; +*/ + Class<?> z = Class.forName("atomicscience.ZhuYaoAS"); CommonWorldGenOres.add(new int[] {((Block)z.getField("bHeOre").get(null)).blockID, 0}); AS_Turbine = ((Block)z.getField("bWoLun").get(null)).blockID; } catch (Exception e) { System.out.println("WarpDriveConfig Error loading AS classes"); + e.printStackTrace(); isASLoaded = false; } } @@ -434,6 +427,8 @@ public class WarpDriveConfig z = Class.forName("icbm.explosion.ICBMExplosion"); ICBM_Machine = ((Block)z.getField("blockMachine").get(null)).blockID; ICBM_Missile = ((Item)z.getField("itemMissile").get(null)).itemID; + ICBM_Explosive = ((Block)z.getField("blockExplosive").get(null)).blockID; + scannerIgnoreBlocks.add(ICBM_Explosive); } catch (Exception e) { diff --git a/src/shipmod/BlockID.java b/src/shipmod/BlockID.java deleted file mode 100644 index ed270113..00000000 --- a/src/shipmod/BlockID.java +++ /dev/null @@ -1,195 +0,0 @@ -// $Id$ -/* - * WorldEdit - * Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -package shipmod; - -/** - * List of block IDs. - * - * @author sk89q - */ -public final class BlockID { - public static final int AIR = 0; - public static final int STONE = 1; - public static final int GRASS = 2; - public static final int DIRT = 3; - public static final int COBBLESTONE = 4; - public static final int WOOD = 5; - public static final int SAPLING = 6; - public static final int BEDROCK = 7; - public static final int WATER = 8; - public static final int STATIONARY_WATER = 9; - public static final int LAVA = 10; - public static final int STATIONARY_LAVA = 11; - public static final int SAND = 12; - public static final int GRAVEL = 13; - public static final int GOLD_ORE = 14; - public static final int IRON_ORE = 15; - public static final int COAL_ORE = 16; - public static final int LOG = 17; - public static final int LEAVES = 18; - public static final int SPONGE = 19; - public static final int GLASS = 20; - public static final int LAPIS_LAZULI_ORE = 21; - public static final int LAPIS_LAZULI_BLOCK = 22; - public static final int DISPENSER = 23; - public static final int SANDSTONE = 24; - public static final int NOTE_BLOCK = 25; - public static final int BED = 26; - public static final int POWERED_RAIL = 27; - public static final int DETECTOR_RAIL = 28; - public static final int PISTON_STICKY_BASE = 29; - public static final int WEB = 30; - public static final int LONG_GRASS = 31; - public static final int DEAD_BUSH = 32; - public static final int PISTON_BASE = 33; - public static final int PISTON_EXTENSION = 34; - public static final int CLOTH = 35; - public static final int PISTON_MOVING_PIECE = 36; - public static final int YELLOW_FLOWER = 37; - public static final int RED_FLOWER = 38; - public static final int BROWN_MUSHROOM = 39; - public static final int RED_MUSHROOM = 40; - public static final int GOLD_BLOCK = 41; - public static final int IRON_BLOCK = 42; - public static final int DOUBLE_STEP = 43; - public static final int STEP = 44; - public static final int BRICK = 45; - public static final int TNT = 46; - public static final int BOOKCASE = 47; - public static final int MOSSY_COBBLESTONE = 48; - public static final int OBSIDIAN = 49; - public static final int TORCH = 50; - public static final int FIRE = 51; - public static final int MOB_SPAWNER = 52; - public static final int WOODEN_STAIRS = 53; - public static final int OAK_WOOD_STAIRS = 53; - public static final int CHEST = 54; - public static final int REDSTONE_WIRE = 55; - public static final int DIAMOND_ORE = 56; - public static final int DIAMOND_BLOCK = 57; - public static final int WORKBENCH = 58; - public static final int CROPS = 59; - public static final int SOIL = 60; - public static final int FURNACE = 61; - public static final int BURNING_FURNACE = 62; - public static final int SIGN_POST = 63; - public static final int WOODEN_DOOR = 64; - public static final int LADDER = 65; - public static final int MINECART_TRACKS = 66; - public static final int COBBLESTONE_STAIRS = 67; - public static final int WALL_SIGN = 68; - public static final int LEVER = 69; - public static final int STONE_PRESSURE_PLATE = 70; - public static final int IRON_DOOR = 71; - public static final int WOODEN_PRESSURE_PLATE = 72; - public static final int REDSTONE_ORE = 73; - public static final int GLOWING_REDSTONE_ORE = 74; - public static final int REDSTONE_TORCH_OFF = 75; - public static final int REDSTONE_TORCH_ON = 76; - public static final int STONE_BUTTON = 77; - public static final int SNOW = 78; - public static final int ICE = 79; - public static final int SNOW_BLOCK = 80; - public static final int CACTUS = 81; - public static final int CLAY = 82; - public static final int REED = 83; - public static final int JUKEBOX = 84; - public static final int FENCE = 85; - public static final int PUMPKIN = 86; - public static final int NETHERSTONE = 87; - public static final int NETHERRACK = 87; - public static final int SLOW_SAND = 88; - public static final int LIGHTSTONE = 89; - public static final int PORTAL = 90; - public static final int JACKOLANTERN = 91; - public static final int CAKE_BLOCK = 92; - public static final int REDSTONE_REPEATER_OFF = 93; - public static final int REDSTONE_REPEATER_ON = 94; - public static final int LOCKED_CHEST = 95; - public static final int TRAP_DOOR = 96; - public static final int SILVERFISH_BLOCK = 97; - public static final int STONE_BRICK = 98; - public static final int BROWN_MUSHROOM_CAP = 99; - public static final int RED_MUSHROOM_CAP = 100; - public static final int IRON_BARS = 101; - public static final int GLASS_PANE = 102; - public static final int MELON_BLOCK = 103; - public static final int PUMPKIN_STEM = 104; - public static final int MELON_STEM = 105; - public static final int VINE = 106; - public static final int FENCE_GATE = 107; - public static final int BRICK_STAIRS = 108; - public static final int STONE_BRICK_STAIRS = 109; - public static final int MYCELIUM = 110; - public static final int LILY_PAD = 111; - public static final int NETHER_BRICK = 112; - public static final int NETHER_BRICK_FENCE = 113; - public static final int NETHER_BRICK_STAIRS = 114; - public static final int NETHER_WART = 115; - public static final int ENCHANTMENT_TABLE = 116; - public static final int BREWING_STAND = 117; - public static final int CAULDRON = 118; - public static final int END_PORTAL = 119; - public static final int END_PORTAL_FRAME = 120; - public static final int END_STONE = 121; - public static final int DRAGON_EGG = 122; - public static final int REDSTONE_LAMP_OFF = 123; - public static final int REDSTONE_LAMP_ON = 124; - public static final int DOUBLE_WOODEN_STEP = 125; - public static final int WOODEN_STEP = 126; - public static final int COCOA_PLANT = 127; - public static final int SANDSTONE_STAIRS = 128; - public static final int EMERALD_ORE = 129; - public static final int ENDER_CHEST = 130; - public static final int TRIPWIRE_HOOK = 131; - public static final int TRIPWIRE = 132; - public static final int EMERALD_BLOCK = 133; - public static final int SPRUCE_WOOD_STAIRS = 134; - public static final int BIRCH_WOOD_STAIRS = 135; - public static final int JUNGLE_WOOD_STAIRS = 136; - public static final int COMMAND_BLOCK = 137; - public static final int BEACON = 138; - public static final int COBBLESTONE_WALL = 139; - public static final int FLOWER_POT = 140; - public static final int CARROTS = 141; - public static final int POTATOES = 142; - public static final int WOODEN_BUTTON = 143; - public static final int HEAD = 144; - public static final int ANVIL = 145; - public static final int TRAPPED_CHEST = 146; - public static final int PRESSURE_PLATE_LIGHT = 147; - public static final int PRESSURE_PLATE_HEAVY = 148; - public static final int COMPARATOR_OFF = 149; - public static final int COMPARATOR_ON = 150; - public static final int DAYLIGHT_SENSOR = 151; - public static final int REDSTONE_BLOCK = 152; - public static final int QUARTZ_ORE = 153; - public static final int HOPPER = 154; - public static final int QUARTZ_BLOCK = 155; - public static final int QUARTZ_STAIRS = 156; - public static final int ACTIVATOR_RAIL = 157; - public static final int DROPPER = 158; - public static final int STAINED_CLAY = 159; - public static final int HAY_BLOCK = 170; - public static final int CARPET = 171; - public static final int HARDENED_CLAY = 172; - public static final int COAL_BLOCK = 173; - -} diff --git a/src/shipmod/BlockMetaRotation.java b/src/shipmod/BlockMetaRotation.java deleted file mode 100644 index 2c07eed3..00000000 --- a/src/shipmod/BlockMetaRotation.java +++ /dev/null @@ -1,41 +0,0 @@ -package shipmod; - -public class BlockMetaRotation -{ - public final int blockID; - public final int[] metaRotation; - private int bitMask; - - protected BlockMetaRotation(int blockid, int[] metarotation, int bitmask) - { - if (metarotation.length != 4) - { - throw new IllegalArgumentException("MetaRotation int array must have length 4"); - } - else - { - this.blockID = blockid; - this.metaRotation = metarotation; - this.bitMask = bitmask; - } - } - - public int getRotatedMeta(int currentmeta, int rotate) - { - for (int i = 0; i < this.metaRotation.length; ++i) - { - if (this.metaRotation[i] == (currentmeta & this.bitMask)) - { - int mr = currentmeta & ~this.bitMask | this.metaRotation[wrapRotationIndex(i + rotate)] & this.bitMask; - return mr; - } - } - - return currentmeta; - } - - public static int wrapRotationIndex(int i) - { - return i & 3; - } -} diff --git a/src/shipmod/ClientProxy.java b/src/shipmod/ClientProxy.java deleted file mode 100644 index 16249717..00000000 --- a/src/shipmod/ClientProxy.java +++ /dev/null @@ -1,37 +0,0 @@ -package shipmod; - -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.KeyBindingRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.registry.LanguageRegistry; -import net.minecraft.client.settings.KeyBinding; -import shipmod.control.ShipKeyHandler; -import shipmod.entity.EntityShip; -import shipmod.render.RenderShip; - -public class ClientProxy extends CommonProxy -{ - private ShipKeyHandler shipKeyHandler; - - public void registerTickHandlers() - { - super.registerTickHandlers(); - this.shipKeyHandler = new ShipKeyHandler(new KeyBinding("key.shipmod.up", 45), new KeyBinding("key.shipmod.down", 44), new KeyBinding("key.shipmod.brake", 46), new KeyBinding("key.shipmod.align", 13)); - KeyBindingRegistry.registerKeyBinding(this.shipKeyHandler); - } - - public void registerLocalization() - { - LanguageRegistry lang = LanguageRegistry.instance(); - lang.addStringLocalization(ShipMod.blockMarkShip.getUnlocalizedName().concat(".name"), "en_US", "Shuttle Controller"); - lang.addStringLocalization(this.shipKeyHandler.kbUp.keyDescription, "en_US", "Ascent Ship"); - lang.addStringLocalization(this.shipKeyHandler.kbDown.keyDescription, "en_US", "Descent Ship"); - lang.addStringLocalization(this.shipKeyHandler.kbBrake.keyDescription, "en_US", "Brake Ship"); - lang.addStringLocalization(this.shipKeyHandler.kbAlign.keyDescription, "en_US", "Align Ship"); - } - - public void registerRenderers() - { - RenderingRegistry.registerEntityRenderingHandler(EntityShip.class, new RenderShip()); - } -} diff --git a/src/shipmod/CommonProxy.java b/src/shipmod/CommonProxy.java deleted file mode 100644 index 71f5c39d..00000000 --- a/src/shipmod/CommonProxy.java +++ /dev/null @@ -1,10 +0,0 @@ -package shipmod; - -public class CommonProxy -{ - public void registerTickHandlers() {} - - public void registerLocalization() {} - - public void registerRenderers() {} -} diff --git a/src/shipmod/ConnectionHandler.java b/src/shipmod/ConnectionHandler.java deleted file mode 100644 index c0424ad4..00000000 --- a/src/shipmod/ConnectionHandler.java +++ /dev/null @@ -1,27 +0,0 @@ -package shipmod; - -import cpw.mods.fml.common.network.IConnectionHandler; -import cpw.mods.fml.common.network.Player; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.NetLoginHandler; -import net.minecraft.network.packet.NetHandler; -import net.minecraft.network.packet.Packet1Login; -import net.minecraft.server.MinecraftServer; - -public class ConnectionHandler implements IConnectionHandler -{ - public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {} - - public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) - { - return null; - } - - public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) {} - - public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) {} - - public void connectionClosed(INetworkManager manager) {} - - public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) {} -} diff --git a/src/shipmod/ForgeHookContainer.java b/src/shipmod/ForgeHookContainer.java deleted file mode 100644 index 4cc9c9ac..00000000 --- a/src/shipmod/ForgeHookContainer.java +++ /dev/null @@ -1,31 +0,0 @@ -package shipmod; - -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.PacketDispatcher; -import net.minecraft.network.packet.Packet250CustomPayload; -import net.minecraftforge.event.ForgeSubscribe; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import shipmod.entity.EntityShip; - -public class ForgeHookContainer -{ - @ForgeSubscribe - public void onEntitySpawn(EntityJoinWorldEvent event) - { - if (FMLCommonHandler.instance().getEffectiveSide().isClient() && event.entity instanceof EntityShip) - { - if (!((EntityShip)event.entity).getCapabilities().hasSigns()) - { - return; - } - - ByteArrayDataOutput out = ByteStreams.newDataOutput(4); - out.writeInt(event.entity.entityId); - Packet250CustomPayload packet = new Packet250CustomPayload("reqShipSigns", out.toByteArray()); - PacketDispatcher.sendPacketToServer(packet); - } - } -} diff --git a/src/shipmod/MetaRotations$1.java b/src/shipmod/MetaRotations$1.java deleted file mode 100644 index 0e0cde0c..00000000 --- a/src/shipmod/MetaRotations$1.java +++ /dev/null @@ -1,19 +0,0 @@ -package shipmod; - -import java.io.File; -import java.io.FilenameFilter; - -class MetaRotations$1 implements FilenameFilter -{ - final MetaRotations this$0; - - MetaRotations$1(MetaRotations var1) - { - this.this$0 = var1; - } - - public boolean accept(File f, String name) - { - return name.endsWith(".mrot"); - } -} diff --git a/src/shipmod/MetaRotations.java b/src/shipmod/MetaRotations.java deleted file mode 100644 index e7896d53..00000000 --- a/src/shipmod/MetaRotations.java +++ /dev/null @@ -1,723 +0,0 @@ -package shipmod; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import shipmod.MetaRotations$1; -import shipmod.BlockID; -import ic2.api.network.NetworkHelper; - -public class MetaRotations -{ - private File metaRotationsDirectory; - public Map<Integer, BlockMetaRotation> metaRotationMap = new HashMap(); - - public int getRotatedMeta(int block, int meta, int rotate) - { - if (rotate == 0) - { - return meta; - } - else - { - BlockMetaRotation rotation = (BlockMetaRotation)this.metaRotationMap.get(Integer.valueOf(block)); - return rotation == null ? meta : rotation.getRotatedMeta(meta, rotate); - } - } - - public int getRotatedMeta(Block block, int meta, int rotate) - { - return this.getRotatedMeta(block.blockID, meta, rotate); - } - - public void addMetaRotation(int blockid, int bitmask, int ... metarotation) - { - ShipMod.modLogger.finer("Adding meta rotations (id=" + blockid + ", name=" + Block.blocksList[blockid].getUnlocalizedName() + ", mask=" + bitmask + ", rot=" + Arrays.toString(metarotation) + ")"); - this.metaRotationMap.put(Integer.valueOf(blockid), new BlockMetaRotation(blockid, metarotation, bitmask)); - } - - public void addMetaRotation(Block block, int bitmask, int ... metarotation) - { - this.addMetaRotation(block.blockID, bitmask, metarotation); - } - - public void parseMetaRotations(BufferedReader reader) throws IOException - { - int lineno = 0; - String line; - - while ((line = reader.readLine()) != null) - { - ++lineno; - - if (!line.startsWith("#") && line.length() != 0) - { - int mask = -1; - int[] rot = new int[4]; - String[] as = line.split(";"); - - if (as.length < 3) - { - ShipMod.modLogger.warning("Curruption in metarotation file at line " + lineno + "(Not enough parameters)"); - } - else - { - String[] block = as[0].split(","); - int[] ids = new int[block.length]; - - for (int arr$ = 0; arr$ < block.length; ++arr$) - { - try - { - ids[arr$] = Integer.parseInt(block[arr$].trim()); - } - catch (NumberFormatException var17) - { - String i$ = block[arr$].trim(); - Block[] blockid = Block.blocksList; - int len$1 = blockid.length; - - for (int i$1 = 0; i$1 < len$1; ++i$1) - { - Block b = blockid[i$1]; - - if (b != null && b.getUnlocalizedName().toLowerCase().equals("tile.".concat(i$.toLowerCase()))) - { - ids[arr$] = b.blockID; - } - } - } - } - - int len$; - - try - { - mask = Integer.decode(as[1].trim()).intValue(); - String[] var19 = as[2].split(","); - - for (len$ = 0; len$ < rot.length; ++len$) - { - rot[len$] = Integer.parseInt(var19[len$].trim()); - } - } - catch (NumberFormatException var16) - { - ShipMod.modLogger.warning("Curruption in metarotation file at line " + lineno + " (" + var16.getLocalizedMessage() + ")"); - } - - int[] var18 = ids; - len$ = ids.length; - - for (int var20 = 0; var20 < len$; ++var20) - { - int var21 = var18[var20]; - this.addMetaRotation(var21, mask, rot); - } - } - } - } - } - - public void setConfigDirectory(File configdirectory) - { - this.metaRotationsDirectory = new File(configdirectory, "ShipMod"); - - if (!this.metaRotationsDirectory.isDirectory()) - { - this.metaRotationsDirectory.mkdirs(); - } - } - - public void readMetaRotationFiles() - { - if (this.metaRotationsDirectory == null) - { - throw new NullPointerException("Config folder has not been initialized"); - } - else - { - this.metaRotationMap.clear(); - File defaultfile = new File(this.metaRotationsDirectory, "default.mrot"); - ShipMod.modLogger.finer("Creating default.mrot"); - BufferedWriter writer = null; - - try - { - defaultfile.createNewFile(); - writer = new BufferedWriter(new FileWriter(defaultfile)); - writer.write("#----------------#\n"); - writer.write("# VANILLA BLOCKS #\n"); - writer.write("#----------------#\n"); - writer.write("# Default vanilla block meta rotations\n"); - writer.write("# This file will be overwritten every start, changes will not be implemented!\n"); - writer.write("# blocknames/blockIDs; bitmask; 4 metadata values in the clockwise rotation order\n"); - writer.write("\n"); - writer.write("# Pumpkin & Lantern\n"); - writer.write("86, 87; 0x3; 0, 1, 2, 3;\n"); - writer.write("\n"); - writer.write("# Stairs\n"); - writer.write("53, 67, 108, 109, 114, 128, 134, 135, 136, 156; 0x3; 2, 1, 3, 0;\n"); - writer.write("\n"); - writer.write("# Torches, levers and buttons\n"); - writer.write("50, 69, 75, 76, 77, 143; 0x7; 4, 1, 3, 2;\n"); - writer.write("\n"); - writer.write("# Sign\n"); - writer.write("68; 0x7; 3, 4, 2, 5;\n"); - writer.write("\n"); - writer.write("# Log\n"); - writer.write("17; 0xC; 4, 8, 4, 8;\n"); - writer.write("\n"); - writer.write("# Quarts pillar\n"); - writer.write("155; 0x7; 3, 4, 3, 4;\n"); - writer.write("\n"); - writer.write("# Ladder\n"); - writer.write("65; 0x7; 3, 4, 2, 5;\n"); - writer.write("\n# Fence gate\n"); - writer.write("107; 0x3; 0, 1, 2, 3;\n"); - writer.write("\n# Furnace, dispenser, chest\n"); - writer.write("61, 62, 23, 54; 0x7; 2, 5, 3, 4;\n"); - writer.write("\n# Redstone repeater\n"); - writer.write("93, 94; 0x3; 0, 1, 2, 3;\n"); - writer.write("\n# Doors\n"); - writer.write("64, 71; 0x3; 0, 1, 2, 3;\n"); - writer.write("\n# Bed\n"); - writer.write("26; 0x3; 0, 1, 2, 3;\n"); - writer.write("\n# AS stuff\n"); - writer.write("3769, 3779, 3772; 0x3; 2, 1, 3, 0;\n"); - } - catch (IOException var33) - { - var33.printStackTrace(); - } - finally - { - if (writer != null) - { - try - { - writer.close(); - } - catch (IOException var30) - { - var30.printStackTrace(); - } - } - } - - File archshipsmodfile = new File(this.metaRotationsDirectory, "ShipMod.mrot"); - ShipMod.modLogger.finer("Creating ShipMod.mrot"); - writer = null; - - try - { - archshipsmodfile.createNewFile(); - writer = new BufferedWriter(new FileWriter(archshipsmodfile)); - writer.write("# Block meta rotations\n"); - writer.write("\n"); - writer.write("markShip; 0x3; 0, 1, 2, 3;\n"); - } - catch (IOException var32) - { - var32.printStackTrace(); - } - finally - { - if (writer != null) - { - try - { - writer.close(); - } - catch (IOException var31) - { - var31.printStackTrace(); - } - } - } - - File[] files = this.metaRotationsDirectory.listFiles(new MetaRotations$1(this)); - File[] arr$ = files; - int len$ = files.length; - - for (int i$ = 0; i$ < len$; ++i$) - { - File f = arr$[i$]; - - try - { - this.readMetaRotationFile(f); - } - catch (IOException var34) - { - var34.printStackTrace(); - } - } - } - } - - public void readMetaRotationFile(File file) throws IOException - { - ShipMod.modLogger.info("Reading metarotation file " + file.getAbsolutePath()); - BufferedReader reader = new BufferedReader(new FileReader(file)); - this.parseMetaRotations(reader); - reader.close(); - } - - public static int rotate90(int type, int data) { - switch (type) { - case BlockID.MINECART_TRACKS: - switch (data) { - case 6: return 7; - case 7: return 8; - case 8: return 9; - case 9: return 6; - } - /* FALL-THROUGH */ - - case BlockID.POWERED_RAIL: - case BlockID.DETECTOR_RAIL: - case BlockID.ACTIVATOR_RAIL: - switch (data & 0x7) { - case 0: return 1 | (data & ~0x7); - case 1: return 0 | (data & ~0x7); - case 2: return 5 | (data & ~0x7); - case 3: return 4 | (data & ~0x7); - case 4: return 2 | (data & ~0x7); - case 5: return 3 | (data & ~0x7); - } - break; - - case BlockID.WOODEN_STAIRS: - case BlockID.COBBLESTONE_STAIRS: - case BlockID.BRICK_STAIRS: - case BlockID.STONE_BRICK_STAIRS: - case BlockID.NETHER_BRICK_STAIRS: - case BlockID.SANDSTONE_STAIRS: - case BlockID.SPRUCE_WOOD_STAIRS: - case BlockID.BIRCH_WOOD_STAIRS: - case BlockID.JUNGLE_WOOD_STAIRS: - case BlockID.QUARTZ_STAIRS: - switch (data) { - case 0: return 2; - case 1: return 3; - case 2: return 1; - case 3: return 0; - case 4: return 6; - case 5: return 7; - case 6: return 5; - case 7: return 4; - } - break; - - case BlockID.COCOA_PLANT: - case BlockID.TRIPWIRE_HOOK: - int extra = data & ~0x3; - int withoutFlags = data & 0x3; - switch (withoutFlags) { - case 0: return 1 | extra; - case 1: return 2 | extra; - case 2: return 3 | extra; - case 3: return 0 | extra; - } - break; - - case BlockID.SIGN_POST: - return (data + 4) % 16; - - case BlockID.LADDER: - case BlockID.WALL_SIGN: - case BlockID.FURNACE: - case BlockID.BURNING_FURNACE: - case BlockID.ENDER_CHEST: - case BlockID.TRAPPED_CHEST: - case BlockID.HOPPER: - switch (data) { - case 2: return 5; - case 3: return 4; - case 4: return 2; - case 5: return 3; - } - break; - - case BlockID.DROPPER: - int dispPower = data & 0x8; - switch (data & ~0x8) { - case 2: return 5 | dispPower; - case 3: return 4 | dispPower; - case 4: return 2 | dispPower; - case 5: return 3 | dispPower; - } - break; - - case BlockID.LOG: - if (data >= 4 && data <= 11) data ^= 0xc; - break; - - case BlockID.COMPARATOR_OFF: - case BlockID.COMPARATOR_ON: - int dir = data & 0x03; - int delay = data - dir; - switch (dir) { - case 0: return 1 | delay; - case 1: return 2 | delay; - case 2: return 3 | delay; - case 3: return 0 | delay; - } - break; - - case BlockID.TRAP_DOOR: - int withoutOrientation = data & ~0x3; - int orientation = data & 0x3; - switch (orientation) { - case 0: return 3 | withoutOrientation; - case 1: return 2 | withoutOrientation; - case 2: return 0 | withoutOrientation; - case 3: return 1 | withoutOrientation; - } - break; - - case BlockID.PISTON_BASE: - case BlockID.PISTON_STICKY_BASE: - case BlockID.PISTON_EXTENSION: - System.out.println("Flipping piston..."); - final int rest = data & ~0x7; - switch (data & 0x7) { - case 2: return 5 | rest; - case 3: return 4 | rest; - case 4: return 2 | rest; - case 5: return 3 | rest; - } - break; - - case BlockID.BROWN_MUSHROOM_CAP: - case BlockID.RED_MUSHROOM_CAP: - if (data >= 10) return data; - return (data * 3) % 10; - - case BlockID.VINE: - return ((data << 1) | (data >> 3)) & 0xf; - - case BlockID.FENCE_GATE: - return ((data + 1) & 0x3) | (data & ~0x3); - - case BlockID.ANVIL: - return data ^ 0x1; - - case BlockID.HAY_BLOCK: - if (data == 4) return 8; - else if (data == 8) return 4; - else return 0; // sanitize extraneous data values since hay blocks are weird - - } - - return data; - } - - public static boolean examForIC2Machine(TileEntity te) { - if (te == null) { - return false; - } - - //System.out.println("Testing for IC2 machine " + te.getClass().getSimpleName()); - Class c = te.getClass().getSuperclass(); - //System.out.println("Superclass name: " + c.getName()); - return (c == null) ? false : (c.getName().contains("ic2.core.block.generator.tileentity") || c.getName().contains("ic2.core.block.wiring.TileEntity") || c.getName().contains("ic2.core.block.machine.tileentity")); - } - - public static short rotateIC2MachineFacing90Reverse(short facing) { - switch(facing) // 3 5 2 4 - { - case 3: - facing = 5; - break; - - case 5: - facing = 2; - break; - - case 2: - facing = 4; - break; - - case 4: - facing = 3; - break; - } - return facing; - } - - public static boolean examForAEMachine(TileEntity te) { - if (te == null) { - return false; - } - - //System.out.println("Testing for AE machine " + te.getClass().getSimpleName()); - Class c = te.getClass().getSuperclass(); - //System.out.println("Superclass name: " + c.getName()); - return (c == null) ? false : (c.getName().contains("appeng.me.basetiles") || c.getName().contains("appeng.me.tile") || c.getName().contains("appeng.common.base.AppEngTile")); - } - - public static int rotateAEMachineFacing90Reverse(int facing) { - switch(facing) // 0 4 2 1 - { - case 0: - facing = 4; - break; - - case 4: - facing = 2; - break; - - case 2: - facing = 1; - break; - - case 1: - facing = 0; - break; - } - - return facing; - } - - public static int rotateAECableFacing90Reverse(int facing) { - switch(facing) // 3 5 2 4 - { - case 3: - facing = 5; - break; - - case 5: - facing = 2; - break; - - case 2: - facing = 4; - break; - - case 4: - facing = 3; - break; - } - - return facing; - } - - public static int getCCSubtypeFromMetadata(int metadata) { - return metadata >= 2 && metadata <= 5? 0 : (metadata >= 2 && (metadata < 6 || metadata > 9) ? (metadata == 10 ? 2 :(metadata == 11 ? 3 : 4)) : 1); - } - - public static int getCCDirectionFromMetadata(int metadata) { - return metadata >= 2 && metadata <= 5 ? metadata : (metadata <= 9 ? (metadata < 2 ? metadata : metadata - 4) : 2); - } - - public static int rotateCCBlock90Reverse(int dir) { - switch(dir) - { - case 4: - return 3; - case 3: - return 5; - case 5: - return 2; - case 2: - return 4; - } - - return dir; - } - - public static int rotateComputer90Reverse(int meta) { - int typeMeta = meta & 0x8; - - switch(meta - typeMeta) - { - case 4: - return typeMeta + 3; - case 3: - return typeMeta + 5; - case 5: - return typeMeta + 2; - case 2: - return typeMeta + 4; - } - - return meta; - } - - - /** - * Rotate a block's data value -90 degrees (north<-east<-south<-west<-north); - * - * @param type - * @param data - * @return - */ - public static int rotate90Reverse(int type, int data) { - switch (type) { - case BlockID.MINECART_TRACKS: - switch (data) { - case 7: return 6; - case 8: return 7; - case 9: return 8; - case 6: return 9; - } - /* FALL-THROUGH */ - - case BlockID.POWERED_RAIL: - case BlockID.DETECTOR_RAIL: - case BlockID.ACTIVATOR_RAIL: - int power = data & ~0x7; - switch (data & 0x7) { - case 1: return 0 | power; - case 0: return 1 | power; - case 5: return 2 | power; - case 4: return 3 | power; - case 2: return 4 | power; - case 3: return 5 | power; - } - break; - - case BlockID.WOODEN_STAIRS: - case BlockID.COBBLESTONE_STAIRS: - case BlockID.BRICK_STAIRS: - case BlockID.STONE_BRICK_STAIRS: - case BlockID.NETHER_BRICK_STAIRS: - case BlockID.SANDSTONE_STAIRS: - case BlockID.SPRUCE_WOOD_STAIRS: - case BlockID.BIRCH_WOOD_STAIRS: - case BlockID.JUNGLE_WOOD_STAIRS: - case BlockID.QUARTZ_STAIRS: - switch (data) { - case 2: return 0; - case 3: return 1; - case 1: return 2; - case 0: return 3; - case 6: return 4; - case 7: return 5; - case 5: return 6; - case 4: return 7; - } - break; - - case BlockID.WOODEN_DOOR: - case BlockID.IRON_DOOR: - case BlockID.COCOA_PLANT: - case BlockID.TRIPWIRE_HOOK: - int extra = data & ~0x3; - int withoutFlags = data & 0x3; - switch (withoutFlags) { - case 1: return 0 | extra; - case 2: return 1 | extra; - case 3: return 2 | extra; - case 0: return 3 | extra; - } - break; - - case BlockID.SIGN_POST: - return (data + 12) % 16; - - case BlockID.LADDER: - case BlockID.WALL_SIGN: - case BlockID.FURNACE: - case BlockID.BURNING_FURNACE: - case BlockID.ENDER_CHEST: - case BlockID.TRAPPED_CHEST: - case BlockID.HOPPER: - switch (data) { - case 5: return 2; - case 4: return 3; - case 2: return 4; - case 3: return 5; - } - break; - - case BlockID.DROPPER: - int dispPower = data & 0x8; - switch (data & ~0x8) { - case 5: return 2 | dispPower; - case 4: return 3 | dispPower; - case 2: return 4 | dispPower; - case 3: return 5 | dispPower; - } - break; - - case BlockID.LOG: - if (data >= 4 && data <= 11) data ^= 0xc; - break; - - case BlockID.COMPARATOR_OFF: - case BlockID.COMPARATOR_ON: - int dir = data & 0x03; - int delay = data - dir; - switch (dir) { - case 1: return 0 | delay; - case 2: return 1 | delay; - case 3: return 2 | delay; - case 0: return 3 | delay; - } - break; - - case BlockID.TRAP_DOOR: - int withoutOrientation = data & ~0x3; - int orientation = data & 0x3; - switch (orientation) { - case 3: return 0 | withoutOrientation; - case 2: return 1 | withoutOrientation; - case 0: return 2 | withoutOrientation; - case 1: return 3 | withoutOrientation; - } - - case BlockID.PISTON_BASE: - case BlockID.PISTON_STICKY_BASE: - case BlockID.PISTON_EXTENSION: - System.out.println("Flipping piston..."); - final int rest = data & ~0x7; - switch (data & 0x7) { - case 5: return 2 | rest; - case 4: return 3 | rest; - case 2: return 4 | rest; - case 3: return 5 | rest; - } - break; - - case BlockID.BROWN_MUSHROOM_CAP: - case BlockID.RED_MUSHROOM_CAP: - if (data >= 10) return data; - return (data * 7) % 10; - - case BlockID.VINE: - return ((data >> 1) | (data << 3)) & 0xf; - - case BlockID.FENCE_GATE: - return ((data + 3) & 0x3) | (data & ~0x3); - - case BlockID.ANVIL: - return data ^ 0x1; - - case BlockID.HAY_BLOCK: - if (data == 4) return 8; - else if (data == 8) return 4; - else return 0; - - } - - return data; - } -} diff --git a/src/shipmod/PacketHandler.java b/src/shipmod/PacketHandler.java deleted file mode 100644 index a5b45199..00000000 --- a/src/shipmod/PacketHandler.java +++ /dev/null @@ -1,134 +0,0 @@ -package shipmod; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; -import cpw.mods.fml.common.network.IPacketHandler; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import java.util.ArrayList; -import java.util.Iterator; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet250CustomPayload; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntitySign; -import shipmod.entity.EntityShip; - -public class PacketHandler implements IPacketHandler -{ - public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) - { - ShipMod.modLogger.finest("Received packet " + packet.channel + " with player " + player.toString()); - EntityPlayer entityplayer = (EntityPlayer)player; - ByteArrayDataInput in; - int id; - Entity entity; - - if (packet.channel.equals("shipControl")) - { - in = ByteStreams.newDataInput(packet.data); - id = in.readInt(); - entity = entityplayer.worldObj.getEntityByID(id); - - if (entity instanceof EntityShip) - { - byte signs = in.readByte(); - EntityShip i = (EntityShip)entity; - i.getController().updateControl(i, entityplayer, signs); - } - } - else if (packet.channel.equals("shipInteract")) - { - in = ByteStreams.newDataInput(packet.data); - id = in.readInt(); - entity = entityplayer.worldObj.getEntityByID(id); - - if (entity instanceof EntityShip) - { - entity.func_130002_c(entityplayer); - } - } - else if (packet.channel.equals("reqShipSigns")) - { - in = ByteStreams.newDataInput(packet.data); - id = in.readInt(); - entity = entityplayer.worldObj.getEntityByID(id); - - if (entity instanceof EntityShip) - { - if (!((EntityShip)entity).getCapabilities().hasSigns()) - { - return; - } - - ArrayList var14 = new ArrayList(); - Iterator var15 = ((EntityShip)entity).getShipChunk().chunkTileEntityMap.values().iterator(); - - while (var15.hasNext()) - { - TileEntity s = (TileEntity)var15.next(); - - if (s instanceof TileEntitySign) - { - var14.add((TileEntitySign)s); - } - } - - if (var14.size() > 0) - { - ByteArrayDataOutput var17 = ByteStreams.newDataOutput(6 + var14.size() * 70); - var17.writeInt(id); - var17.writeShort(var14.size()); - Iterator var20 = var14.iterator(); - - while (var20.hasNext()) - { - TileEntitySign te = (TileEntitySign)var20.next(); - var17.writeShort(te.xCoord & 15 | (te.yCoord & 15) << 4 | (te.zCoord & 15) << 8); - var17.writeUTF(te.signText[0]); - var17.writeUTF(te.signText[1]); - var17.writeUTF(te.signText[2]); - var17.writeUTF(te.signText[3]); - } - - try - { - Packet250CustomPayload var21 = new Packet250CustomPayload("shipSigns", var17.toByteArray()); - PacketDispatcher.sendPacketToPlayer(var21, player); - } - catch (IllegalArgumentException var12) - { - ShipMod.modLogger.warning("Ship has too many signs to send"); - } - } - } - } - else if (packet.channel.equals("shipSigns")) - { - in = ByteStreams.newDataInput(packet.data); - id = in.readInt(); - entity = entityplayer.worldObj.getEntityByID(id); - - if (entity instanceof EntityShip) - { - short var13 = in.readShort(); - - for (int var16 = 0; var16 < var13; ++var16) - { - short var18 = in.readShort(); - TileEntity var19 = ((EntityShip)entity).getShipChunk().getBlockTileEntity(var18 & 15, var18 >>> 4 & 15, var18 >>> 8 & 15); - - if (var19 instanceof TileEntitySign) - { - ((TileEntitySign)var19).signText[0] = in.readUTF(); - ((TileEntitySign)var19).signText[1] = in.readUTF(); - ((TileEntitySign)var19).signText[2] = in.readUTF(); - ((TileEntitySign)var19).signText[3] = in.readUTF(); - } - } - } - } - } -} diff --git a/src/shipmod/ShipMod.java b/src/shipmod/ShipMod.java deleted file mode 100644 index 3446ff20..00000000 --- a/src/shipmod/ShipMod.java +++ /dev/null @@ -1,119 +0,0 @@ -package shipmod; - -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -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.event.FMLServerStartingEvent; -import cpw.mods.fml.common.network.NetworkMod; -import cpw.mods.fml.common.registry.EntityRegistry; -import cpw.mods.fml.common.registry.GameRegistry; -import ic2.api.item.Items; - -import java.util.Collections; -import java.util.logging.Logger; - -import net.minecraft.block.Block; -import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; -import net.minecraft.command.CommandBase; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.Configuration; -import net.minecraftforge.common.MinecraftForge; -import shipmod.blockitem.BlockMarkShip; -import shipmod.blockitem.ItemCreateShip; -import shipmod.command.CommandHelp; -import shipmod.command.CommandAlignShip; -import shipmod.command.CommandDismountShip; -import shipmod.command.CommandKillShip; -import shipmod.command.CommandReloadMetaRotations; -import shipmod.command.CommandShipInfo; -import shipmod.command.CommandTpShip; -import shipmod.entity.EntityShip; - -@Mod( - modid = "ShipMod", - name = "ShipMod", - version = "1.6.2 v0.0.1" -) -@NetworkMod( - clientSideRequired = true, - serverSideRequired = true, - packetHandler = PacketHandler.class, - connectionHandler = ConnectionHandler.class, - channels = {"shipControl", "shipInteract", "reqShipSigns", "shipSigns"} -) -public class ShipMod -{ - @Instance("ShipMod") - public static ShipMod instance; - @SidedProxy( - clientSide = "shipmod.ClientProxy", - serverSide = "shipmod.CommonProxy" - ) - public static CommonProxy proxy; - public static Logger modLogger; - public static ItemCreateShip itemCreateVehicle; - public static BlockMarkShip blockMarkShip; - public static Material materialFloater; - public ShipModConfig modConfig; - public MetaRotations metaRotations = new MetaRotations(); - private ForgeHookContainer hookContainer = new ForgeHookContainer(); - - @EventHandler - public void preInitMod(FMLPreInitializationEvent event) - { - modLogger = event.getModLog(); - this.modConfig = new ShipModConfig(new Configuration(event.getSuggestedConfigurationFile())); - this.modConfig.loadAndSave(); - this.metaRotations.setConfigDirectory(event.getModConfigurationDirectory()); - } - - @EventHandler - public void initMod(FMLInitializationEvent event) - { - blockMarkShip = (BlockMarkShip)(new BlockMarkShip(this.modConfig.blockMarkShipID)).setUnlocalizedName("markShip").func_111022_d("markShip").setCreativeTab(CreativeTabs.tabTransport); - blockMarkShip.setStepSound(Block.soundMetalFootstep).setHardness(2.0F).setResistance(15.0F); - GameRegistry.registerBlock(blockMarkShip, "markShip"); - - GameRegistry.addRecipe(new ItemStack(blockMarkShip), "ici", "cec", "ici", - 'i', Items.getItem("iridiumPlate"), 'e', Item.enderPearl, 'c', Items.getItem("advancedCircuit")); - - EntityRegistry.registerModEntity(EntityShip.class, "shipmod", 1, this, 64, this.modConfig.shipEntitySyncRate, true); - - proxy.registerTickHandlers(); - proxy.registerLocalization(); - proxy.registerRenderers(); - MinecraftForge.EVENT_BUS.register(this.hookContainer); - } - - @EventHandler - public void postInitMod(FMLPostInitializationEvent event) - { - this.metaRotations.readMetaRotationFiles(); - } - - @EventHandler - public void serverStarting(FMLServerStartingEvent event) - { - this.registerASCommand(event, new CommandHelp()); - this.registerASCommand(event, new CommandReloadMetaRotations()); - this.registerASCommand(event, new CommandDismountShip()); - this.registerASCommand(event, new CommandShipInfo()); - this.registerASCommand(event, new CommandKillShip()); - this.registerASCommand(event, new CommandAlignShip()); - this.registerASCommand(event, new CommandTpShip()); - Collections.sort(CommandHelp.asCommands); - } - - private void registerASCommand(FMLServerStartingEvent event, CommandBase commandbase) - { - event.registerServerCommand(commandbase); - CommandHelp.asCommands.add(commandbase); - } -} diff --git a/src/shipmod/ShipModConfig.java b/src/shipmod/ShipModConfig.java deleted file mode 100644 index c7531b67..00000000 --- a/src/shipmod/ShipModConfig.java +++ /dev/null @@ -1,81 +0,0 @@ -package shipmod; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import net.minecraft.block.Block; -import net.minecraftforge.common.Configuration; - -public class ShipModConfig -{ - private static int[] defaultForbiddenBlocks = new int[] {Block.dirt.blockID, Block.grass.blockID, Block.sand.blockID, Block.gravel.blockID, Block.blockClay.blockID, Block.ice.blockID, Block.waterMoving.blockID, Block.waterStill.blockID, Block.lavaMoving.blockID, Block.lavaStill.blockID, Block.snow.blockID, Block.waterlily.blockID, Block.netherrack.blockID, Block.slowSand.blockID, Block.tallGrass.blockID}; - private static int[] defaultOverwritableBlocks = new int[] {Block.tallGrass.blockID, Block.waterlily.blockID}; - public static final int CONTROL_TYPE_VANILLA = 0; - public static final int CONTROL_TYPE_ARCHIMEDES = 1; - private Configuration config; - private Map<String, Object> materialStringMap; - public boolean enableAirShips = true; - public int shipEntitySyncRate; - public int maxShipChunkBlocks; - public float flyBalloonRatio = 0f; - public boolean connectDiagonalBlocks1; - public Set<Integer> forbiddenBlocks; - public Set<Integer> overwritableBlocks; - public int shipControlType; - public boolean remountOnDecompilationFail; - public float turnSpeed; - public float speedLimit; - public boolean enableRightClickDismount; - public int itemCreateVehicleID; - public int blockMarkShipID; - public int blockFloaterID; - public int blockBalloonID; - public int blockGaugeID; - - public ShipModConfig(Configuration configuration) - { - this.config = configuration; - this.forbiddenBlocks = new HashSet(); - this.overwritableBlocks = new HashSet(); - } - - public void loadAndSave() - { - this.config.load(); - this.shipEntitySyncRate = this.config.get("settings", "sync_rate", 20, "The amount of ticks between a server-client synchronization. Higher numbers reduce network traffic. Lower numbers increase multiplayer experience. 20 ticks = 1 second").getInt(); - this.shipControlType = this.config.get("control", "control_type", 1, "Set to 0 to use vanilla boat controls, set to 1 to use the new controls.").getInt(); - this.remountOnDecompilationFail = this.config.get("control", "remount_on_decomp_fail", false, "Set to \'true\' to automatically remount a ship if decompilation failed.").getBoolean(false); - this.turnSpeed = (float)this.config.get("control", "turn_speed", 1.0D, "A multiplier of the ship\'s turn speed.").getDouble(1.0D); - this.speedLimit = (float)this.config.get("control", "speed_limit", 30.0D, "The maximum velocity a ship can have, in meter per second. This does not affect acceleration.").getDouble(30.0D); - this.speedLimit /= 20.0F; - this.enableRightClickDismount = this.config.get("control", "enable_right_click_dismount", false, "Enable if right clicking on the ship should also dismount you.").getBoolean(false); - this.maxShipChunkBlocks = this.config.get("mobile_chunk", "max_chunk_blocks", 2048, "The maximum amount of blocks that a mobile ship chunk may contain, limited to a maximum of 3200 blocks").getInt(); - this.maxShipChunkBlocks = Math.min(this.maxShipChunkBlocks, 3400); - this.connectDiagonalBlocks1 = this.config.get("mobile_chunk", "connect_diagonal_blocks_1", false, "Blocks connected diagonally on one axis will also be added to the ship when this value is set to \'true\'.").getBoolean(false); - int[] forbiddenblocks = this.config.get("mobile_chunk", "forbidden_blocks", defaultForbiddenBlocks, "A list of blocks that will not be added to a ship.").getIntList(); - int[] overwritableblocks = this.config.get("mobile_chunk", "overwritable_blocks", defaultOverwritableBlocks, "A list of blocks that may be overwritten when decompiling a ship.").getIntList(); - int[] arr$ = forbiddenblocks; - int len$ = forbiddenblocks.length; - int i$; - int i; - - for (i$ = 0; i$ < len$; ++i$) - { - i = arr$[i$]; - this.forbiddenBlocks.add(Integer.valueOf(i)); - } - - arr$ = overwritableblocks; - len$ = overwritableblocks.length; - - for (i$ = 0; i$ < len$; ++i$) - { - i = arr$[i$]; - this.overwritableBlocks.add(Integer.valueOf(i)); - } - - this.blockMarkShipID = this.config.getBlock("mark_ship", 3611).getInt(); - this.blockGaugeID = this.config.getBlock("gauge", 3614).getInt(); - this.config.save(); - } -} diff --git a/src/shipmod/blockitem/BlockMarkShip.java b/src/shipmod/blockitem/BlockMarkShip.java deleted file mode 100644 index 86f439a9..00000000 --- a/src/shipmod/blockitem/BlockMarkShip.java +++ /dev/null @@ -1,184 +0,0 @@ -package shipmod.blockitem; - -import java.util.List; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.Icon; -import net.minecraft.world.World; -import shipmod.ShipMod; -import shipmod.chunk.ChunkBuilder; -import shipmod.entity.EntityShip; - -public class BlockMarkShip extends BlockDirectional -{ - private Icon frontIcon; - final int FUEL_CAN_ID = 30232; - final int EMPTY_FUEL_CAN_ID = 30231; - - final int SECONDS_OF_FLYING_PER_CAN = 300; // without ship blocks - final int TICKS_OF_TIME_PER_BLOCK_DECREASE = 10; // half a second per block - - public BlockMarkShip(int id) - { - super(id, Material.iron); - } - - @SideOnly(Side.CLIENT) - - /** - * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata - */ - public Icon getIcon(int side, int meta) - { - meta &= 3; - return side == 2 ? (meta == 0 ? this.frontIcon : this.blockIcon) : (side == 3 ? (meta == 2 ? this.frontIcon : this.blockIcon) : (side == 4 ? (meta == 3 ? this.frontIcon : this.blockIcon) : (side == 5 ? (meta == 1 ? this.frontIcon : this.blockIcon) : this.blockIcon))); - } - - /** - * When this method is called, your block should register all the icons it needs with the given IconRegister. This - * is the only chance you get to register icons. - */ - public void registerIcons(IconRegister reg) - { - super.registerIcons(reg); - this.frontIcon = reg.registerIcon("shipmod:shuttleControllerFront"); - this.blockIcon = reg.registerIcon("shipmod:shuttleControllerSide"); - } - - /** - * Called when the block is placed in the world. - */ - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - int dir = Math.round(entityliving.rotationYaw / 90.0F) & 3; - world.setBlockMetadataWithNotify(x, y, z, dir, 3); - } - - private TileEntityChest searchChest(World worldObj, int xCoord, int yCoord, int zCoord) { - TileEntity result = null; - result = worldObj.getBlockTileEntity(xCoord + 1, yCoord, zCoord); - if (result != null && result instanceof TileEntityChest) { - return (TileEntityChest) result; - } - - result = worldObj.getBlockTileEntity(xCoord - 1, yCoord, zCoord); - if (result != null && result instanceof TileEntityChest) { - return (TileEntityChest) result; - } - - result = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord + 1); - if (result != null && result instanceof TileEntityChest) { - return (TileEntityChest) result; - } - - result = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord - 1); - if (result != null && result instanceof TileEntityChest) { - return (TileEntityChest) result; - } - - result = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord); - if (result != null && result instanceof TileEntityChest) { - return (TileEntityChest) result; - } - - return null; - } - - private int consumeFuel(World worldObj, int xCoord, int yCoord, int zCoord) { - int res = 0; - - TileEntityChest chest = searchChest(worldObj, xCoord, yCoord, zCoord); - if (chest != null) { - for (int i = 0; i < chest.getSizeInventory(); i++) { - ItemStack stack = chest.getStackInSlot(i); - - if (stack != null && stack.itemID == FUEL_CAN_ID) { - res += (20 * SECONDS_OF_FLYING_PER_CAN) * stack.stackSize; - chest.setInventorySlotContents(i, new ItemStack(EMPTY_FUEL_CAN_ID, 1, 0)); - } - } - } - - return res; - } - - /** - * Called upon block activation (right click on the block.) - */ - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) - { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return true; - } - else - { - world.isRemote = true; // lock world from changes - ChunkBuilder builder = new ChunkBuilder(world, x, y, z); - builder.doFilling(); - - if (builder.getResult() == 0) - { - if (builder.getBlockCount() < 10) { - ((EntityPlayerMP)entityplayer).addChatMessage("[ShipMod] Ship is too small!"); - world.isRemote = false; - return false; - } - - int fuelLevel = consumeFuel(world, x, y, z); - fuelLevel -= (builder.getBlockCount() * TICKS_OF_TIME_PER_BLOCK_DECREASE); - - // By half of second per ship block - if (fuelLevel <= 0) { - ((EntityPlayerMP)entityplayer).addChatMessage("[ShipMod] Not enough fuel!"); - world.isRemote = false; - return false; - } else { - int flysec = fuelLevel / 20; - ((EntityPlayerMP)entityplayer).addChatMessage("[ShipMod] Loaded fuel for " + ((flysec <= 120) ? flysec + " seconds" : (flysec / 60) + " minutes") + " of flying"); - } - - EntityShip entity = builder.getEntity(world); - world.isRemote = false; - if (entity != null) - { - entity.health = builder.getBlockCount(); - entity.fuelLevel = fuelLevel; - world.spawnEntityInWorld(entity); - entityplayer.mountEntity(entity); - return true; - } - } - - if (builder.getResult() == 1) - { - ((EntityPlayerMP)entityplayer).addChatMessage("[ShipMod] Cannot create vehicle with more than " + ShipMod.instance.modConfig.maxShipChunkBlocks + " blocks"); - } - else if (builder.getResult() == 2) - { - ((EntityPlayerMP)entityplayer).addChatMessage("[ShipMod] Cannot create vehicle with no vehicle marker"); - } - else if (builder.getResult() == 3) - { - ((EntityPlayerMP)entityplayer).addChatMessage("[ShipMod] An error occured while compiling ship. Please report the appeared exception in the console."); - } else if (builder.getResult() == 4) { - ((EntityPlayerMP)entityplayer).addChatMessage("[ShipMod] ACTIVE WARP-CORE DETECTED. CANNOT CREATE VEHICLE."); - } - - world.isRemote = false; - return false; - } - } -} diff --git a/src/shipmod/blockitem/ItemCreateShip.java b/src/shipmod/blockitem/ItemCreateShip.java deleted file mode 100644 index f615c962..00000000 --- a/src/shipmod/blockitem/ItemCreateShip.java +++ /dev/null @@ -1,69 +0,0 @@ -package shipmod.blockitem; - -import cpw.mods.fml.common.FMLCommonHandler; -import net.minecraft.entity.Entity; -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.world.World; -import shipmod.chunk.ChunkBuilder; -import shipmod.entity.EntityShip; - -public class ItemCreateShip extends Item -{ - public ItemCreateShip(int id) - { - super(id); - } - - /** - * 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 itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int par7, float par8, float par9, float par10) - { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return true; - } - else - { - ChunkBuilder filler = new ChunkBuilder(world, x, y, z); - filler.doFilling(); - - if (filler.getResult() == 0) - { - EntityShip entity = filler.getEntity(world); - world.spawnEntityInWorld(entity); - return true; - } - else - { - if (filler.getResult() == 1) - { - ((EntityPlayerMP)entityplayer).addChatMessage("Cannot create vehicle with more than 200 blocks"); - } - else if (filler.getResult() == 2) - { - ((EntityPlayerMP)entityplayer).addChatMessage("Cannot create vehicle with no vehicle marker"); - } - - return false; - } - } - } - - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) - { - if (entity instanceof EntityShip) - { - ((EntityShip)entity).decompileToBlocks(true); - return true; - } - else - { - return false; - } - } -} diff --git a/src/shipmod/chunk/ChunkBuilder.java b/src/shipmod/chunk/ChunkBuilder.java deleted file mode 100644 index 447d30c0..00000000 --- a/src/shipmod/chunk/ChunkBuilder.java +++ /dev/null @@ -1,233 +0,0 @@ -package shipmod.chunk; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; - -import cr0s.WarpDrive.WarpDrive; -import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.ChunkPosition; -import net.minecraft.world.World; -import shipmod.ShipMod; -import shipmod.entity.EntityShip; - -public class ChunkBuilder -{ - public static final int RESULT_OK = 0; - public static final int RESULT_BLOCK_OVERFLOW = 1; - public static final int RESULT_MISSING_MARKER = 2; - public static final int RESULT_ERROR_OCCURED = 3; - private World worldObj; - private int startX; - private int startY; - private int startZ; - private Map<ChunkPosition, LocatedBlock> filledBlocks; - private LocatedBlock shipMarkingBlock; - private int result; - private final int maxBlocks; - public int xOffset; - public int yOffset; - public int zOffset; - - private boolean isActiveCoreOnBoard = false; - - public ChunkBuilder(World world, int x, int y, int z) - { - this.worldObj = world; - this.filledBlocks = new HashMap(256); - this.startX = x; - this.startY = y; - this.startZ = z; - this.maxBlocks = ShipMod.instance.modConfig.maxShipChunkBlocks; - this.result = -1; - } - - public int getBlockCount() - { - return this.filledBlocks.size(); - } - - public int getResult() - { - return this.result; - } - - public Collection<LocatedBlock> getFilledBlocks() - { - return this.filledBlocks.values(); - } - - public LocatedBlock getShipMarker() - { - return this.shipMarkingBlock; - } - - public void doFilling() - { - this.xOffset = this.startX; - this.yOffset = this.startY; - this.zOffset = this.startZ; - - try - { - this.fill(new HashSet(), this.startX, this.startY, this.startZ); - - if (this.shipMarkingBlock == null) - { - this.result = 2; - } - else - { - if (!isActiveCoreOnBoard) - this.result = 0; - else - this.result = 4; - } - } - catch (ShipSizeOverflowException var2) - { - this.result = 1; - } - catch (StackOverflowError var3) - { - System.err.println(var3.toString()); - this.result = 3; - } - catch (Exception var4) - { - var4.printStackTrace(); - this.result = 3; - } - } - - private void fill(HashSet<ChunkPosition> set, int x, int y, int z) throws ShipSizeOverflowException - { - if (this.getBlockCount() > this.maxBlocks) - { - throw new ShipSizeOverflowException(); - } - else - { - ChunkPosition pos = new ChunkPosition(x, y, z); - - if (!set.contains(pos) && !this.filledBlocks.containsKey(pos)) - { - set.add(pos); - int id = this.worldObj.getBlockId(x, y, z); - - if (id != 0 && this.canUseBlockForVehicle(Block.blocksList[id], x, y, z)) - { - this.xOffset = Math.min(this.xOffset, x); - this.yOffset = Math.min(this.yOffset, y); - this.zOffset = Math.min(this.zOffset, z); - - if (id == ShipMod.blockMarkShip.blockID && this.shipMarkingBlock == null) - { - this.shipMarkingBlock = new LocatedBlock(id, this.worldObj.getBlockMetadata(x, y, z), pos); - this.filledBlocks.put(pos, this.shipMarkingBlock); - } - else - { - if (id == WarpDrive.WARP_CORE_BLOCKID) { - isActiveCoreOnBoard = worldObj.getBlockMetadata(x, y, z) != 0; - } - this.filledBlocks.put(pos, new LocatedBlock(id, this.worldObj.getBlockMetadata(x, y, z), pos)); - } - - this.fill(set, x - 1, y, z); - this.fill(set, x, y - 1, z); - this.fill(set, x, y, z - 1); - this.fill(set, x + 1, y, z); - this.fill(set, x, y + 1, z); - this.fill(set, x, y, z + 1); - - if (ShipMod.instance.modConfig.connectDiagonalBlocks1) - { - this.fill(set, x - 1, y - 1, z); - this.fill(set, x + 1, y - 1, z); - this.fill(set, x + 1, y + 1, z); - this.fill(set, x - 1, y + 1, z); - this.fill(set, x - 1, y, z - 1); - this.fill(set, x + 1, y, z - 1); - this.fill(set, x + 1, y, z + 1); - this.fill(set, x - 1, y, z + 1); - this.fill(set, x, y - 1, z - 1); - this.fill(set, x, y + 1, z - 1); - this.fill(set, x, y + 1, z + 1); - this.fill(set, x, y - 1, z + 1); - } - } - } - } - } - - public boolean canUseBlockForVehicle(Block block, int x, int y, int z) - { - return block != null && !block.isAirBlock(this.worldObj, x, y, z) && !block.blockMaterial.isLiquid() && !ShipMod.instance.modConfig.forbiddenBlocks.contains(Integer.valueOf(block.blockID)); - } - - public EntityShip getEntity(World world) - { - if (this.result != 0) - { - return null; - } - else - { - EntityShip entity = new EntityShip(world); - Iterator i$ = this.getFilledBlocks().iterator(); - LocatedBlock block; - - while (i$.hasNext()) - { - block = (LocatedBlock)i$.next(); - int ix = block.coords.x - this.xOffset; - int iy = block.coords.y - this.yOffset; - int iz = block.coords.z - this.zOffset; - TileEntity tileentity = world.getBlockTileEntity(block.coords.x, block.coords.y, block.coords.z); - - // cloning tile entity - NBTTagCompound nbt = null; - - if (tileentity != null) - { - nbt = new NBTTagCompound(); - tileentity.writeToNBT(nbt); - world.removeBlockTileEntity(block.coords.x, block.coords.y, block.coords.z); - } - - if (entity.getShipChunk().setBlockIDWithMetadata(ix, iy, iz, block.blockID, block.blockMeta)) - { - world.setBlock(block.coords.x, block.coords.y, block.coords.z, 0, 1, 2); - - if (nbt != null) { - TileEntity newTE = TileEntity.createAndLoadEntity(nbt); - entity.getShipChunk().setBlockTileEntity(ix, iy, iz, newTE); - } - } - } - - i$ = this.getFilledBlocks().iterator(); - - while (i$.hasNext()) - { - block = (LocatedBlock)i$.next(); - world.setBlockToAir(block.coords.x, block.coords.y, block.coords.z); - } - - entity.setFrontDirection(this.shipMarkingBlock.blockMeta & 3); - entity.seatX = this.shipMarkingBlock.coords.x - this.xOffset; - entity.seatY = this.shipMarkingBlock.coords.y - this.yOffset; - entity.seatZ = this.shipMarkingBlock.coords.z - this.zOffset; - entity.getShipChunk().setCreationSpotBiomeGen(world.getBiomeGenForCoords(this.shipMarkingBlock.coords.x, this.shipMarkingBlock.coords.z)); - entity.getShipChunk().setChunkModified(); - entity.getShipChunk().onChunkLoad(); - entity.setLocationAndAngles((double)((float)this.xOffset + entity.getShipChunk().getCenterX()), (double)this.yOffset, (double)((float)this.zOffset + entity.getShipChunk().getCenterZ()), 0.0F, 0.0F); - return entity; - } - } -} diff --git a/src/shipmod/chunk/LocatedBlock.java b/src/shipmod/chunk/LocatedBlock.java deleted file mode 100644 index 7c6238f9..00000000 --- a/src/shipmod/chunk/LocatedBlock.java +++ /dev/null @@ -1,22 +0,0 @@ -package shipmod.chunk; - -import net.minecraft.world.ChunkPosition; - -public class LocatedBlock -{ - public final int blockID; - public final int blockMeta; - public final ChunkPosition coords; - - public LocatedBlock(int id, int meta, ChunkPosition coords) - { - this.blockID = id; - this.blockMeta = meta; - this.coords = coords; - } - - public String toString() - { - return "LocatedBlock [id=" + this.blockID + ", meta=" + this.blockMeta + ", coords=[" + this.coords.x + ", " + this.coords.y + ", " + this.coords.z + "]]"; - } -} diff --git a/src/shipmod/chunk/MobileChunk.java b/src/shipmod/chunk/MobileChunk.java deleted file mode 100644 index 832ab25a..00000000 --- a/src/shipmod/chunk/MobileChunk.java +++ /dev/null @@ -1,640 +0,0 @@ -package shipmod.chunk; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Vec3Pool; -import net.minecraft.world.ChunkPosition; -import net.minecraft.world.EnumSkyBlock; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.chunk.storage.ExtendedBlockStorage; -import net.minecraftforge.common.ForgeDirection; -import shipmod.ShipMod; -import shipmod.entity.EntityShip; -import shipmod.entity.IShipTileEntity; -import shipmod.render.MobileChunkRenderer; - -public class MobileChunk implements IBlockAccess -{ - public static final int CHUNK_SIZE = 16; - public static final int CHUNK_SIZE_EXP = 4; - public static final int CHUNK_MEMORY_USING = 24576; - private World worldObj; - private EntityShip entityShip; - private Map<ChunkPosition, ExtendedBlockStorage> blockStorageMap; - public Map<ChunkPosition, TileEntity> chunkTileEntityMap; - private boolean boundsInit; - private int minX; - private int minY; - private int minZ; - private int maxX; - private int maxY; - private int maxZ; - private int blockCount; - public boolean isChunkLoaded; - public boolean isModified; - public boolean chunkUpdated; - private BiomeGenBase creationSpotBiome; - @SideOnly(Side.CLIENT) - public MobileChunkRenderer renderer; - - public MobileChunk(World world, EntityShip entityship) - { - this.worldObj = world; - this.entityShip = entityship; - this.blockStorageMap = new HashMap(1); - this.chunkTileEntityMap = new HashMap(2); - this.isChunkLoaded = false; - this.isModified = false; - this.chunkUpdated = false; - this.boundsInit = false; - this.minX = this.minY = this.minZ = this.maxX = this.maxY = this.maxZ = -1; - this.blockCount = 0; - - if (FMLCommonHandler.instance().getSide().isClient()) - { - this.renderer = new MobileChunkRenderer(this); - } - - this.creationSpotBiome = BiomeGenBase.ocean; - } - - public ExtendedBlockStorage getBlockStorage(int x, int y, int z) - { - ChunkPosition pos = new ChunkPosition(x >> 4, y >> 4, z >> 4); - return (ExtendedBlockStorage)this.blockStorageMap.get(pos); - } - - public ExtendedBlockStorage getBlockStorageOrCreate(int x, int y, int z) - { - ChunkPosition pos = new ChunkPosition(x >> 4, y >> 4, z >> 4); - ExtendedBlockStorage storage = (ExtendedBlockStorage)this.blockStorageMap.get(pos); - - if (storage != null) - { - return storage; - } - else - { - storage = new ExtendedBlockStorage(pos.y, false); - this.blockStorageMap.put(pos, storage); - return storage; - } - } - - public int getBlockCount() - { - return this.blockCount; - } - - public float getCenterX() - { - return (float)(this.minX + this.maxX) / 2.0F; - } - - public float getCenterY() - { - return (float)(this.minY + this.maxY) / 2.0F; - } - - public float getCenterZ() - { - return (float)(this.minZ + this.maxZ) / 2.0F; - } - - public int minX() - { - return this.minX; - } - - public int maxX() - { - return this.maxX; - } - - public int minY() - { - return this.minY; - } - - public int maxY() - { - return this.maxY; - } - - public int minZ() - { - return this.minZ; - } - - public int maxZ() - { - return this.maxZ; - } - - public void setCreationSpotBiomeGen(BiomeGenBase biomegenbase) - { - this.creationSpotBiome = biomegenbase; - } - - /** - * Returns the block ID at coords x,y,z - */ - public int getBlockId(int x, int y, int z) - { - ExtendedBlockStorage storage = this.getBlockStorage(x, y, z); - return storage == null ? 0 : storage.getExtBlockID(x & 15, y & 15, z & 15); - } - - /** - * Returns the block metadata at coords x,y,z - */ - public int getBlockMetadata(int x, int y, int z) - { - ExtendedBlockStorage storage = this.getBlockStorage(x, y, z); - return storage == null ? 0 : storage.getExtBlockMetadata(x & 15, y & 15, z & 15); - } - - public boolean setBlockIDWithMetadata(int x, int y, int z, int id, int meta) - { - ExtendedBlockStorage storage = this.getBlockStorageOrCreate(x, y, z); - int i = x & 15; - int j = y & 15; - int k = z & 15; - int currentid = storage.getExtBlockID(i, j, k); - int currentmeta = storage.getExtBlockMetadata(i, j, k); - - if (currentid == 0 && (currentid != id || currentmeta != meta)) - { - storage.setExtBlockID(i, j, k, id); - storage.setExtBlockMetadata(i, j, k, meta); - - if (this.boundsInit) - { - this.minX = Math.min(this.minX, x); - this.minY = Math.min(this.minY, y); - this.minZ = Math.min(this.minZ, z); - this.maxX = Math.max(this.maxX, x + 1); - this.maxY = Math.max(this.maxY, y + 1); - this.maxZ = Math.max(this.maxZ, z + 1); - } - else - { - this.boundsInit = true; - this.minX = x; - this.minY = y; - this.minZ = z; - this.maxX = x + 1; - this.maxY = y + 1; - this.maxZ = z + 1; - } - - ++this.blockCount; - this.entityShip.onChunkBlockAdded(id, meta); - this.setChunkModified(); - - if (Block.blocksList[id] != null && Block.blocksList[id].hasTileEntity(meta)) - { - TileEntity tileentity = this.getChunkBlockTileEntity(x, y, z); - - /*if (tileentity == null) - { - tileentity = Block.blocksList[id].createTileEntity(this.worldObj, meta); - this.setBlockTileEntity(x, y, z, tileentity); - }*/ - - if (tileentity != null) - { - tileentity.updateContainingBlockInfo(); - tileentity.blockType = Block.blocksList[id]; - tileentity.blockMetadata = meta; - } - } - - return true; - } - else - { - return false; - } - } - - public boolean setBlockMetadata(int x, int y, int z, int meta) - { - ExtendedBlockStorage storage = this.getBlockStorage(x, y, z); - - if (storage == null) - { - return false; - } - else - { - int currentmeta = storage.getExtBlockMetadata(x, y & 15, z); - - if (currentmeta == meta) - { - return false; - } - else - { - this.setChunkModified(); - storage.setExtBlockMetadata(x & 15, y & 15, z & 15, meta); - int id = storage.getExtBlockID(x & 15, y & 15, z & 15); - - if (id > 0 && Block.blocksList[id] != null && Block.blocksList[id].hasTileEntity(meta)) - { - TileEntity tileentity = this.getChunkBlockTileEntity(x, y, z); - - if (tileentity != null) - { - tileentity.updateContainingBlockInfo(); - tileentity.blockMetadata = meta; - } - } - - return true; - } - } - } - - public boolean setBlockAsFilledAir(int x, int y, int z) - { - ExtendedBlockStorage storage = this.getBlockStorage(x, y, z); - - if (storage == null) - { - return true; - } - else - { - int id = storage.getExtBlockID(x & 15, y & 15, z & 15); - - if (id != 0 && Block.blocksList[id] != null && !Block.blocksList[id].isAirBlock(this.worldObj, x, y, z)) - { - return false; - } - else - { - storage.setExtBlockID(x & 15, y & 15, z & 15, 0); - storage.setExtBlockMetadata(x & 15, y & 15, z & 15, 1); - return true; - } - } - } - - /** - * Returns the TileEntity associated with a given block in X,Y,Z coordinates, or null if no TileEntity exists - */ - public TileEntity getBlockTileEntity(int i, int j, int k) - { - return this.getChunkBlockTileEntity(i, j, k); - } - - private TileEntity getChunkBlockTileEntity(int x, int y, int z) - { - ChunkPosition chunkposition = new ChunkPosition(x, y, z); - TileEntity tileentity = (TileEntity)this.chunkTileEntityMap.get(chunkposition); - - if (tileentity != null && tileentity.isInvalid()) - { - this.chunkTileEntityMap.remove(chunkposition); - tileentity = null; - } - - /*if (tileentity == null) - { - int l = this.getBlockId(x, y, z); - int meta = this.getBlockMetadata(x, y, z); - - if (l <= 0 || !Block.blocksList[l].hasTileEntity(meta)) - { - return null; - } - - // GET OUT! - //tileentity = Block.blocksList[l].createTileEntity(this.worldObj, meta); - this.setBlockTileEntity(x, y, z, tileentity); - tileentity = (TileEntity)this.chunkTileEntityMap.get(chunkposition); - }*/ - - return tileentity; - } - - public void setBlockTileEntity(int x, int y, int z, TileEntity tileentity) - { - if (tileentity != null && !tileentity.isInvalid()) - { - this.setChunkBlockTileEntity(x, y, z, tileentity); - } - } - - private void setChunkBlockTileEntity(int x, int y, int z, TileEntity tileentity) - { - ChunkPosition chunkposition = new ChunkPosition(x, y, z); - tileentity.setWorldObj(this.worldObj); - tileentity.xCoord = x; - tileentity.yCoord = y; - tileentity.zCoord = z; - Block block = Block.blocksList[this.getBlockId(x, y, z)]; - - if (block != null && block.hasTileEntity(this.getBlockMetadata(x, y, z))) - { - if (this.chunkTileEntityMap.containsKey(chunkposition)) - { - ((TileEntity)this.chunkTileEntityMap.get(chunkposition)).invalidate(); - } - - tileentity.blockMetadata = this.getBlockMetadata(x, y, z); - tileentity.validate(); - this.chunkTileEntityMap.put(chunkposition, tileentity); - - if (tileentity instanceof IShipTileEntity) - { - ((IShipTileEntity)tileentity).setVehicle(this.entityShip); - } - - //if (this.isChunkLoaded) - //{ - // this.worldObj.addTileEntity(tileentity); - //} - } - } - - public void addTileEntity(TileEntity tileentity) - { - int i = tileentity.xCoord; - int j = tileentity.yCoord; - int k = tileentity.zCoord; - if (!worldObj.isAirBlock(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord) && worldObj.getBlockTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord) != null) { - worldObj.removeBlockTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord); - tileentity.validate(); - } - this.setChunkBlockTileEntity(i, j, k, tileentity); - - //if (this.isChunkLoaded) - //{ - // this.worldObj.addTileEntity(tileentity); - //} - } - - public void removeChunkBlockTileEntity(int x, int y, int z) - { - ChunkPosition chunkposition = new ChunkPosition(x, y, z); - - if (this.isChunkLoaded) - { - TileEntity tileentity = (TileEntity)this.chunkTileEntityMap.remove(chunkposition); - - if (tileentity != null) - { - tileentity.invalidate(); - } - } - } - - public void onChunkLoad() - { - this.isChunkLoaded = true; - // do not load mobile chunk entities - //this.worldObj.addTileEntity(this.chunkTileEntityMap.values()); - } - - public void onChunkUnload() - { - this.isChunkLoaded = false; - - if (FMLCommonHandler.instance().getSide().isClient()) - { - this.renderer.markRemoved(); - } - } - - public void setChunkModified() - { - this.isModified = true; - this.chunkUpdated = true; - - if (FMLCommonHandler.instance().getSide().isClient()) - { - this.renderer.markDirty(); - } - } - - /** - * Any Light rendered on a 1.8 Block goes through here - */ - public int getLightBrightnessForSkyBlocks(int i, int j, int k, int l) - { - int i1 = EnumSkyBlock.Sky.defaultLightValue; - return i1 << 20 | l << 4; - } - - public float getBrightness(int i, int j, int k, int l) - { - return 1.0F; - } - - /** - * Returns how bright the block is shown as which is the block's light value looked up in a lookup table (light - * values aren't linear for brightness). Args: x, y, z - */ - public float getLightBrightness(int i, int j, int k) - { - return 1.0F; - } - - /** - * Returns the block's material. - */ - public Material getBlockMaterial(int i, int j, int k) - { - int l = this.getBlockId(i, j, k); - return l == 0 ? Material.air : Block.blocksList[l].blockMaterial; - } - - /** - * Returns true if the block at the specified coordinates is an opaque cube. Args: x, y, z - */ - public boolean isBlockOpaqueCube(int par1, int par2, int par3) - { - Block block = Block.blocksList[this.getBlockId(par1, par2, par3)]; - return block != null && block.isOpaqueCube(); - } - - /** - * Indicate if a material is a normal solid opaque cube. - */ - public boolean isBlockNormalCube(int par1, int par2, int par3) - { - Block block = Block.blocksList[this.getBlockId(par1, par2, par3)]; - return block != null && block.isBlockNormalCube(this.worldObj, par1, par2, par3); - } - - /** - * Returns true if the block at the specified coordinates is empty - */ - public boolean isAirBlock(int x, int y, int z) - { - int id = this.getBlockId(x, y, z); - return id == 0 || Block.blocksList[id] == null || Block.blocksList[id].isAirBlock(this.worldObj, x, y, z); - } - - public boolean isBlockTakingWaterVolume(int x, int y, int z) - { - int id = this.getBlockId(x, y, z); - - if (id == 0) - { - if (this.getBlockMetadata(x, y, z) == 1) - { - return false; - } - } - else if (Block.blocksList[id] == null || Block.blocksList[id].isAirBlock(this.worldObj, x, y, z)) - { - return false; - } - - return true; - } - - /** - * Gets the biome for a given set of x/z coordinates - */ - public BiomeGenBase getBiomeGenForCoords(int i, int j) - { - return this.creationSpotBiome; - } - - /** - * Returns current world height. - */ - public int getHeight() - { - return 16; - } - - /** - * set by !chunk.getAreLevelsEmpty - */ - public boolean extendedLevelsInChunkCache() - { - return false; - } - - public boolean isBlockSolidOnSide(int x, int y, int z, ForgeDirection side, boolean _default) - { - if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000) - { - Block block = Block.blocksList[this.getBlockId(x, y, z)]; - return block == null ? false : block.isBlockSolidOnSide(this.worldObj, x, y, z, side); - } - else - { - return _default; - } - } - - /** - * Returns true if the block at the given coordinate has a solid (buildable) top surface. - */ - public boolean doesBlockHaveSolidTopSurface(int i, int j, int k) - { - return this.isBlockSolidOnSide(i, j, k, ForgeDirection.UP, false); - } - - /** - * Return the Vec3Pool object for this world. - */ - public Vec3Pool getWorldVec3Pool() - { - return this.worldObj.getWorldVec3Pool(); - } - - /** - * Is this block powering in the specified direction Args: x, y, z, direction - */ - public int isBlockProvidingPowerTo(int i, int j, int k, int l) - { - return 0; - } - - public void writeChunkData(DataOutput out) throws IOException - { - int count = 0; - int i; - int j; - int k; - int id; - - for (i = this.minX; i < this.maxX; ++i) - { - for (j = this.minY; j < this.maxY; ++j) - { - for (k = this.minZ; k < this.maxZ; ++k) - { - id = this.getBlockId(i, j, k); - - if (id != 0 && Block.blocksList[id] != null) - { - ++count; - } - } - } - } - - ShipMod.modLogger.finest("Writing mobile chunk data: " + count); - out.writeShort(count); - - for (i = this.minX; i < this.maxX; ++i) - { - for (j = this.minY; j < this.maxY; ++j) - { - for (k = this.minZ; k < this.maxZ; ++k) - { - id = this.getBlockId(i, j, k); - - if (id != 0 && Block.blocksList[id] != null) - { - out.writeByte(i); - out.writeByte(j); - out.writeByte(k); - out.writeShort(id); - out.writeInt(this.getBlockMetadata(i, j, k)); - } - } - } - } - } - - public void readChunkData(DataInput in) throws IOException - { - short count = in.readShort(); - ShipMod.modLogger.finest("Reading mobile chunk data: " + count); - - for (int i = 0; i < count; ++i) - { - byte x = in.readByte(); - byte y = in.readByte(); - byte z = in.readByte(); - short id = in.readShort(); - int meta = in.readInt(); - this.setBlockIDWithMetadata(x, y, z, id, meta); - } - } - - public int getMemoryUsage() - { - return 2 + this.blockCount * 9; - } -} diff --git a/src/shipmod/chunk/ShipChunkBuilder$ShipSizeOverflowException.java b/src/shipmod/chunk/ShipChunkBuilder$ShipSizeOverflowException.java deleted file mode 100644 index 002ed485..00000000 --- a/src/shipmod/chunk/ShipChunkBuilder$ShipSizeOverflowException.java +++ /dev/null @@ -1,5 +0,0 @@ -package shipmod.chunk; - -public class ShipChunkBuilder$ShipSizeOverflowException extends Exception -{ -} diff --git a/src/shipmod/chunk/ShipSizeOverflowException.java b/src/shipmod/chunk/ShipSizeOverflowException.java deleted file mode 100644 index f8077b0e..00000000 --- a/src/shipmod/chunk/ShipSizeOverflowException.java +++ /dev/null @@ -1,5 +0,0 @@ -package shipmod.chunk; - -public class ShipSizeOverflowException extends RuntimeException -{ -} diff --git a/src/shipmod/command/CommandAlignShip.java b/src/shipmod/command/CommandAlignShip.java deleted file mode 100644 index 18be0194..00000000 --- a/src/shipmod/command/CommandAlignShip.java +++ /dev/null @@ -1,50 +0,0 @@ -package shipmod.command; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.Entity; -import net.minecraft.util.ChatMessageComponent; -import shipmod.entity.EntityShip; - -public class CommandAlignShip extends CommandBase -{ - public String getCommandName() - { - return "alignship"; - } - - public void processCommand(ICommandSender icommandsender, String[] astring) - { - if (icommandsender instanceof Entity && ((Entity)icommandsender).ridingEntity instanceof EntityShip) - { - EntityShip ship = (EntityShip)((Entity)icommandsender).ridingEntity; - ship.alignToGrid(); - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Ship aligned to world grid")); - } - else - { - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Not steering a ship")); - } - } - - /** - * Return the required permission level for this command. - */ - public int getRequiredPermissionLevel() - { - return 0; - } - - /** - * Returns true if the given command sender is allowed to use this command. - */ - public boolean canCommandSenderUseCommand(ICommandSender icommandsender) - { - return icommandsender instanceof Entity; - } - - public String getCommandUsage(ICommandSender icommandsender) - { - return "/" + this.getCommandName(); - } -} diff --git a/src/shipmod/command/CommandDismountShip.java b/src/shipmod/command/CommandDismountShip.java deleted file mode 100644 index e80cde98..00000000 --- a/src/shipmod/command/CommandDismountShip.java +++ /dev/null @@ -1,65 +0,0 @@ -package shipmod.command; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.Entity; -import net.minecraft.util.ChatMessageComponent; -import shipmod.entity.EntityShip; - -public class CommandDismountShip extends CommandBase -{ - public String getCommandName() - { - return "dismountship"; - } - - /** - * Return the required permission level for this command. - */ - public int getRequiredPermissionLevel() - { - return 4; - } - - public void processCommand(ICommandSender icommandsender, String[] astring) - { - if (icommandsender instanceof Entity) - { - Entity player = (Entity)icommandsender; - - if (player.ridingEntity instanceof EntityShip) - { - boolean flag = false; - - if (astring != null && astring.length > 0 && (astring[0].equals("overwrite") || astring[0].equals("override"))) - { - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Overwriting existing blocks with ship blocks")); - flag = true; - } - else - { - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Trying to add ship blocks to world")); - } - - ((EntityShip)player.ridingEntity).decompileToBlocks(flag); - player.mountEntity((Entity)null); - return; - } - } - - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Not steering a ship")); - } - - /** - * Returns true if the given command sender is allowed to use this command. - */ - public boolean canCommandSenderUseCommand(ICommandSender icommandsender) - { - return icommandsender instanceof Entity; - } - - public String getCommandUsage(ICommandSender icommandsender) - { - return "/" + this.getCommandName() + " [overwrite]"; - } -} diff --git a/src/shipmod/command/CommandHelp.java b/src/shipmod/command/CommandHelp.java deleted file mode 100644 index 6a494aff..00000000 --- a/src/shipmod/command/CommandHelp.java +++ /dev/null @@ -1,58 +0,0 @@ -package shipmod.command; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.Entity; -import net.minecraft.util.ChatMessageComponent; - -public class CommandHelp extends CommandBase -{ - public static List<CommandBase> asCommands = new ArrayList(); - - public String getCommandName() - { - return "smhelp"; - } - - /** - * Return the required permission level for this command. - */ - public int getRequiredPermissionLevel() - { - return 0; - } - - /** - * Returns true if the given command sender is allowed to use this command. - */ - public boolean canCommandSenderUseCommand(ICommandSender icommandsender) - { - return icommandsender instanceof Entity; - } - - public List<String> getCommandAliases() - { - return Arrays.asList(new String[] {"sm"}); - } - - public void processCommand(ICommandSender icommandsender, String[] astring) - { - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("ShipMod commands:")); - Iterator i$ = asCommands.iterator(); - - while (i$.hasNext()) - { - CommandBase cb = (CommandBase)i$.next(); - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d(cb.getCommandUsage(icommandsender))); - } - } - - public String getCommandUsage(ICommandSender icommandsender) - { - return "/sm or /smhelp"; - } -} diff --git a/src/shipmod/command/CommandKillShip.java b/src/shipmod/command/CommandKillShip.java deleted file mode 100644 index 82150f26..00000000 --- a/src/shipmod/command/CommandKillShip.java +++ /dev/null @@ -1,102 +0,0 @@ -package shipmod.command; - -import java.util.Iterator; -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.NumberInvalidException; -import net.minecraft.entity.Entity; -import net.minecraft.util.ChatMessageComponent; -import shipmod.entity.EntityShip; - -public class CommandKillShip extends CommandBase -{ - public String getCommandName() - { - return "killship"; - } - - public void processCommand(ICommandSender icommandsender, String[] astring) - { - if (icommandsender instanceof Entity) - { - double range = 16.0D; - - if (astring != null && astring.length > 0) - { - try - { - range = (double)Integer.parseInt(astring[0]); - } - catch (NumberFormatException var13) - { - throw new NumberInvalidException(); - } - } - - range *= range; - Entity player = (Entity)icommandsender; - EntityShip ne = null; - - if (player.ridingEntity instanceof EntityShip) - { - ne = (EntityShip)player.ridingEntity; - } - else - { - double nd = 0.0D; - Iterator i$ = player.worldObj.getLoadedEntityList().iterator(); - - while (i$.hasNext()) - { - Entity entity = (Entity)i$.next(); - - if (entity instanceof EntityShip) - { - double d = player.getDistanceSqToEntity(entity); - - if (d < range && (ne == null || d < nd)) - { - ne = (EntityShip)entity; - nd = d; - } - } - } - } - - if (ne == null) - { - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("No ship in a " + (int)range + " blocks\' range")); - return; - } - - if (!ne.decompileToBlocks(false)) - { - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Failed to decompile ship; dropping to items")); - ne.dropAsItems(); - } - - ne.setDead(); - } - } - - public String getCommandUsage(ICommandSender icommandsender) - { - return "/" + this.getCommandName() + " [range]"; - } - - /** - * Return the required permission level for this command. - */ - public int getRequiredPermissionLevel() - { - return 4; - } - - /** - * Returns true if the given command sender is allowed to use this command. - */ - public boolean canCommandSenderUseCommand(ICommandSender icommandsender) - { - return icommandsender instanceof Entity; - } -} diff --git a/src/shipmod/command/CommandReloadMetaRotations.java b/src/shipmod/command/CommandReloadMetaRotations.java deleted file mode 100644 index b4465492..00000000 --- a/src/shipmod/command/CommandReloadMetaRotations.java +++ /dev/null @@ -1,28 +0,0 @@ -package shipmod.command; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatMessageComponent; -import shipmod.ShipMod; - -public class CommandReloadMetaRotations extends CommandBase -{ - public String getCommandName() - { - return "reloadmeta"; - } - - public void processCommand(ICommandSender icommandsender, String[] astring) - { - if (this.canCommandSenderUseCommand(icommandsender)) - { - ShipMod.instance.metaRotations.readMetaRotationFiles(); - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Reloading MetaRotations")); - } - } - - public String getCommandUsage(ICommandSender icommandsender) - { - return "/" + this.getCommandName(); - } -} diff --git a/src/shipmod/command/CommandShipInfo.java b/src/shipmod/command/CommandShipInfo.java deleted file mode 100644 index 8d323afd..00000000 --- a/src/shipmod/command/CommandShipInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -package shipmod.command; - -import java.util.Locale; -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.Entity; -import net.minecraft.util.ChatMessageComponent; -import shipmod.entity.EntityShip; - -public class CommandShipInfo extends CommandBase -{ - public String getCommandName() - { - return "sminfo"; - } - - public void processCommand(ICommandSender icommandsender, String[] astring) - { - if (icommandsender instanceof Entity && ((Entity)icommandsender).ridingEntity instanceof EntityShip) - { - EntityShip ship = (EntityShip)((Entity)icommandsender).ridingEntity; - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Ship information")); - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(Locale.ENGLISH, "Position: %.2f, %.2f, %.2f", new Object[] {Double.valueOf(ship.posX), Double.valueOf(ship.posY), Double.valueOf(ship.posZ)}))); - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(Locale.ENGLISH, "Speed: %.2f km/h", new Object[] {Float.valueOf(ship.getHorizontalVelocity() * 20.0F * 3.6F)}))); - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(Locale.ENGLISH, "Ship health: %i / %i", new Object[] { Integer.valueOf(ship.health), Integer.valueOf(ship.getShipChunk().getBlockCount())}))); - - } - else - { - icommandsender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Not steering a ship")); - } - } - - /** - * Return the required permission level for this command. - */ - public int getRequiredPermissionLevel() - { - return 0; - } - - /** - * Returns true if the given command sender is allowed to use this command. - */ - public boolean canCommandSenderUseCommand(ICommandSender icommandsender) - { - return icommandsender instanceof Entity; - } - - public String getCommandUsage(ICommandSender icommandsender) - { - return "/".concat(this.getCommandName()); - } -} diff --git a/src/shipmod/command/CommandTpShip.java b/src/shipmod/command/CommandTpShip.java deleted file mode 100644 index c3441503..00000000 --- a/src/shipmod/command/CommandTpShip.java +++ /dev/null @@ -1,115 +0,0 @@ -package shipmod.command; - -import java.util.List; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.PlayerNotFoundException; -import net.minecraft.command.WrongUsageException; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.server.MinecraftServer; - -public class CommandTpShip extends CommandBase -{ - public String getCommandName() - { - return "tpship"; - } - - /** - * Return the required permission level for this command. - */ - public int getRequiredPermissionLevel() - { - return 4; - } - - public String getCommandUsage(ICommandSender par1ICommandSender) - { - return "commands.tp.usage"; - } - - public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) - { - if (par2ArrayOfStr.length < 1) - { - throw new WrongUsageException("Invalid command usage", new Object[0]); - } - else - { - EntityPlayerMP entityplayermp; - - if (par2ArrayOfStr.length != 2 && par2ArrayOfStr.length != 4) - { - entityplayermp = getCommandSenderAsPlayer(par1ICommandSender); - } - else - { - entityplayermp = func_82359_c(par1ICommandSender, par2ArrayOfStr[0]); - - if (entityplayermp == null) - { - throw new PlayerNotFoundException(); - } - } - - if (par2ArrayOfStr.length != 3 && par2ArrayOfStr.length != 4) - { - if (par2ArrayOfStr.length == 1 || par2ArrayOfStr.length == 2) - { - EntityPlayerMP entityplayermp1 = func_82359_c(par1ICommandSender, par2ArrayOfStr[par2ArrayOfStr.length - 1]); - - if (entityplayermp1 == null) - { - throw new PlayerNotFoundException(); - } - - if (entityplayermp1.worldObj != entityplayermp.worldObj) - { - notifyAdmins(par1ICommandSender, "commands.tp.notSameDimension", new Object[0]); - return; - } - - // Entity ship = entityplayermp.ridingEntity; - - //entityplayermp.mountEntity((Entity)null); - entityplayermp.ridingEntity.setPositionAndRotation(entityplayermp1.posX, Math.min(entityplayermp1.posY + 128, 255), entityplayermp1.posZ, entityplayermp.ridingEntity.rotationYaw, entityplayermp.ridingEntity.rotationPitch); - entityplayermp.playerNetServerHandler.setPlayerLocation(entityplayermp1.posX, Math.min(entityplayermp1.posY + 128, 255), entityplayermp1.posZ, entityplayermp1.rotationYaw, entityplayermp1.rotationPitch); - //entityplayermp.mountEntity(ship); - - notifyAdmins(par1ICommandSender, "commands.tp.success", new Object[] {entityplayermp.getEntityName(), entityplayermp1.getEntityName()}); - } - } - else if (entityplayermp.worldObj != null) - { - int i = par2ArrayOfStr.length - 3; - double d0 = func_110666_a(par1ICommandSender, entityplayermp.posX, par2ArrayOfStr[i++]); - double d1 = func_110665_a(par1ICommandSender, entityplayermp.posY, par2ArrayOfStr[i++], 0, 0); - double d2 = func_110666_a(par1ICommandSender, entityplayermp.posZ, par2ArrayOfStr[i++]); - //Entity ship = entityplayermp.ridingEntity; - //entityplayermp.mountEntity((Entity)null); - entityplayermp.ridingEntity.setPositionAndRotation(d0, d1, d2, entityplayermp.ridingEntity.rotationYaw, entityplayermp.ridingEntity.rotationPitch); - entityplayermp.setPositionAndUpdate(d0, d1, d2); - - notifyAdmins(par1ICommandSender, "commands.tp.success.coordinates", new Object[] {entityplayermp.getEntityName(), Double.valueOf(d0), Double.valueOf(d1), Double.valueOf(d2)}); - } - } - } - - /** - * Adds the strings available in this command to the given list of tab completion options. - */ - public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) - { - return par2ArrayOfStr.length != 1 && par2ArrayOfStr.length != 2 ? null : getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()); - } - - /** - * Return whether the specified command parameter index is a username parameter. - */ - public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) - { - return par2 == 0; - } -} diff --git a/src/shipmod/control/ShipController.java b/src/shipmod/control/ShipController.java deleted file mode 100644 index 0bd6648f..00000000 --- a/src/shipmod/control/ShipController.java +++ /dev/null @@ -1,19 +0,0 @@ -package shipmod.control; - -import net.minecraft.entity.player.EntityPlayer; -import shipmod.entity.EntityShip; - -public class ShipController -{ - private int shipControl = 0; - - public void updateControl(EntityShip ship, EntityPlayer player, int i) - { - this.shipControl = i; - } - - public int getShipControl() - { - return this.shipControl; - } -} diff --git a/src/shipmod/control/ShipControllerClient.java b/src/shipmod/control/ShipControllerClient.java deleted file mode 100644 index cd9a7d86..00000000 --- a/src/shipmod/control/ShipControllerClient.java +++ /dev/null @@ -1,20 +0,0 @@ -package shipmod.control; - -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; -import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.packet.Packet250CustomPayload; -import shipmod.entity.EntityShip; - -public class ShipControllerClient extends ShipController -{ - public void updateControl(EntityShip ship, EntityPlayer player, int i) - { - super.updateControl(ship, player, i); - ByteArrayDataOutput out = ByteStreams.newDataOutput(5); - out.writeInt(ship.entityId); - out.writeByte(i); - ((EntityClientPlayerMP)player).sendQueue.addToSendQueue(new Packet250CustomPayload("shipControl", out.toByteArray())); - } -} diff --git a/src/shipmod/control/ShipKeyHandler.java b/src/shipmod/control/ShipKeyHandler.java deleted file mode 100644 index ee202c2e..00000000 --- a/src/shipmod/control/ShipKeyHandler.java +++ /dev/null @@ -1,123 +0,0 @@ -package shipmod.control; - -import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; -import cpw.mods.fml.common.TickType; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.util.EnumSet; -import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.KeyBinding; -import shipmod.entity.EntityShip; - -@SideOnly(Side.CLIENT) -public class ShipKeyHandler extends KeyHandler -{ - private Minecraft mc = Minecraft.getMinecraft(); - public final KeyBinding kbUp; - public final KeyBinding kbDown; - public final KeyBinding kbBrake; - public final KeyBinding kbAlign; - - public ShipKeyHandler(KeyBinding up, KeyBinding down, KeyBinding brake, KeyBinding align) - { - super(new KeyBinding[] {up, down, brake, align}, new boolean[] {false, false, false, false}); - this.kbUp = up; - this.kbDown = down; - this.kbBrake = brake; - this.kbAlign = align; - } - - public String getLabel() - { - return "ShipMod key handler"; - } - - public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) - { - if (tickEnd) - { - this.keyEvent(kb, true); - } - } - - public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) - { - if (tickEnd) - { - this.keyEvent(kb, false); - } - } - - public void keyEvent(KeyBinding kb, boolean down) - { - if (this.mc.thePlayer != null && this.mc.thePlayer.ridingEntity instanceof EntityShip) - { - int c = 0; - - if (down) - { - if (kb == this.kbBrake) - { - c = 3; - } - else if (kb == this.kbAlign) - { - c = 4; - } - } - - if (c == 0) - { - int ship = 0; - - if (this.kbUp.isPressed()) - { - ++ship; - } - - if (this.kbDown.isPressed()) - { - --ship; - } - - c = ship == 0 ? 0 : (ship < 0 ? 1 : (ship > 0 ? 2 : 0)); - } - - EntityShip var5 = (EntityShip)this.mc.thePlayer.ridingEntity; - var5.getController().updateControl(var5, this.mc.thePlayer, c); - } - } - - public EnumSet<TickType> ticks() - { - return EnumSet.of(TickType.CLIENT); - } - - public int getHeightControl() - { - if (this.kbAlign.isPressed()) - { - return 4; - } - else if (this.kbBrake.isPressed()) - { - return 3; - } - else - { - int i = 0; - - if (this.kbUp.isPressed()) - { - ++i; - } - - if (this.kbDown.isPressed()) - { - --i; - } - - return i == 0 ? 0 : (i < 0 ? 1 : (i > 0 ? 2 : 0)); - } - } -} diff --git a/src/shipmod/entity/EntityShip.java b/src/shipmod/entity/EntityShip.java deleted file mode 100644 index bcb462f1..00000000 --- a/src/shipmod/entity/EntityShip.java +++ /dev/null @@ -1,1320 +0,0 @@ -package shipmod.entity; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ic2.api.network.NetworkHelper; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.EnumEntitySize; -import net.minecraft.entity.item.EntityBoat; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.packet.Packet250CustomPayload; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.util.DamageSource; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; -import net.minecraft.world.ChunkPosition; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; -import shipmod.ShipMod; -import shipmod.chunk.LocatedBlock; -import shipmod.chunk.MobileChunk; -import shipmod.control.ShipController; -import shipmod.control.ShipControllerClient; -import shipmod.util.AABBRotator; -import shipmod.util.MathHelperMod; - -public class EntityShip extends EntityBoat implements IEntityAdditionalSpawnData -{ - public int fuelLevel = 0; - public static final float BASE_FORWARD_SPEED = 0.006F; - public static final float BASE_TURN_SPEED = 0.34F; - public static final float BASE_LIFT_SPEED = 0.005F; - private MobileChunk shipChunk; - private ShipCapabilities capabilities; - private ShipController controller; - public float motionYaw; - public int frontDirection; - public int seatX; - public int seatY; - public int seatZ; - private Entity prevRiddenByEntity; - private boolean isFlying; - protected float groundFriction; - protected float horFriction; - protected float vertFriction; - private int[] layeredBlockVolumeCount; - private boolean riddenByOtherPlayer; - private boolean syncPosWithServer; - @SideOnly(Side.CLIENT) - private int boatPosRotationIncrements; - @SideOnly(Side.CLIENT) - private double boatX; - @SideOnly(Side.CLIENT) - private double boatY; - @SideOnly(Side.CLIENT) - private double boatZ; - @SideOnly(Side.CLIENT) - private double boatPitch; - @SideOnly(Side.CLIENT) - private double boatYaw; - @SideOnly(Side.CLIENT) - private double boatVelX; - @SideOnly(Side.CLIENT) - private double boalVelY; - @SideOnly(Side.CLIENT) - private double boatVelZ; - - public ArrayList<EntityLivingBase> playersOnShip = new ArrayList<EntityLivingBase>(); - public int health; - - private int sourceYaw; - private boolean explosionFlag = false; - - public static boolean isAABBInLiquidNotFall(World world, AxisAlignedBB aabb) - { - int i = MathHelper.floor_double(aabb.minX); - int j = MathHelper.floor_double(aabb.maxX + 1.0D); - int k = MathHelper.floor_double(aabb.minY); - int l = MathHelper.floor_double(aabb.maxY + 1.0D); - int i1 = MathHelper.floor_double(aabb.minZ); - int j1 = MathHelper.floor_double(aabb.maxZ + 1.0D); - - for (int k1 = i; k1 < j; ++k1) - { - for (int l1 = k; l1 < l; ++l1) - { - for (int i2 = i1; i2 < j1; ++i2) - { - Block block = Block.blocksList[world.getBlockId(k1, l1, i2)]; - - if (block != null && (block.blockMaterial == Material.water || block.blockMaterial == Material.lava)) - { - int j2 = world.getBlockMetadata(k1, l1, i2); - double d0 = (double)(l1 + 1); - - if (j2 < 8) - { - d0 = (double)(l1 + 1) - (double)j2 / 8.0D; - - if (d0 >= aabb.minY) - { - return true; - } - } - } - } - } - } - - return false; - } - - public EntityShip(World world) - { - super(world); - this.shipChunk = new MobileChunk(world, this); - this.capabilities = new ShipCapabilities(); - - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - this.controller = new ShipControllerClient(); - } - else - { - this.controller = new ShipController(); - } - - this.motionYaw = 0.0F; - this.layeredBlockVolumeCount = null; - this.frontDirection = 0; - this.yOffset = 0.0F; - this.groundFriction = 0.9F; - this.horFriction = 0.994F; - this.vertFriction = 0.95F; - this.prevRiddenByEntity = null; - this.isFlying = false; - this.riddenByOtherPlayer = false; - this.syncPosWithServer = true; - - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - this.boatPosRotationIncrements = 0; - this.boatX = this.boatY = this.boatZ = 0.0D; - this.boatPitch = this.boatYaw = 0.0D; - this.boatVelX = this.boalVelY = this.boatVelZ = 0.0D; - } - } - - @Override - protected void entityInit() - { - this.dataWatcher.addObject(30, Byte.valueOf((byte)0)); - } - - public MobileChunk getShipChunk() - { - return this.shipChunk; - } - - public ShipCapabilities getCapabilities() - { - return this.capabilities; - } - - public ShipController getController() - { - return this.controller; - } - - public void setFrontDirection(int dir) - { - this.frontDirection = dir; - } - - public void onChunkBlockAdded(int id, int metadata) - { - if (id != 0) - { - this.capabilities.onChunkBlockAdded(id, metadata); - } - } - - /** - * Will get destroyed next tick. - */ - @Override - public void setDead() - { - super.setDead(); - this.shipChunk.onChunkUnload(); - } - - /** - * Gets called every tick from main Entity class - */ - @Override - public void onEntityUpdate() - { - super.onEntityUpdate(); - - if (this.shipChunk.chunkUpdated) - { - this.shipChunk.chunkUpdated = false; - this.setSize((float)Math.max(this.shipChunk.maxX() - this.shipChunk.minX(), this.shipChunk.maxZ() - this.shipChunk.minZ()), (float)(this.shipChunk.maxY() - this.shipChunk.minY())); - World.MAX_ENTITY_RADIUS = Math.max(World.MAX_ENTITY_RADIUS, (double)Math.max(this.width, this.height)) + 2.0D; - - try - { - this.fillAirBlocks(new HashSet(), -1, -1, -1); - } - catch (StackOverflowError var4) - { - System.err.println(var4.toString()); - } - - this.layeredBlockVolumeCount = new int[this.shipChunk.maxX() - this.shipChunk.minX()]; - - for (int y = 0; y < this.layeredBlockVolumeCount.length; ++y) - { - for (int i = this.shipChunk.minX(); i < this.shipChunk.maxX(); ++i) - { - for (int j = this.shipChunk.minZ(); j < this.shipChunk.maxZ(); ++j) - { - if (this.shipChunk.isBlockTakingWaterVolume(i, y + this.shipChunk.minY(), j)) - { - ++this.layeredBlockVolumeCount[y]; - } - } - } - } - - this.isFlying = this.capabilities.canFly(); - } - } - - public void setRotatedBoundingBox() - { - if (this.shipChunk == null) - { - float hw = this.width / 2.0F; - this.boundingBox.setBounds(this.posX - (double)hw, this.posY, this.posZ - (double)hw, this.posX + (double)hw, this.posY + (double)this.height, this.posZ + (double)hw); - } - else - { - this.boundingBox.setBounds(this.posX - (double)this.shipChunk.getCenterX(), this.posY, this.posZ - (double)this.shipChunk.getCenterZ(), this.posX + (double)this.shipChunk.getCenterX(), this.posY + (double)this.height, this.posZ + (double)this.shipChunk.getCenterZ()); - AABBRotator.rotateAABBAroundY(this.boundingBox, this.posX, this.posZ, (float)Math.toRadians((double)this.rotationYaw)); - } - } - - /** - * Sets the width and height of the entity. Args: width, height - */ - @Override - public void setSize(float w, float h) - { - float f; - - if (w != this.width || h != this.height) - { - this.width = w; - this.height = h; - f = w / 2.0F; - this.boundingBox.setBounds(this.posX - (double)f, this.posY, this.posZ - (double)f, this.posX + (double)f, this.posY + (double)this.height, this.posZ + (double)f); - } - - f = w % 2.0F; - - if ((double)f < 0.375D) - { - this.myEntitySize = EnumEntitySize.SIZE_1; - } - else if ((double)f < 0.75D) - { - this.myEntitySize = EnumEntitySize.SIZE_2; - } - else if ((double)f < 1.0D) - { - this.myEntitySize = EnumEntitySize.SIZE_3; - } - else if ((double)f < 1.375D) - { - this.myEntitySize = EnumEntitySize.SIZE_4; - } - else if ((double)f < 1.75D) - { - this.myEntitySize = EnumEntitySize.SIZE_5; - } - else - { - this.myEntitySize = EnumEntitySize.SIZE_6; - } - } - - @Override - @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 x, double y, double z, float yaw, float pitch, int incr) - { - if (this.riddenByOtherPlayer) - { - this.boatPosRotationIncrements = incr + 5; - } - else - { - double dx = x - this.posX; - double dy = y - this.posY; - double dz = z - this.posZ; - double d = dx * dx + dy * dy + dz * dz; - - if (d < 0.3D) - { - return; - } - - this.syncPosWithServer = true; - this.boatPosRotationIncrements = incr; - } - - this.boatX = x; - this.boatY = y; - this.boatZ = z; - this.boatYaw = (double)yaw; - this.boatPitch = (double)pitch; - this.motionX = this.boatVelX; - this.motionY = this.boalVelY; - this.motionZ = this.boatVelZ; - } - - @Override - @SideOnly(Side.CLIENT) - - /** - * Sets the velocity to the args. Args: x, y, z - */ - public void setVelocity(double x, double y, double z) - { - this.boatVelX = this.motionX = x; - this.boalVelY = this.motionY = y; - this.boatVelZ = this.motionZ = z; - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void onUpdate() - { - this.onEntityUpdate(); - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - double horvel = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); - - if (FMLCommonHandler.instance().getEffectiveSide().isClient() && (this.riddenByOtherPlayer || this.syncPosWithServer)) - { - this.handleClientUpdate(); - - if (this.boatPosRotationIncrements == 0) - { - this.syncPosWithServer = false; - } - } - else - { - this.handleServerUpdate(horvel); - } - } - - @SideOnly(Side.CLIENT) - protected void handleClientUpdate() - { - if (this.boatPosRotationIncrements > 0) - { - double dx = this.posX + (this.boatX - this.posX) / (double)this.boatPosRotationIncrements; - double dy = this.posY + (this.boatY - this.posY) / (double)this.boatPosRotationIncrements; - double dz = this.posZ + (this.boatZ - this.posZ) / (double)this.boatPosRotationIncrements; - double ang = MathHelper.wrapAngleTo180_double(this.boatYaw - (double)this.rotationYaw); - this.rotationYaw = (float)((double)this.rotationYaw + ang / (double)this.boatPosRotationIncrements); - this.rotationPitch = (float)((double)this.rotationPitch + (this.boatPitch - (double)this.rotationPitch) / (double)this.boatPosRotationIncrements); - --this.boatPosRotationIncrements; - this.setPosition(dx, dy, dz); - this.setRotation(this.rotationYaw, this.rotationPitch); - } - else - { - this.setPosition(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - - if (this.onGround) - { - this.motionX *= (double)this.groundFriction; - this.motionY *= (double)this.groundFriction; - this.motionZ *= (double)this.groundFriction; - } - - this.motionX *= (double)this.horFriction; - this.motionY *= (double)this.vertFriction; - this.motionZ *= (double)this.horFriction; - } - - this.setRotatedBoundingBox(); - movePlayers(); - } - - private void movePlayers() { - // Grab players on ship - List entities = worldObj.getEntitiesWithinAABBExcludingEntity(riddenByEntity, this.boundingBox); - if (entities != null && !entities.isEmpty()) { - for (Object o : entities) { - if (o != null && o instanceof EntityPlayer) { - EntityPlayer e = (EntityPlayer)o; - - if (!e.isSneaking()) { - updateRiderPosition(e, seatX, seatY, seatZ); - } - } - } - } - } - - protected void handleServerUpdate(double horvel) - { - if (this.riddenByEntity == null && this.prevRiddenByEntity != null) - { - this.prevRiddenByEntity.mountEntity(this); - - if (!this.decompileToBlocks(false) && !ShipMod.instance.modConfig.remountOnDecompilationFail) - { - this.riddenByEntity.mountEntity((Entity)null); - } - - this.prevRiddenByEntity = null; - } - - if (this.riddenByEntity != null) - { - this.handlePlayerControl(); - this.prevRiddenByEntity = this.riddenByEntity; - } - - this.fuelLevel--; - if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) { - if (fuelLevel == 20 * 10) { - ((EntityPlayer)this.riddenByEntity).addChatMessage("[ShipMod] Low fuel level. 10 seconds remaining"); - } - - if (fuelLevel <= 0) { - ((EntityPlayer)this.riddenByEntity).addChatMessage("[ShipMod] Ship is out of fuel"); - - if (!this.decompileToBlocks(false)) { - dropAsItems(); - } - } - } - double var25 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); - double maxvel = (double)ShipMod.instance.modConfig.speedLimit; - double list; - - if (var25 > maxvel) - { - list = maxvel / var25; - this.motionX *= list; - this.motionZ *= list; - } - - this.motionY = MathHelperMod.clamp_double(this.motionY, -maxvel, maxvel); - - if (this.onGround) - { - this.motionX *= (double)this.groundFriction; - this.motionY *= (double)this.groundFriction; - this.motionZ *= (double)this.groundFriction; - } - - this.motionYaw *= 0.7F; - this.rotationYaw += this.motionYaw; - this.setRotatedBoundingBox(); - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.posY = Math.min(this.posY, (double)this.worldObj.getHeight()); - this.motionX *= (double)this.horFriction; - this.motionY *= (double)this.vertFriction; - this.motionZ *= (double)this.horFriction; - this.rotationPitch = 0.0F; - - if (ShipMod.instance.modConfig.shipControlType == 0) - { - list = (double)this.rotationYaw; - double i1 = this.prevPosX - this.posX; - double k1 = this.prevPosZ - this.posZ; - - if (this.riddenByEntity != null && !this.isBraking() && i1 * i1 + k1 * k1 > 0.01D) - { - list = 270.0D - Math.toDegrees(Math.atan2(k1, i1)) + (double)((float)this.frontDirection * 90.0F); - } - - double i2 = MathHelper.wrapAngleTo180_double(list - (double)this.rotationYaw); - double maxyawspeed = 2.0D; - - if (i2 > maxyawspeed) - { - i2 = maxyawspeed; - } - - if (i2 < -maxyawspeed) - { - i2 = -maxyawspeed; - } - - this.rotationYaw = (float)((double)this.rotationYaw + i2); - } - - this.setRotation(this.rotationYaw, this.rotationPitch); - - movePlayers(); - } - - private void handlePlayerControl() - { - if (this.riddenByEntity instanceof EntityLivingBase) - { - double i = (double)((EntityLivingBase)this.riddenByEntity).moveForward; - - if (this.isFlying()) - { - i *= 0.5D; - } - - if (ShipMod.instance.modConfig.shipControlType == 1) - { - Vec3 dsin = this.worldObj.getWorldVec3Pool().getVecFromPool(this.riddenByEntity.motionX, 0.0D, this.riddenByEntity.motionZ); - dsin.rotateAroundY((float)Math.toRadians((double)this.riddenByEntity.rotationYaw)); - double steer = (double)((EntityLivingBase)this.riddenByEntity).moveStrafing; - this.motionYaw = (float)((double)this.motionYaw + steer * 0.3499999940395355D * (double)this.capabilities.rotationMultiplier * (double)ShipMod.instance.modConfig.turnSpeed); - float yaw = (float)Math.toRadians((double)(180.0F - this.rotationYaw + (float)this.frontDirection * 90.0F)); - dsin.xCoord = this.motionX; - dsin.zCoord = this.motionZ; - dsin.rotateAroundY(yaw); - dsin.xCoord *= 0.9D; - dsin.zCoord -= i * 0.004999999888241291D * (double)this.capabilities.speedMultiplier; - dsin.rotateAroundY(-yaw); - this.motionX = dsin.xCoord; - this.motionZ = dsin.zCoord; - } - else if (ShipMod.instance.modConfig.shipControlType == 0 && i > 0.0D) - { - double dsin1 = -Math.sin(Math.toRadians((double)this.riddenByEntity.rotationYaw)); - double dcos = Math.cos(Math.toRadians((double)this.riddenByEntity.rotationYaw)); - this.motionX += dsin1 * 0.004999999888241291D * (double)this.capabilities.speedMultiplier; - this.motionZ += dcos * 0.004999999888241291D * (double)this.capabilities.speedMultiplier; - } - } - - if (this.controller.getShipControl() != 0) - { - if (this.controller.getShipControl() == 4) - { - this.alignToGrid(); - } - else if (this.isBraking()) - { - this.motionX *= (double)this.capabilities.brakeMult; - this.motionZ *= (double)this.capabilities.brakeMult; - - if (this.isFlying()) - { - this.motionY *= (double)this.capabilities.brakeMult; - } - } - else if (this.controller.getShipControl() < 3 && this.capabilities.canFly()) - { - byte i1; - - if (this.controller.getShipControl() == 2) - { - this.isFlying = true; - i1 = 1; - } - else - { - i1 = -1; - } - - this.motionY += (double)((float)i1 * 0.004F * this.capabilities.liftMultiplier); - } - } - } - - public boolean isFlying() - { - return true; - } - - public boolean isBraking() - { - return this.controller.getShipControl() == 3; - } - - @Override - public boolean func_96092_aw() - { - return this.ticksExisted > 60; - } - - @Override - @SideOnly(Side.CLIENT) - public void func_70270_d(boolean flag) - { - this.riddenByOtherPlayer = flag; - } - - @Override - public boolean shouldRiderSit() - { - return true; - } - - @Override - public void updateRiderPosition() - { - this.updateRiderPosition(this.riddenByEntity, this.seatX, this.seatY, this.seatZ); - } - - public void updateRiderPosition(Entity entity, int seatx, int seaty, int seatz) - { - if (entity != null) - { - float yaw = (float)Math.toRadians((double)this.rotationYaw); - int x1 = seatx; - int y1 = seaty; - int z1 = seatz; - - if (this.frontDirection == 0) - { - z1 = seatz - 1; - } - else if (this.frontDirection == 1) - { - x1 = seatx + 1; - } - else if (this.frontDirection == 2) - { - z1 = seatz + 1; - } - else if (this.frontDirection == 3) - { - x1 = seatx - 1; - } - - int id = this.shipChunk.getBlockId(x1, MathHelper.floor_double((double)seaty + this.getMountedYOffset() + entity.getYOffset()), z1); - - if (id != 0 && Block.blocksList[id] != null && Block.blocksList[id].isOpaqueCube()) - { - x1 = seatx; - y1 = seaty; - z1 = seatz; - } - - Vec3 vec = this.worldObj.getWorldVec3Pool().getVecFromPool((double)((float)x1 - this.shipChunk.getCenterX()) + 0.5D, (double)(y1 - this.shipChunk.minY()) + this.getMountedYOffset(), (double)((float)z1 - this.shipChunk.getCenterZ()) + 0.5D); - vec.rotateAroundY(yaw); - entity.setPosition(this.posX + vec.xCoord, this.posY + vec.yCoord + entity.getYOffset(), this.posZ + vec.zCoord); - } - } - - /** - * Returns the Y offset from the entity's position for any entity riding this one. - */ - @Override - public double getMountedYOffset() - { - return (double)this.yOffset + 0.5D; - } - - /** - * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to - * prevent them from trampling crops - */ - @Override - protected boolean canTriggerWalking() - { - return false; - } - - /** - * 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. - */ - @Override - public AxisAlignedBB getCollisionBox(Entity entity) - { - return null; - } - - /** - * returns the bounding box for this entity - */ - @Override - public AxisAlignedBB getBoundingBox() - { - return this.boundingBox; - } - - /** - * Returns true if this entity should push and be pushed by other entities when colliding. - */ - @Override - public boolean canBePushed() - { - return false; - } - - /** - * Returns true if other Entities should be prevented from moving through this Entity. - */ - @Override - public boolean canBeCollidedWith() - { - return !this.isDead; - } - - /** - * Called when the entity is attacked. - */ - @Override - public boolean attackEntityFrom(DamageSource source, float damage) - { - this.health -= damage; - System.out.println("[SHIP] Entity damaged: -" + damage + ". Health: " + this.health + "/" + shipChunk.getBlockCount()); - - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { - return true; - } - - if (this.health <= 0 && !this.isDead) { - ((EntityPlayer)this.riddenByEntity).addChatMessage("[ShipMod] MOVEABLE SHIP IS DESTROYED"); - - this.explosionFlag = true; - - if (!this.decompileToBlocks(false)) { - dropAsItems(); - this.setDead(); - return true; - } - } - - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() - { - return 0.5F; - } - - public float getHorizontalVelocity() - { - return (float)Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); - } - - @Override - public boolean func_130002_c(EntityPlayer entityplayer) - { - if (this.riddenByEntity != null && this.riddenByEntity != entityplayer) - { - return true; - } - else - { - if (FMLCommonHandler.instance().getEffectiveSide().isClient() && entityplayer.getDistanceSqToEntity(this) >= 36.0D) - { - ByteArrayDataOutput out = ByteStreams.newDataOutput(4); - out.writeInt(this.entityId); - Packet250CustomPayload packet = new Packet250CustomPayload("shipInteract", out.toByteArray()); - ((EntityClientPlayerMP)entityplayer).sendQueue.addToSendQueue(packet); - } - - if (this.riddenByEntity == entityplayer) - { - if (ShipMod.instance.modConfig.enableRightClickDismount) - { - this.decompileToBlocks(false); - } - } - else if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - entityplayer.mountEntity(this); - } - - return true; - } - } - - public void alignToGrid() - { - this.rotationYaw = (float)Math.round(this.rotationYaw / 90.0F) * 90.0F; - this.rotationPitch = 0.0F; - this.posX = (double)MathHelperMod.round_double(this.posX); - this.posY = (double)MathHelperMod.round_double(this.posY); - this.posZ = (double)MathHelperMod.round_double(this.posZ); - this.motionX = this.motionY = this.motionZ = 0.0D; - } - - public boolean canDecompile() - { - float yaw = (float)Math.round(this.rotationYaw / 90.0F) * 90.0F; - yaw = (float)Math.toRadians((double)this.rotationYaw); - float ox = -this.shipChunk.getCenterX(); - float oy = (float)(-this.shipChunk.minY()); - float oz = -this.shipChunk.getCenterZ(); - Vec3 vec = this.worldObj.getWorldVec3Pool().getVecFromPool(0.0D, 0.0D, 0.0D); - - for (int i = this.shipChunk.minX(); i < this.shipChunk.maxX(); ++i) - { - for (int j = this.shipChunk.minY(); j < this.shipChunk.maxY(); ++j) - { - for (int k = this.shipChunk.minZ(); k < this.shipChunk.maxZ(); ++k) - { - if (!this.shipChunk.isAirBlock(i, j, k)) - { - vec.xCoord = (double)((float)i + ox); - vec.yCoord = (double)((float)j + oy); - vec.zCoord = (double)((float)k + oz); - vec.rotateAroundY(yaw); - int ix = MathHelperMod.round_double(vec.xCoord + this.posX); - int iy = MathHelperMod.round_double(vec.yCoord + this.posY); - int iz = MathHelperMod.round_double(vec.zCoord + this.posZ); - int id = this.worldObj.getBlockId(ix, iy, iz); - - if (id != 0 && Block.blocksList[id] != null && !Block.blocksList[id].isAirBlock(this.worldObj, ix, iy, iz) && !Block.blocksList[id].blockMaterial.isLiquid() && !ShipMod.instance.modConfig.overwritableBlocks.contains(Integer.valueOf(id))) - { - return false; - } - } - } - } - } - - return true; - } - - public boolean decompileToBlocks(boolean overwrite) - { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return true; - } - else if (!overwrite && !this.canDecompile()) - { - if (this.prevRiddenByEntity instanceof EntityPlayer) - { - ((EntityPlayer)this.prevRiddenByEntity).addChatMessage("Cannot decompile ship here"); - } - - return false; - } - else - { - ArrayList<ChunkCoordinates> explosions = new ArrayList<ChunkCoordinates>(); - ArrayList<TileEntity> IC2MachinesToUpdateFacing = new ArrayList<TileEntity>(); - - int currentrotation = Math.round(this.rotationYaw / 90.0F); - int deltarotation = -(currentrotation & 3); - this.rotationYaw = (float)currentrotation * 90.0F; - this.rotationPitch = 0.0F; - float yaw = (float)Math.toRadians((double)this.rotationYaw); - this.updateRiderPosition(); - - if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - this.worldObj.isRemote = true; // lock world from changes - boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("doTileDrops"); - this.worldObj.getGameRules().setOrCreateGameRule("doTileDrops", "false"); - ArrayList list = new ArrayList(); - float ox = -this.shipChunk.getCenterX(); - float oy = (float)(-this.shipChunk.minY()); - float oz = -this.shipChunk.getCenterZ(); - Vec3 vec = this.worldObj.getWorldVec3Pool().getVecFromPool(0.0D, 0.0D, 0.0D); - - for (int x = this.shipChunk.minX(); x <= this.shipChunk.maxX(); x++) - { - for (int z = this.shipChunk.minZ(); z <= this.shipChunk.maxZ(); z++) - { - for (int y = this.shipChunk.minY(); y <= this.shipChunk.maxY(); y++) - { - TileEntity tileentity = this.shipChunk.getBlockTileEntity(x, y, z); - int id = this.shipChunk.getBlockId(x, y, z); - int meta = this.shipChunk.getBlockMetadata(x, y, z); - - if (id == 0) - { - if (meta == 1) - { - continue; - } - } - else if (Block.blocksList[id] == null || Block.blocksList[id].isAirBlock(this.worldObj, x, y, z)) - { - continue; - } - - int newMeta = meta; - - for (int i = 0; i < -deltarotation; i++) { - newMeta = ShipMod.instance.metaRotations.rotate90Reverse(id, newMeta); - } - - if (id == 1225) { - // Rotate computer - for (int i = 0; i < -deltarotation; i++) { - newMeta = ShipMod.instance.metaRotations.rotateComputer90Reverse(newMeta); - } - } else if (id == 1226) { // Rotate peripherals (Disk drive, printer, modem, monitors) - NBTTagCompound NBT = new NBTTagCompound(); - tileentity.writeToNBT(NBT); - int oldDir = NBT.getInteger("dir"); - int newDir = oldDir; - int subType = ShipMod.instance.metaRotations.getCCSubtypeFromMetadata(meta); - - - if (subType == 0) { // Disk drive - for (int i = 0; i < -deltarotation; i++) { - newMeta = ShipMod.instance.metaRotations.rotateCCBlock90Reverse(newMeta); - } - } else if (subType == 1) { // Modems - /*System.out.println("Delta: " + deltarotation); - System.out.println("Old dir: " + oldDir); - System.out.println("Old meta: " + meta); - System.out.println("Rot from meta: " + ShipMod.instance.metaRotations.getCCDirectionFromMetadata(meta)); - */ - newMeta = ShipMod.instance.metaRotations.getCCDirectionFromMetadata(meta); - - for (int i = 0; i < -deltarotation; i++) { - newMeta = ShipMod.instance.metaRotations.rotateCCBlock90Reverse(newMeta); - newDir = ShipMod.instance.metaRotations.rotateCCBlock90Reverse(newDir); - } - - if (newDir >= 2) { - newMeta = 4 + newMeta; - } - //System.out.println("newDir: " + newDir); - NBT.setInteger("dir", newDir); - tileentity.readFromNBT(NBT); - //System.out.println("New meta: " + newMeta); - } else { // Printer, monitors - //System.out.println("Delta: " + deltarotation); - //System.out.println("Old dir: " + oldDir); - - // Rotate peripheral - for (int i = 0; i < -deltarotation; i++) { - newDir = ShipMod.instance.metaRotations.rotateCCBlock90Reverse(newDir); - } - - NBT.setInteger("dir", newDir); - tileentity.readFromNBT(NBT); - - //System.out.println("New dir: " + newDir); - } - } else if (id == 1229) { - int subType = meta >= 0 && meta < 6 ? 1 : (meta >= 6 && meta < 12 ? 2 : 0); - int dir = meta % 6; - /* - System.out.println("Old meta: " + meta); - System.out.println("Subtype: " + subType); - System.out.println("Dir: " + dir); - */ - if (subType == 1 || subType == 2) { - //System.out.println("Found wired modem"); - for (int i = 0; i < -deltarotation; i++) { - newMeta = ShipMod.instance.metaRotations.rotateCCBlock90Reverse(newMeta); - } - - newMeta += 6 * (subType - 1); - - //System.out.println("New meta: " + newMeta); - } - } - - if (newMeta == meta) { - newMeta = ShipMod.instance.metaRotations.getRotatedMeta(id, newMeta, deltarotation); - } - - // Rotate specific machines - if (ShipMod.instance.metaRotations.examForIC2Machine(tileentity)) { - short newFacing, oldFacing; - NBTTagCompound NBT = new NBTTagCompound(); - tileentity.writeToNBT(NBT); - oldFacing = NBT.getShort("facing"); - newFacing = oldFacing; - for (int i = 0; i < -deltarotation; i++) { - newFacing = ShipMod.instance.metaRotations.rotateIC2MachineFacing90Reverse(newFacing); - } - NBT.setShort("facing", newFacing); - tileentity.readFromNBT(NBT); - - // Updating via network - try { - NetworkHelper.updateTileEntityField(tileentity, "facing"); - } catch (Exception e) { - e.printStackTrace(); - } - IC2MachinesToUpdateFacing.add(tileentity); - } else - if (ShipMod.instance.metaRotations.examForAEMachine(tileentity)) { - int newFacing, oldFacing; - NBTTagCompound NBT = new NBTTagCompound(); - tileentity.writeToNBT(NBT); - String tagName = "unknown"; - // Select tag name - if (NBT.getTag("r") != null) - tagName = "r"; - else if (NBT.getTag("rot") != null) - tagName = "rot"; - else if (NBT.getTag("ori") != null) - tagName = "ori"; - - if (tagName != "unknown") { - boolean isCableOrBus = (tagName == "ori"); - - if (!isCableOrBus) { - oldFacing = NBT.getInteger(tagName); - } else - oldFacing = NBT.getByte(tagName); - - System.out.println(((isCableOrBus) ? "[cable|bus] " : "") + tagName + ": " + oldFacing); - newFacing = oldFacing; - - if (!isCableOrBus) { - for (int i = 0; i < -deltarotation; i++) { - newFacing = ShipMod.instance.metaRotations.rotateAEMachineFacing90Reverse(newFacing); - } - } else { - for (int i = 0; i < -deltarotation; i++) { - newFacing = ShipMod.instance.metaRotations.rotateAECableFacing90Reverse(newFacing); - } - } - - if (tagName != "ori") { - NBT.setInteger(tagName, newFacing); - } else - NBT.setByte(tagName, (byte)newFacing); - - tileentity.readFromNBT(NBT); - } - } - - //meta = ShipMod.instance.metaRotations.getRotatedMeta(id, meta, deltarotation); - vec.xCoord = (double)((float)x + ox); - vec.yCoord = (double)((float)y + oy); - vec.zCoord = (double)((float)z + oz); - vec.rotateAroundY(yaw); - int ix = MathHelperMod.round_double(vec.xCoord + this.posX); - int iy = MathHelperMod.round_double(vec.yCoord + this.posY); - int iz = MathHelperMod.round_double(vec.zCoord + this.posZ); - this.worldObj.setBlock(ix, iy, iz, id, newMeta, 2); - - if (explosionFlag && worldObj.rand.nextInt(30) == 0) { - explosions.add(new ChunkCoordinates(ix, iy, iz)); - } - - if (id != this.worldObj.getBlockId(ix, iy, iz)) - { - list.add(new LocatedBlock(id, newMeta, new ChunkPosition(ix, iy, iz))); - } - else - { - if (newMeta != this.worldObj.getBlockMetadata(ix, iy, iz)) - { - this.worldObj.setBlockMetadataWithNotify(ix, iy, iz, newMeta, 2); - } - - if (tileentity != null) - { - this.worldObj.setBlockTileEntity(ix, iy, iz, tileentity); - tileentity.blockMetadata = newMeta; - } - } - } - } - } - - this.worldObj.getGameRules().setOrCreateGameRule("doTileDrops", String.valueOf(flag)); - Iterator var20 = list.iterator(); - - while (var20.hasNext()) - { - LocatedBlock var21 = (LocatedBlock)var20.next(); - ShipMod.modLogger.finest("Post-rejoining block: " + var21.toString()); - this.worldObj.setBlock(var21.coords.x, var21.coords.y, var21.coords.z, var21.blockID, var21.blockMeta, 2); - } - - worldObj.isRemote = false; - this.setDead(); - - for (TileEntity machine : IC2MachinesToUpdateFacing) { - try { - NetworkHelper.updateTileEntityField(machine, "facing"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - for (ChunkCoordinates e : explosions) { - worldObj.newExplosion(null, e.posX, e.posY, e.posZ, 4F, true, true); - } - - explosionFlag = false; - } - - return true; - } - } - - public void dropAsItems() - { - for (int i = this.shipChunk.minX(); i < this.shipChunk.maxX(); ++i) - { - for (int j = this.shipChunk.minY(); j < this.shipChunk.maxY(); ++j) - { - for (int k = this.shipChunk.minZ(); k < this.shipChunk.maxZ(); ++k) - { - this.shipChunk.getBlockTileEntity(i, j, k); - int id = this.shipChunk.getBlockId(i, j, k); - - if (id != 0 && Block.blocksList[id] != null && (worldObj.rand.nextBoolean())) - { - int meta = this.shipChunk.getBlockMetadata(i, j, k); - Block.blocksList[id].dropBlockAsItem(this.worldObj, i, j, k, meta, 0); - this.shipChunk.setBlockAsFilledAir(i, j, k); - this.shipChunk.setChunkModified(); - } - } - } - } - } - - private void fillAirBlocks(Set<ChunkPosition> set, int x, int y, int z) - { - if (x >= this.shipChunk.minX() - 1 && x <= this.shipChunk.maxX() && y >= this.shipChunk.minY() - 1 && y <= this.shipChunk.maxY() && z >= this.shipChunk.minZ() - 1 && z <= this.shipChunk.maxZ()) - { - ChunkPosition pos = new ChunkPosition(x, y, z); - - if (!set.contains(pos)) - { - set.add(pos); - - if (this.shipChunk.setBlockAsFilledAir(x, y, z)) - { - this.fillAirBlocks(set, x, y + 1, z); - this.fillAirBlocks(set, x - 1, y, z); - this.fillAirBlocks(set, x, y, z - 1); - this.fillAirBlocks(set, x + 1, y, z); - this.fillAirBlocks(set, x, y, z + 1); - } - } - } - } - - /** - * Called when the mob is falling. Calculates and applies fall damage. - */ - protected void fall(float distance) {} - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - protected void writeEntityToNBT(NBTTagCompound compound) - { - super.writeEntityToNBT(compound); - ByteArrayOutputStream baos = new ByteArrayOutputStream(this.shipChunk.getMemoryUsage()); - DataOutputStream out = new DataOutputStream(baos); - - try - { - this.shipChunk.writeChunkData(out); - out.flush(); - out.close(); - } - catch (IOException var8) - { - var8.printStackTrace(); - } - - compound.setByteArray("chunk", baos.toByteArray()); - compound.setByte("seatX", (byte)this.seatX); - compound.setByte("seatY", (byte)this.seatY); - compound.setByte("seatZ", (byte)this.seatZ); - compound.setByte("front", (byte)this.frontDirection); - - if (!this.shipChunk.chunkTileEntityMap.isEmpty()) - { - NBTTagList tileentities = new NBTTagList(); - Iterator i$ = this.shipChunk.chunkTileEntityMap.values().iterator(); - - while (i$.hasNext()) - { - TileEntity tileentity = (TileEntity)i$.next(); - NBTTagCompound comp = new NBTTagCompound(); - tileentity.writeToNBT(comp); - tileentities.appendTag(comp); - } - - compound.setTag("tileent", tileentities); - } - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - protected void readEntityFromNBT(NBTTagCompound compound) - { - super.readEntityFromNBT(compound); - byte[] ab = compound.getByteArray("chunk"); - ByteArrayInputStream bais = new ByteArrayInputStream(ab); - DataInputStream in = new DataInputStream(bais); - - try - { - this.shipChunk.readChunkData(in); - in.close(); - } - catch (IOException var9) - { - var9.printStackTrace(); - } - - if (compound.hasKey("seat")) - { - short tileentities = compound.getShort("seat"); - this.seatX = tileentities & 15; - this.seatY = tileentities >>> 4 & 15; - this.seatZ = tileentities >>> 8 & 15; - this.frontDirection = tileentities >>> 12 & 3; - } - else - { - this.seatX = compound.getByte("seatX"); - this.seatY = compound.getByte("seatZ"); - this.seatZ = compound.getByte("seatZ"); - this.frontDirection = compound.getByte("front"); - } - - NBTTagList var10 = compound.getTagList("tileent"); - - if (var10 != null) - { - for (int i = 0; i < var10.tagCount(); ++i) - { - NBTTagCompound comp = (NBTTagCompound)var10.tagAt(i); - TileEntity tileentity = TileEntity.createAndLoadEntity(comp); - this.shipChunk.setBlockTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, tileentity); - } - } - } - - @Override - public void writeSpawnData(ByteArrayDataOutput out) - { - out.writeByte(this.seatX); - out.writeByte(this.seatY); - out.writeByte(this.seatZ); - out.writeByte(this.frontDirection); - - try - { - this.shipChunk.writeChunkData(out); - } - catch (IOException var3) - { - var3.printStackTrace(); - } - } - - @Override - public void readSpawnData(ByteArrayDataInput in) - { - this.seatX = in.readByte(); - this.seatY = in.readByte(); - this.seatZ = in.readByte(); - this.frontDirection = in.readByte(); - - try - { - this.shipChunk.readChunkData(in); - } - catch (IOException var3) - { - var3.printStackTrace(); - } - } -} diff --git a/src/shipmod/entity/IShipTileEntity.java b/src/shipmod/entity/IShipTileEntity.java deleted file mode 100644 index a4825ffd..00000000 --- a/src/shipmod/entity/IShipTileEntity.java +++ /dev/null @@ -1,6 +0,0 @@ -package shipmod.entity; - -public interface IShipTileEntity -{ - void setVehicle(EntityShip var1); -} diff --git a/src/shipmod/entity/ShipCapabilities.java b/src/shipmod/entity/ShipCapabilities.java deleted file mode 100644 index b4f65faa..00000000 --- a/src/shipmod/entity/ShipCapabilities.java +++ /dev/null @@ -1,42 +0,0 @@ -package shipmod.entity; - -import net.minecraft.block.Block; -import shipmod.ShipMod; - -public class ShipCapabilities -{ - public float speedMultiplier = 1.0F; - public float rotationMultiplier = 1.0F; - public float liftMultiplier = 1.0F; - public float brakeMult = 0.9F; - private int balloons = 0; - private int floaters = 0; - private int blockCount = 0; - private float mass = 0.0F; - private boolean hasSigns = false; - - public boolean canFly() - { - return true; - } - - public float getMass() - { - return this.mass; - } - - public boolean hasSigns() - { - return this.hasSigns; - } - - protected void onChunkBlockAdded(int id, int metadata) - { - if (id == Block.signPost.blockID || id == Block.signWall.blockID) - { - this.hasSigns = true; - } - - ++this.blockCount; - } -} diff --git a/src/shipmod/render/MobileChunkRenderer.java b/src/shipmod/render/MobileChunkRenderer.java deleted file mode 100644 index 8573b62e..00000000 --- a/src/shipmod/render/MobileChunkRenderer.java +++ /dev/null @@ -1,254 +0,0 @@ -package shipmod.render; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.logging.Level; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.GLAllocation; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.chunk.Chunk; -import org.lwjgl.opengl.GL11; -import shipmod.ShipMod; -import shipmod.chunk.MobileChunk; - -public class MobileChunkRenderer -{ - private MobileChunk chunk; - private RenderBlocks blockRenderer; - private int glRenderList = -1; - public boolean isInFrustum = false; - public boolean[] skipRenderPass = new boolean[2]; - public boolean needsUpdate; - public boolean isRemoved; - public AxisAlignedBB rendererBoundingBox; - private boolean isInitialized = false; - private List<TileEntity> tileEntityRenderers = new ArrayList(); - public List<TileEntity> tileEntities; - private int bytesDrawn; - - public MobileChunkRenderer(MobileChunk vehiclechunk) - { - this.chunk = vehiclechunk; - this.needsUpdate = true; - this.tileEntities = new ArrayList(); - } - - public void render(float partialticks) - { - if (this.isRemoved) - { - if (this.glRenderList != -1) - { - GLAllocation.deleteDisplayLists(this.glRenderList); - this.glRenderList = -1; - } - } - else - { - if (this.needsUpdate) - { - try - { - this.updateRender(); - } - catch (Exception var7) - { - ShipMod.modLogger.log(Level.SEVERE, "A mobile chunk render error has occured", var7); - } - } - - if (this.glRenderList != -1) - { - for (int pass = 0; pass < 2; ++pass) - { - GL11.glCallList(this.glRenderList + pass); - RenderHelper.enableStandardItemLighting(); - Iterator it = this.tileEntityRenderers.iterator(); - - while (it.hasNext()) - { - TileEntity tile = (TileEntity)it.next(); - - try - { - if (tile.shouldRenderInPass(pass)) - { - this.renderTileEntity(tile, partialticks); - } - } - catch (Exception var6) - { - it.remove(); - ShipMod.modLogger.log(Level.SEVERE, "A tile entity render error has occured", var6); - } - } - } - } - } - } - - public void renderTileEntity(TileEntity par1TileEntity, float partialticks) - { - try { - int i = this.chunk.getLightBrightnessForSkyBlocks(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord, 0); - int j = i % 65536; - int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - TileEntityRenderer.instance.renderTileEntityAt(par1TileEntity, (double)par1TileEntity.xCoord, (double)par1TileEntity.yCoord, (double)par1TileEntity.zCoord, partialticks); - } catch (Exception e) { - if (Tessellator.instance.isDrawing) { - Tessellator.instance.draw(); - } - } - } - - private void updateRender() - { - if (this.glRenderList == -1) - { - this.glRenderList = GLAllocation.generateDisplayLists(2); - } - - this.needsUpdate = false; - - for (int hashset0 = 0; hashset0 < 2; ++hashset0) - { - this.skipRenderPass[hashset0] = true; - } - - Chunk.isLit = false; - HashSet var14 = new HashSet(); - var14.addAll(this.tileEntityRenderers); - this.tileEntityRenderers.clear(); - boolean b0 = true; - RenderBlocks renderblocks = new RenderBlocks(this.chunk); - this.bytesDrawn = 0; - - for (int hashset1 = 0; hashset1 < 2; ++hashset1) - { - boolean flag = false; - boolean flag1 = false; - boolean isDrawStarted = false; - - for (int y = this.chunk.minY(); y < this.chunk.maxY(); ++y) - { - for (int z = this.chunk.minZ(); z < this.chunk.maxZ(); ++z) - { - for (int x = this.chunk.minX(); x < this.chunk.maxX(); ++x) - { - int l2 = this.chunk.getBlockId(x, y, z); - - if (l2 > 0) - { - if (!isDrawStarted) - { - isDrawStarted = true; - GL11.glNewList(this.glRenderList + hashset1, GL11.GL_COMPILE); - GL11.glPushMatrix(); - float block = 1.000001F; - GL11.glTranslatef(-8.0F, -8.0F, -8.0F); - GL11.glScalef(block, block, block); - GL11.glTranslatef(8.0F, 8.0F, 8.0F); - Tessellator.instance.startDrawingQuads(); - } - - Block var16 = Block.blocksList[l2]; - - if (var16 != null) - { - if (hashset1 == 0 && var16.hasTileEntity(this.chunk.getBlockMetadata(x, y, z))) - { - TileEntity blockpass = this.chunk.getBlockTileEntity(x, y, z); - - if (TileEntityRenderer.instance.hasSpecialRenderer(blockpass)) - { - this.tileEntityRenderers.add(blockpass); - } - } - - int var17 = var16.getRenderBlockPass(); - if (var17 > hashset1) - { - flag = true; - } - - try { - if (var16.canRenderInPass(hashset1)) - { - flag1 |= renderblocks.renderBlockByRenderType(var16, x, y, z); - } - } catch (Exception e) { - flag1 = false; - } - } - } - } - } - } - - if (isDrawStarted) - { - this.bytesDrawn += Tessellator.instance.draw(); - GL11.glPopMatrix(); - GL11.glEndList(); - Tessellator.instance.setTranslation(0.0D, 0.0D, 0.0D); - } - else - { - flag1 = false; - } - - if (flag1) - { - this.skipRenderPass[hashset1] = false; - } - - if (!flag) - { - break; - } - } - - HashSet var15 = new HashSet(); - var15.addAll(this.tileEntityRenderers); - var15.removeAll(var14); - this.tileEntities.addAll(var15); - var14.removeAll(this.tileEntityRenderers); - this.tileEntities.removeAll(var14); - this.isInitialized = true; - } - - public void markDirty() - { - this.needsUpdate = true; - } - - public void markRemoved() - { - this.isRemoved = true; - - try - { - if (this.glRenderList != -1) - { - ShipMod.modLogger.finest("Deleting mobile chunk display list " + this.glRenderList); - GLAllocation.deleteDisplayLists(this.glRenderList); - this.glRenderList = -1; - } - } - catch (Exception var2) - { - ShipMod.modLogger.log(Level.SEVERE, "Failed to destroy mobile chunk display list", var2); - } - } -} diff --git a/src/shipmod/render/RenderShip.java b/src/shipmod/render/RenderShip.java deleted file mode 100644 index 0c6ef0e4..00000000 --- a/src/shipmod/render/RenderShip.java +++ /dev/null @@ -1,50 +0,0 @@ -package shipmod.render; - -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import shipmod.entity.EntityShip; - -public class RenderShip extends Render -{ - public RenderShip() - { - this.shadowSize = 1.0F; - } - - public void renderVehicle(EntityShip entity, double x, double y, double z, float yaw, float pitch) - { - GL11.glPushAttrib(8256); - RenderHelper.disableStandardItemLighting(); - GL11.glPushMatrix(); - GL11.glTranslatef((float)x, (float)y, (float)z); - GL11.glRotatef(yaw, 0.0F, 1.0F, 0.0F); - float fx = entity.getShipChunk().getCenterX(); - float fz = entity.getShipChunk().getCenterZ(); - GL11.glTranslatef(-fx, (float)(-entity.getShipChunk().minY()), -fz); - float f4 = 0.75F; - this.func_110777_b(entity); - entity.getShipChunk().renderer.render(0.0F); - GL11.glPopMatrix(); - GL11.glPopAttrib(); - } - - /** - * 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<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, - * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. - */ - public void doRender(Entity entity, double x, double y, double z, float yaw, float pitch) - { - this.renderVehicle((EntityShip)entity, x, y, z, yaw, pitch); - } - - protected ResourceLocation func_110775_a(Entity entity) - { - return TextureMap.field_110575_b; - } -} diff --git a/src/shipmod/util/AABBRotator.java b/src/shipmod/util/AABBRotator.java deleted file mode 100644 index b5a1e550..00000000 --- a/src/shipmod/util/AABBRotator.java +++ /dev/null @@ -1,51 +0,0 @@ -package shipmod.util; - -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.Vec3; - -public class AABBRotator -{ - private static Vec3 vec00 = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); - private static Vec3 vec01 = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); - private static Vec3 vec10 = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); - private static Vec3 vec11 = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); - - public static void rotateAABBAroundY(AxisAlignedBB aabb, double xoff, double zoff, float ang) - { - double y0 = aabb.minY; - double y1 = aabb.maxY; - vec00.xCoord = aabb.minX - xoff; - vec00.zCoord = aabb.minZ - zoff; - vec01.xCoord = aabb.minX - xoff; - vec01.zCoord = aabb.maxZ - zoff; - vec10.xCoord = aabb.maxX - xoff; - vec10.zCoord = aabb.minZ - zoff; - vec11.xCoord = aabb.maxX - xoff; - vec11.zCoord = aabb.maxZ - zoff; - vec00.rotateAroundY(ang); - vec01.rotateAroundY(ang); - vec10.rotateAroundY(ang); - vec11.rotateAroundY(ang); - aabb.setBounds(minX(), y0, minZ(), maxX(), y1, maxZ()).offset(xoff, 0.0D, zoff); - } - - private static double minX() - { - return Math.min(Math.min(Math.min(vec00.xCoord, vec01.xCoord), vec10.xCoord), vec11.xCoord); - } - - private static double minZ() - { - return Math.min(Math.min(Math.min(vec00.zCoord, vec01.zCoord), vec10.zCoord), vec11.zCoord); - } - - private static double maxX() - { - return Math.max(Math.max(Math.max(vec00.xCoord, vec01.xCoord), vec10.xCoord), vec11.xCoord); - } - - private static double maxZ() - { - return Math.max(Math.max(Math.max(vec00.zCoord, vec01.zCoord), vec10.zCoord), vec11.zCoord); - } -} diff --git a/src/shipmod/util/MathHelperMod.java b/src/shipmod/util/MathHelperMod.java deleted file mode 100644 index 514cd97d..00000000 --- a/src/shipmod/util/MathHelperMod.java +++ /dev/null @@ -1,16 +0,0 @@ -package shipmod.util; - -import net.minecraft.util.MathHelper; - -public class MathHelperMod extends MathHelper -{ - public static double clamp_double(double d, double lowerbound, double upperbound) - { - return d < lowerbound ? lowerbound : (d > upperbound ? upperbound : d); - } - - public static int round_double(double d) - { - return (int)Math.round(d); - } -} diff --git a/src/shipmod/util/StackSafeFiller.java b/src/shipmod/util/StackSafeFiller.java deleted file mode 100644 index 0045236c..00000000 --- a/src/shipmod/util/StackSafeFiller.java +++ /dev/null @@ -1,37 +0,0 @@ -package shipmod.util; - -import java.util.HashSet; -import java.util.Set; -import net.minecraft.world.ChunkPosition; - -public class StackSafeFiller -{ - private Set<ChunkPosition> filledCoords = new HashSet(); - private ChunkPosition nextPos = null; - - public void fill(int x, int y, int z) - { - if (!this.hasNext()) - { - ChunkPosition pos = new ChunkPosition(x, y, z); - - if (!this.filledCoords.contains(pos)) - { - this.nextPos = pos; - this.filledCoords.add(pos); - } - } - } - - public ChunkPosition next() - { - ChunkPosition pos = this.nextPos; - this.nextPos = null; - return pos; - } - - public boolean hasNext() - { - return this.nextPos != null; - } -}