From 7846ef5481150cdc04f5342ef6acaa7863850074 Mon Sep 17 00:00:00 2001 From: HoosierTransfer <97118529+HoosierTransfer@users.noreply.github.com> Date: Tue, 28 May 2024 15:20:58 -0400 Subject: [PATCH] thing --- .../minecraft/blockstates/chorus_flower.json | 10 + .../minecraft/blockstates/chorus_plant.json | 70 + .../minecraft/models/block/chorus_flower.json | 76 + .../models/block/chorus_flower_dead.json | 8 + .../minecraft/models/block/chorus_plant.json | 81 + .../models/block/chorus_plant_noside.json | 16 + .../models/block/chorus_plant_noside1.json | 26 + .../models/block/chorus_plant_noside2.json | 26 + .../models/block/chorus_plant_noside3.json | 26 + .../models/block/chorus_plant_side.json | 20 + .../minecraft/models/item/chorus_flower.json | 3 + .../minecraft/models/item/chorus_plant.json | 3 + .../textures/blocks/chorus_flower.png | Bin 0 -> 325 bytes .../textures/blocks/chorus_flower_dead.png | Bin 0 -> 328 bytes .../textures/blocks/chorus_plant.png | Bin 0 -> 300 bytes .../textures/entity/end_gateway_beam.png | Bin 0 -> 255 bytes .../v1_8/opengl/EaglerMeshLoader.java | 100 +- .../v1_8/opengl/GlStateManager.java | 16 + .../ext/deferred/EaglerDeferredPipeline.java | 1372 ++++++++++------- src/main/java/net/minecraft/block/Block.java | 21 + .../minecraft/block/BlockChorusFlower.java | 277 ++++ .../net/minecraft/block/BlockChorusPlant.java | 222 +++ .../net/minecraft/block/BlockEndGateway.java | 96 ++ .../net/minecraft/block/BlockGrassPath.java | 9 +- .../java/net/minecraft/client/Minecraft.java | 2 +- .../client/network/NetHandlerPlayClient.java | 3 +- .../client/renderer/BlockModelShapes.java | 3 +- .../client/renderer/RenderGlobal.java | 10 + .../entity/layers/LayerSheepWool.java | 6 +- .../entity/layers/LayerWolfCollar.java | 2 +- .../tileentity/TileEntityBeaconRenderer.java | 123 ++ .../TileEntityEndGatewayRenderer.java | 222 +++ .../TileEntityRendererDispatcher.java | 2 + .../minecraft/entity/passive/EntitySheep.java | 2 +- .../entity/player/InventoryPlayer.java | 83 +- .../item/crafting/RecipesArmorDyes.java | 2 +- .../net/minecraft/tileentity/TileEntity.java | 1 + .../tileentity/TileEntityBeacon.java | 6 +- .../tileentity/TileEntityEndGateway.java | 272 ++++ .../net/minecraft/util/AxisAlignedBB.java | 11 + .../java/net/minecraft/util/MathHelper.java | 4 + src/main/java/net/minecraft/util/Vec3.java | 4 + src/main/java/net/minecraft/world/World.java | 6 + 43 files changed, 2553 insertions(+), 689 deletions(-) create mode 100644 resources/resources/assets/minecraft/blockstates/chorus_flower.json create mode 100644 resources/resources/assets/minecraft/blockstates/chorus_plant.json create mode 100644 resources/resources/assets/minecraft/models/block/chorus_flower.json create mode 100644 resources/resources/assets/minecraft/models/block/chorus_flower_dead.json create mode 100644 resources/resources/assets/minecraft/models/block/chorus_plant.json create mode 100644 resources/resources/assets/minecraft/models/block/chorus_plant_noside.json create mode 100644 resources/resources/assets/minecraft/models/block/chorus_plant_noside1.json create mode 100644 resources/resources/assets/minecraft/models/block/chorus_plant_noside2.json create mode 100644 resources/resources/assets/minecraft/models/block/chorus_plant_noside3.json create mode 100644 resources/resources/assets/minecraft/models/block/chorus_plant_side.json create mode 100644 resources/resources/assets/minecraft/models/item/chorus_flower.json create mode 100644 resources/resources/assets/minecraft/models/item/chorus_plant.json create mode 100644 resources/resources/assets/minecraft/textures/blocks/chorus_flower.png create mode 100644 resources/resources/assets/minecraft/textures/blocks/chorus_flower_dead.png create mode 100644 resources/resources/assets/minecraft/textures/blocks/chorus_plant.png create mode 100644 resources/resources/assets/minecraft/textures/entity/end_gateway_beam.png create mode 100644 src/main/java/net/minecraft/block/BlockChorusFlower.java create mode 100644 src/main/java/net/minecraft/block/BlockChorusPlant.java create mode 100644 src/main/java/net/minecraft/block/BlockEndGateway.java create mode 100644 src/main/java/net/minecraft/client/renderer/tileentity/TileEntityEndGatewayRenderer.java create mode 100644 src/main/java/net/minecraft/tileentity/TileEntityEndGateway.java diff --git a/resources/resources/assets/minecraft/blockstates/chorus_flower.json b/resources/resources/assets/minecraft/blockstates/chorus_flower.json new file mode 100644 index 0000000..12ae41c --- /dev/null +++ b/resources/resources/assets/minecraft/blockstates/chorus_flower.json @@ -0,0 +1,10 @@ +{ + "variants": { + "age=0": { "model": "chorus_flower" }, + "age=1": { "model": "chorus_flower" }, + "age=2": { "model": "chorus_flower" }, + "age=3": { "model": "chorus_flower" }, + "age=4": { "model": "chorus_flower" }, + "age=5": { "model": "chorus_flower_dead" } + } +} diff --git a/resources/resources/assets/minecraft/blockstates/chorus_plant.json b/resources/resources/assets/minecraft/blockstates/chorus_plant.json new file mode 100644 index 0000000..fc53b76 --- /dev/null +++ b/resources/resources/assets/minecraft/blockstates/chorus_plant.json @@ -0,0 +1,70 @@ +{ + "multipart": [ + { "when": { "north": true }, + "apply": { "model": "chorus_plant_side" } + }, + { "when": { "east": true }, + "apply": { "model": "chorus_plant_side", "y": 90, "uvlock": true } + }, + { "when": { "south": true }, + "apply": { "model": "chorus_plant_side", "y": 180, "uvlock": true } + }, + { "when": { "west": true }, + "apply": { "model": "chorus_plant_side", "y": 270, "uvlock": true } + }, + { "when": { "up": true }, + "apply": { "model": "chorus_plant_side", "x": 270, "uvlock": true } + }, + { "when": { "down": true }, + "apply": { "model": "chorus_plant_side", "x": 90, "uvlock": true } + }, + { "when": { "north": false }, + "apply": [ + { "model": "chorus_plant_noside", "weight": 2 }, + { "model": "chorus_plant_noside1" }, + { "model": "chorus_plant_noside2" }, + { "model": "chorus_plant_noside3" } + ] + }, + { "when": { "east": false }, + "apply": [ + { "model": "chorus_plant_noside1", "y": 90, "uvlock": true }, + { "model": "chorus_plant_noside2", "y": 90, "uvlock": true }, + { "model": "chorus_plant_noside3", "y": 90, "uvlock": true }, + { "model": "chorus_plant_noside", "weight": 2, "y": 90, "uvlock": true } + ] + }, + { "when": { "south": false }, + "apply": [ + { "model": "chorus_plant_noside2", "y": 180, "uvlock": true }, + { "model": "chorus_plant_noside3", "y": 180, "uvlock": true }, + { "model": "chorus_plant_noside", "weight": 2, "y": 180, "uvlock": true }, + { "model": "chorus_plant_noside1", "y": 180, "uvlock": true } + ] + }, + { "when": { "west": false }, + "apply": [ + { "model": "chorus_plant_noside3", "y": 270, "uvlock": true }, + { "model": "chorus_plant_noside", "weight": 2, "y": 270, "uvlock": true }, + { "model": "chorus_plant_noside1", "y": 270, "uvlock": true }, + { "model": "chorus_plant_noside2", "y": 270, "uvlock": true } + ] + }, + { "when": { "up": false }, + "apply": [ + { "model": "chorus_plant_noside", "weight": 2, "x": 270, "uvlock": true }, + { "model": "chorus_plant_noside3", "x": 270, "uvlock": true }, + { "model": "chorus_plant_noside1", "x": 270, "uvlock": true }, + { "model": "chorus_plant_noside2", "x": 270, "uvlock": true } + ] + }, + { "when": { "down": false }, + "apply": [ + { "model": "chorus_plant_noside3", "x": 90, "uvlock": true }, + { "model": "chorus_plant_noside2", "x": 90, "uvlock": true }, + { "model": "chorus_plant_noside1", "x": 90, "uvlock": true }, + { "model": "chorus_plant_noside", "weight": 2, "x": 90, "uvlock": true } + ] + } + ] +} diff --git a/resources/resources/assets/minecraft/models/block/chorus_flower.json b/resources/resources/assets/minecraft/models/block/chorus_flower.json new file mode 100644 index 0000000..9dae902 --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chorus_flower.json @@ -0,0 +1,76 @@ +{ + "textures": { + "texture": "blocks/chorus_flower", + "bottom": "blocks/chorus_plant", + "particle": "blocks/chorus_flower" + }, + "elements": [ + { + "from": [ 2, 14, 2 ], + "to": [ 14, 16, 14 ], + "faces": { + "up": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture" }, + "north": { "uv": [ 2, 0, 14, 2 ], "texture": "#bottom" }, + "south": { "uv": [ 2, 0, 14, 2 ], "texture": "#bottom" }, + "west": { "uv": [ 2, 0, 14, 2 ], "texture": "#bottom" }, + "east": { "uv": [ 2, 0, 14, 2 ], "texture": "#bottom" } + } + }, + { + "from": [ 0, 2, 2 ], + "to": [ 2, 14, 14 ], + "faces": { + "down": { "uv": [ 16, 14, 14, 2 ], "texture": "#bottom" }, + "up": { "uv": [ 0, 2, 2, 14 ], "texture": "#bottom" }, + "north": { "uv": [ 14, 2, 16, 14 ], "texture": "#bottom" }, + "south": { "uv": [ 0, 2, 2, 14 ], "texture": "#bottom" }, + "west": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture" } + } + }, + { + "from": [ 2, 2, 0 ], + "to": [ 14, 14, 2 ], + "faces": { + "down": { "uv": [ 14, 2, 2, 0 ], "texture": "#bottom" }, + "up": { "uv": [ 2, 0, 14, 2 ], "texture": "#bottom" }, + "north": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture" }, + "west": { "uv": [ 0, 2, 2, 14 ], "texture": "#bottom" }, + "east": { "uv": [ 14, 2, 16, 14 ], "texture": "#bottom" } + } + }, + { + "from": [ 2, 2, 14 ], + "to": [ 14, 14, 16 ], + "faces": { + "down": { "uv": [ 14, 16, 2, 14 ], "texture": "#bottom" }, + "up": { "uv": [ 2, 14, 14, 16 ], "texture": "#bottom" }, + "south": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture" }, + "west": { "uv": [ 14, 2, 16, 14 ], "texture": "#bottom" }, + "east": { "uv": [ 0, 2, 2, 14 ], "texture": "#bottom" } + } + }, + { + "from": [ 14, 2, 2 ], + "to": [ 16, 14, 14 ], + "faces": { + "down": { "uv": [ 2, 14, 0, 2 ], "texture": "#bottom" }, + "up": { "uv": [ 14, 2, 16, 14 ], "texture": "#bottom" }, + "north": { "uv": [ 0, 2, 2, 14 ], "texture": "#bottom" }, + "south": { "uv": [ 14, 2, 16, 14 ], "texture": "#bottom" }, + "east": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture" } + } + }, + { + "from": [ 2, 0, 2 ], + "to": [ 14, 14, 14 ], + "faces": { + "up": { "uv": [ 2, 2, 14, 14 ], "texture": "#bottom" }, + "down": { "uv": [ 14, 14, 2, 2 ], "texture": "#bottom" }, + "north": { "uv": [ 2, 2, 14, 16 ], "texture": "#bottom" }, + "south": { "uv": [ 2, 2, 14, 16 ], "texture": "#bottom" }, + "west": { "uv": [ 2, 2, 14, 16 ], "texture": "#bottom" }, + "east": { "uv": [ 2, 2, 14, 16 ], "texture": "#bottom" } + } + } + ] +} diff --git a/resources/resources/assets/minecraft/models/block/chorus_flower_dead.json b/resources/resources/assets/minecraft/models/block/chorus_flower_dead.json new file mode 100644 index 0000000..7e9cae5 --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chorus_flower_dead.json @@ -0,0 +1,8 @@ +{ + "parent": "block/chorus_flower", + "textures": { + "texture": "blocks/chorus_flower_dead", + "bottom": "blocks/chorus_plant", + "particle": "blocks/chorus_flower_dead" + } +} diff --git a/resources/resources/assets/minecraft/models/block/chorus_plant.json b/resources/resources/assets/minecraft/models/block/chorus_plant.json new file mode 100644 index 0000000..a9caec0 --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chorus_plant.json @@ -0,0 +1,81 @@ +{ + "ambientocclusion": false, + "textures": { + "texture": "blocks/chorus_plant", + "inside": "blocks/chorus_plant", + "particle": "blocks/chorus_plant" + }, + "elements": [ + { "from": [ 2, 14, 2 ], + "to": [ 14, 16, 14 ], + "faces": { + "up": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture", "cullface":"up" }, + "north": { "uv": [ 2, 0, 14, 2 ], "texture": "#texture", "cullface":"up" }, + "south": { "uv": [ 2, 0, 14, 2 ], "texture": "#texture", "cullface":"up" }, + "west": { "uv": [ 2, 0, 14, 2 ], "texture": "#texture", "cullface":"up" }, + "east": { "uv": [ 2, 0, 14, 2 ], "texture": "#texture", "cullface":"up" } + } + }, + { "from": [ 0, 2, 2 ], + "to": [ 2, 14, 14 ], + "faces": { + "down": { "uv": [ 16, 14, 14, 2 ], "texture": "#texture", "cullface":"west" }, + "up": { "uv": [ 0, 2, 2, 14 ], "texture": "#texture", "cullface":"west" }, + "north": { "uv": [ 14, 2, 16, 14 ], "texture": "#texture", "cullface":"west" }, + "south": { "uv": [ 0, 2, 2, 14 ], "texture": "#texture", "cullface":"west" }, + "west": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture", "cullface":"west" } + } + }, + { "from": [ 2, 2, 0 ], + "to": [ 14, 14, 2 ], + "faces": { + "down": { "uv": [ 14, 2, 2, 0 ], "texture": "#texture", "cullface":"north" }, + "up": { "uv": [ 2, 0, 14, 2 ], "texture": "#texture", "cullface":"north" }, + "north": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture", "cullface":"north" }, + "west": { "uv": [ 0, 2, 2, 14 ], "texture": "#texture", "cullface":"north" }, + "east": { "uv": [ 14, 2, 16, 14 ], "texture": "#texture", "cullface":"north" } + } + }, + { "from": [ 2, 2, 14 ], + "to": [ 14, 14, 16 ], + "faces": { + "down": { "uv": [ 14, 16, 2, 14 ], "texture": "#texture", "cullface":"south" }, + "up": { "uv": [ 2, 14, 14, 16 ], "texture": "#texture", "cullface":"south" }, + "south": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture", "cullface":"south" }, + "west": { "uv": [ 14, 2, 16, 14 ], "texture": "#texture", "cullface":"south" }, + "east": { "uv": [ 0, 2, 2, 14 ], "texture": "#texture", "cullface":"south" } + } + }, + { "from": [ 14, 2, 2 ], + "to": [ 16, 14, 14 ], + "faces": { + "down": { "uv": [ 2, 14, 0, 2 ], "texture": "#texture", "cullface":"east" }, + "up": { "uv": [ 14, 2, 16, 14 ], "texture": "#texture", "cullface":"east" }, + "north": { "uv": [ 0, 2, 2, 14 ], "texture": "#texture", "cullface":"east" }, + "south": { "uv": [ 14, 2, 16, 14 ], "texture": "#texture", "cullface":"east" }, + "east": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture", "cullface":"east" } + } + }, + { "from": [ 2, 0, 2 ], + "to": [ 14, 2, 14 ], + "faces": { + "down": { "uv": [ 14, 14, 2, 2 ], "texture": "#texture", "cullface":"down" }, + "north": { "uv": [ 2, 14, 14, 16 ], "texture": "#texture", "cullface":"down" }, + "south": { "uv": [ 2, 14, 14, 16 ], "texture": "#texture", "cullface":"down" }, + "west": { "uv": [ 2, 14, 14, 16 ], "texture": "#texture", "cullface":"down" }, + "east": { "uv": [ 2, 14, 14, 16 ], "texture": "#texture", "cullface":"down" } + } + }, + { "from": [ 2, 2, 2 ], + "to": [ 14, 14, 14 ], + "faces": { + "down": { "uv": [ 14, 14, 2, 2 ], "texture": "#inside" }, + "up": { "uv": [ 2, 2, 14, 14 ], "texture": "#inside" }, + "north": { "uv": [ 2, 2, 14, 14 ], "texture": "#inside" }, + "south": { "uv": [ 2, 2, 14, 14 ], "texture": "#inside" }, + "west": { "uv": [ 2, 2, 14, 14 ], "texture": "#inside" }, + "east": { "uv": [ 2, 2, 14, 14 ], "texture": "#inside" } + } + } + ] +} diff --git a/resources/resources/assets/minecraft/models/block/chorus_plant_noside.json b/resources/resources/assets/minecraft/models/block/chorus_plant_noside.json new file mode 100644 index 0000000..d529f0f --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chorus_plant_noside.json @@ -0,0 +1,16 @@ +{ + "ambientocclusion": false, + "textures": { + "texture": "blocks/chorus_plant", + "inside": "blocks/chorus_plant", + "particle": "blocks/chorus_plant" + }, + "elements": [ + { "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "texture": "#inside" } + } + } + ] +} diff --git a/resources/resources/assets/minecraft/models/block/chorus_plant_noside1.json b/resources/resources/assets/minecraft/models/block/chorus_plant_noside1.json new file mode 100644 index 0000000..eb376ed --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chorus_plant_noside1.json @@ -0,0 +1,26 @@ +{ + "ambientocclusion": false, + "textures": { + "texture": "blocks/chorus_plant", + "inside": "blocks/chorus_plant", + "particle": "blocks/chorus_plant" + }, + "elements": [ + { "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "texture": "#inside" } + } + }, + { "from": [ 4, 4, 3 ], + "to": [ 12, 12, 4 ], + "faces": { + "down": { "texture": "#texture" }, + "up": { "texture": "#texture" }, + "north": { "texture": "#texture" }, + "west": { "texture": "#texture" }, + "east": { "texture": "#texture" } + } + } + ] +} diff --git a/resources/resources/assets/minecraft/models/block/chorus_plant_noside2.json b/resources/resources/assets/minecraft/models/block/chorus_plant_noside2.json new file mode 100644 index 0000000..104e27f --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chorus_plant_noside2.json @@ -0,0 +1,26 @@ +{ + "ambientocclusion": false, + "textures": { + "texture": "blocks/chorus_plant", + "inside": "blocks/chorus_plant", + "particle": "blocks/chorus_plant" + }, + "elements": [ + { "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "texture": "#inside" } + } + }, + { "from": [ 5, 5, 2 ], + "to": [ 11, 11, 4 ], + "faces": { + "down": { "texture": "#texture" }, + "up": { "texture": "#texture" }, + "north": { "texture": "#texture" }, + "west": { "texture": "#texture" }, + "east": { "texture": "#texture" } + } + } + ] +} diff --git a/resources/resources/assets/minecraft/models/block/chorus_plant_noside3.json b/resources/resources/assets/minecraft/models/block/chorus_plant_noside3.json new file mode 100644 index 0000000..eb376ed --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chorus_plant_noside3.json @@ -0,0 +1,26 @@ +{ + "ambientocclusion": false, + "textures": { + "texture": "blocks/chorus_plant", + "inside": "blocks/chorus_plant", + "particle": "blocks/chorus_plant" + }, + "elements": [ + { "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "texture": "#inside" } + } + }, + { "from": [ 4, 4, 3 ], + "to": [ 12, 12, 4 ], + "faces": { + "down": { "texture": "#texture" }, + "up": { "texture": "#texture" }, + "north": { "texture": "#texture" }, + "west": { "texture": "#texture" }, + "east": { "texture": "#texture" } + } + } + ] +} diff --git a/resources/resources/assets/minecraft/models/block/chorus_plant_side.json b/resources/resources/assets/minecraft/models/block/chorus_plant_side.json new file mode 100644 index 0000000..1862b88 --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chorus_plant_side.json @@ -0,0 +1,20 @@ +{ + "ambientocclusion": false, + "textures": { + "texture": "blocks/chorus_plant", + "inside": "blocks/chorus_plant", + "particle": "blocks/chorus_plant" + }, + "elements": [ + { "from": [ 4, 4, 0 ], + "to": [ 12, 12, 4 ], + "faces": { + "down": { "texture": "#texture" }, + "up": { "texture": "#texture" }, + "north": { "texture": "#texture", "cullface":"north" }, + "west": { "texture": "#texture" }, + "east": { "texture": "#texture" } + } + } + ] +} diff --git a/resources/resources/assets/minecraft/models/item/chorus_flower.json b/resources/resources/assets/minecraft/models/item/chorus_flower.json new file mode 100644 index 0000000..5c621b0 --- /dev/null +++ b/resources/resources/assets/minecraft/models/item/chorus_flower.json @@ -0,0 +1,3 @@ +{ + "parent": "block/chorus_flower" +} diff --git a/resources/resources/assets/minecraft/models/item/chorus_plant.json b/resources/resources/assets/minecraft/models/item/chorus_plant.json new file mode 100644 index 0000000..201329f --- /dev/null +++ b/resources/resources/assets/minecraft/models/item/chorus_plant.json @@ -0,0 +1,3 @@ +{ + "parent": "block/chorus_plant" +} diff --git a/resources/resources/assets/minecraft/textures/blocks/chorus_flower.png b/resources/resources/assets/minecraft/textures/blocks/chorus_flower.png new file mode 100644 index 0000000000000000000000000000000000000000..d075807262694d2e356362c1697c9de6f1458d99 GIT binary patch literal 325 zcmV-L0lNN)P)ovTHRST&bv+Ynk68VJwYVD0|}HQqLm{>d{crl zac3fviHrEt&STVEy$5?!@E+ioe1nkSCCT=G;da8{N&9>EZkIn5e)6vgfscc|7a4&c X!rG@VAshWd00000NkvXXu0mjfvOkZQ literal 0 HcmV?d00001 diff --git a/resources/resources/assets/minecraft/textures/blocks/chorus_flower_dead.png b/resources/resources/assets/minecraft/textures/blocks/chorus_flower_dead.png new file mode 100644 index 0000000000000000000000000000000000000000..21f315521ed84dbadbb0907dfc8c72040cfc6a07 GIT binary patch literal 328 zcmV-O0k{5%P)~U0000u56NQ%7)C0JJ-+p4f+3^d03JSw8=Td~OEd^v yz_cguT1;10GMQ;W&VMTTW%=Bl5&afi48R`-2=my;QzjVz0000>fk&eEYPic??+v5E7rkE`l7q~;lI#m_sv z#?f}H@Q6$PohHi>pZm`0Pq%BT@IZo>T11%Uh*9GLP;j}2<;&eLSWXbniU3^l06gQ! z7(WZ(%)E$L_4xs)hzd{yCn86zBF^`iH{4<)Iu!r_002ovPDHLk FV1jemZgv0w literal 0 HcmV?d00001 diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/EaglerMeshLoader.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/EaglerMeshLoader.java index 506fbb7..4cf1cf2 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/EaglerMeshLoader.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/EaglerMeshLoader.java @@ -23,14 +23,21 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*; /** * Copyright (c) 2024 lax1dude. All Rights Reserved. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * @@ -42,11 +49,11 @@ public class EaglerMeshLoader implements IResourceManagerReloadListener { private static final Map meshCache = new HashMap(); public static HighPolyMesh getEaglerMesh(ResourceLocation meshLoc) { - if(meshLoc.cachedPointerType == ResourceLocation.CACHED_POINTER_EAGLER_MESH) { - return (HighPolyMesh)meshLoc.cachedPointer; + if (meshLoc.cachedPointerType == ResourceLocation.CACHED_POINTER_EAGLER_MESH) { + return (HighPolyMesh) meshLoc.cachedPointer; } HighPolyMesh theMesh = meshCache.get(meshLoc); - if(theMesh == null) { + if (theMesh == null) { theMesh = new HighPolyMesh(); reloadMesh(meshLoc, theMesh, Minecraft.getMinecraft().getResourceManager()); } @@ -55,34 +62,35 @@ public class EaglerMeshLoader implements IResourceManagerReloadListener { return theMesh; } - private static void reloadMesh(ResourceLocation meshLoc, HighPolyMesh meshStruct, IResourceManager resourceManager) { + private static void reloadMesh(ResourceLocation meshLoc, HighPolyMesh meshStruct, + IResourceManager resourceManager) { IntBuffer up1 = null; try { int intsOfVertex, intsOfIndex, intsTotal, stride; - try(DataInputStream dis = new DataInputStream(resourceManager.getResource(meshLoc).getInputStream())) { + try (DataInputStream dis = new DataInputStream(resourceManager.getResource(meshLoc).getInputStream())) { byte[] header = new byte[8]; dis.read(header); - if(!Arrays.equals(header, new byte[] { (byte) 33, (byte) 69, (byte) 65, (byte) 71, (byte) 36, + if (!Arrays.equals(header, new byte[] { (byte) 33, (byte) 69, (byte) 65, (byte) 71, (byte) 36, (byte) 109, (byte) 100, (byte) 108 })) { throw new IOException("File is not an eaglercraft high-poly mesh!"); } - - char CT = (char)dis.read(); - - if(CT == 'C') { + + char CT = (char) dis.read(); + + if (CT == 'C') { meshStruct.hasTexture = false; - }else if(CT == 'T') { + } else if (CT == 'T') { meshStruct.hasTexture = true; - }else { + } else { throw new IOException("Unsupported mesh type '" + CT + "'!"); } - + dis.skipBytes(dis.readUnsignedShort()); meshStruct.vertexCount = dis.readInt(); meshStruct.indexCount = dis.readInt(); int byteIndexCount = meshStruct.indexCount; - if(byteIndexCount % 2 != 0) { // must round up to int + if (byteIndexCount % 2 != 0) { // must round up to int byteIndexCount += 1; } stride = meshStruct.hasTexture ? 24 : 16; @@ -91,72 +99,74 @@ public class EaglerMeshLoader implements IResourceManagerReloadListener { intsOfIndex = byteIndexCount / 2; intsTotal = intsOfIndex + intsOfVertex; up1 = EagRuntime.allocateIntBuffer(intsTotal); - - for(int i = 0; i < intsTotal; ++i) { + + for (int i = 0; i < intsTotal; ++i) { int ch1 = dis.read(); int ch2 = dis.read(); int ch3 = dis.read(); int ch4 = dis.read(); - if ((ch1 | ch2 | ch3 | ch4) < 0) throw new EOFException(); // rip + if ((ch1 | ch2 | ch3 | ch4) < 0) + throw new EOFException(); // rip up1.put((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0)); } } - if(meshStruct.vertexArray == null) { + if (meshStruct.vertexArray == null) { meshStruct.vertexArray = _wglGenVertexArrays(); } - if(meshStruct.vertexBuffer == null) { + if (meshStruct.vertexBuffer == null) { meshStruct.vertexBuffer = _wglGenBuffers(); } - if(meshStruct.indexBuffer == null) { + if (meshStruct.indexBuffer == null) { meshStruct.indexBuffer = _wglGenBuffers(); } - + up1.position(0).limit(intsOfVertex); - + EaglercraftGPU.bindGLArrayBuffer(meshStruct.vertexBuffer); _wglBufferData(GL_ARRAY_BUFFER, up1, GL_STATIC_DRAW); - + EaglercraftGPU.bindGLBufferArray(meshStruct.vertexArray); - + up1.position(intsOfVertex).limit(intsTotal); - + _wglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, meshStruct.indexBuffer); _wglBufferData(GL_ELEMENT_ARRAY_BUFFER, up1, GL_STATIC_DRAW); - + _wglEnableVertexAttribArray(0); _wglVertexAttribPointer(0, 3, GL_FLOAT, false, stride, 0); - - if(meshStruct.hasTexture) { + + if (meshStruct.hasTexture) { _wglEnableVertexAttribArray(1); _wglVertexAttribPointer(1, 2, GL_FLOAT, false, stride, 16); } - + _wglEnableVertexAttribArray(meshStruct.hasTexture ? 2 : 1); _wglVertexAttribPointer(meshStruct.hasTexture ? 2 : 1, 4, GL_BYTE, true, stride, 12); - }catch(Throwable ex) { - if(meshStruct.vertexArray != null) { + + } catch (Throwable ex) { + if (meshStruct.vertexArray != null) { _wglDeleteVertexArrays(meshStruct.vertexArray); meshStruct.vertexArray = null; } - if(meshStruct.vertexBuffer != null) { + if (meshStruct.vertexBuffer != null) { _wglDeleteBuffers(meshStruct.vertexBuffer); meshStruct.vertexBuffer = null; } - if(meshStruct.indexBuffer != null) { + if (meshStruct.indexBuffer != null) { _wglDeleteBuffers(meshStruct.indexBuffer); meshStruct.indexBuffer = null; } - + meshStruct.vertexCount = 0; meshStruct.indexCount = 0; meshStruct.hasTexture = false; - + logger.error("Failed to load eaglercraft high-poly mesh: \"{}\"", meshLoc); logger.error(ex); - }finally { - if(up1 != null) { + } finally { + if (up1 != null) { EagRuntime.freeIntBuffer(up1); } } @@ -164,7 +174,7 @@ public class EaglerMeshLoader implements IResourceManagerReloadListener { @Override public void onResourceManagerReload(IResourceManager var1) { - for(Entry meshEntry : meshCache.entrySet()) { + for (Entry meshEntry : meshCache.entrySet()) { reloadMesh(meshEntry.getKey(), meshEntry.getValue(), var1); } } diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/GlStateManager.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/GlStateManager.java index 531518b..d241f84 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/GlStateManager.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/GlStateManager.java @@ -802,6 +802,22 @@ public class GlStateManager { } } + public static final void getFloat(int pname, FloatBuffer params) { + switch (pname) { + case GL_MODELVIEW_MATRIX: + modelMatrixStack[modelMatrixStackPointer].store(params); + break; + case GL_PROJECTION_MATRIX: + projectionMatrixStack[projectionMatrixStackPointer].store(params); + break; + case GL_TEXTURE_MATRIX: + textureMatrixStack[activeTexture][textureMatrixStackPointer[activeTexture]].store(params); + break; + default: + throw new UnsupportedOperationException("glGetFloat can only be used to retrieve matricies!"); + } + } + public static final void getFloat(int pname, float[] params) { switch (pname) { case GL_MODELVIEW_MATRIX: diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/EaglerDeferredPipeline.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/EaglerDeferredPipeline.java index f08117f..4531a10 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/EaglerDeferredPipeline.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ext/deferred/EaglerDeferredPipeline.java @@ -74,14 +74,21 @@ import java.util.List; /** * Copyright (c) 2023 lax1dude. All Rights Reserved. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * @@ -366,14 +373,14 @@ public class EaglerDeferredPipeline { public EaglerDeferredPipeline(Minecraft mc) { this.mc = mc; - if(matrixCopyBuffer == null) { + if (matrixCopyBuffer == null) { matrixCopyBuffer = GLAllocation.createDirectFloatBuffer(16); } this.lightSourceBucketsWidth = 5; this.lightSourceBucketsHeight = 3; int cnt = 5 * 3 * 5; this.lightSourceBuckets = new ListSerial[cnt]; - for(int i = 0; i < cnt; ++i) { + for (int i = 0; i < cnt; ++i) { this.lightSourceBuckets[i] = new ArrayListSerial(16); } } @@ -394,27 +401,31 @@ public class EaglerDeferredPipeline { gBufferDiffuseTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(gBufferDiffuseTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(gBufferDiffuseTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(gBufferDiffuseTexture), 0); gBufferNormalsTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(gBufferNormalsTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(gBufferNormalsTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(gBufferNormalsTexture), 0); gBufferMaterialTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(gBufferMaterialTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(gBufferMaterialTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(gBufferMaterialTexture), 0); gBufferDrawBuffers = new int[] { _GL_COLOR_ATTACHMENT0, _GL_COLOR_ATTACHMENT1, _GL_COLOR_ATTACHMENT2 }; _wglDrawBuffers(gBufferDrawBuffers); gBufferDepthTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(gBufferDepthTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(gBufferDepthTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(gBufferDepthTexture), 0); DeferredStateManager.checkGLError("Post: rebuild pipeline: gbuffers"); boolean shadowsSun = config.is_rendering_shadowsSun_clamped > 0; - if(shadowsSun) { + if (shadowsSun) { sunShadowFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, sunShadowFramebuffer); sunShadowDepthBuffer = GlStateManager.generateTexture(); @@ -423,72 +434,83 @@ public class EaglerDeferredPipeline { _wglTexParameteri(GL_TEXTURE_2D, _GL_TEXTURE_COMPARE_FUNC, GL_GREATER); _wglTexParameteri(GL_TEXTURE_2D, _GL_TEXTURE_COMPARE_MODE, _GL_COMPARE_REF_TO_TEXTURE); int lods = config.is_rendering_shadowsSun_clamped; - if(lods > 3) { + if (lods > 3) { lods = 3; } sunShadowDepthBufferRes = 2048; - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT24, sunShadowDepthBufferRes, sunShadowDepthBufferRes * lods, 0, _GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, (ByteBuffer)null); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(sunShadowDepthBuffer), 0); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT24, sunShadowDepthBufferRes, + sunShadowDepthBufferRes * lods, 0, _GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, (ByteBuffer) null); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(sunShadowDepthBuffer), 0); sunLightingShadowFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, sunLightingShadowFramebuffer); sunLightingShadowTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(sunLightingShadowTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(sunLightingShadowTexture), 0); - if(config.is_rendering_shadowsColored) { + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(sunLightingShadowTexture), 0); + if (config.is_rendering_shadowsColored) { sunShadowColorFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, sunShadowColorFramebuffer); GlStateManager.bindTexture(sunShadowDepthBuffer); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(sunShadowDepthBuffer), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(sunShadowDepthBuffer), 0); sunShadowColorBuffer = GlStateManager.generateTexture(); GlStateManager.bindTexture(sunShadowColorBuffer); setNearest(); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, sunShadowDepthBufferRes, sunShadowDepthBufferRes * lods, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(sunShadowColorBuffer), 0); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, sunShadowDepthBufferRes, sunShadowDepthBufferRes * lods, 0, + GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(sunShadowColorBuffer), 0); } DeferredStateManager.checkGLError("Post: rebuild pipeline: shadowsSun"); } reprojectionEngineEnable = config.is_rendering_ssao || config.is_rendering_raytracing; - if(reprojectionEngineEnable || config.is_rendering_realisticWater) { + if (reprojectionEngineEnable || config.is_rendering_realisticWater) { lastFrameFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, lastFrameFramebuffer); lastFrameColorTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(lastFrameColorTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(lastFrameColorTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(lastFrameColorTexture), 0); lastFrameDepthTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(lastFrameDepthTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(lastFrameDepthTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(lastFrameDepthTexture), 0); lastFrameGBufferFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, lastFrameGBufferFramebuffer); lastFrameGBufferDepthTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(lastFrameGBufferDepthTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(lastFrameGBufferDepthTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(lastFrameGBufferDepthTexture), 0); DeferredStateManager.checkGLError("Post: rebuild pipeline: lastFrame"); } - if(reprojectionEngineEnable) { + if (reprojectionEngineEnable) { gBufferQuarterFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, gBufferQuarterFramebuffer); gBufferQuarterDepthTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(gBufferQuarterDepthTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(gBufferQuarterDepthTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(gBufferQuarterDepthTexture), 0); reprojectionStartup = 0; - for(int i = 0; i < 2; ++i) { + for (int i = 0; i < 2; ++i) { reprojectionControlFramebuffer[i] = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionControlFramebuffer[i]); - if(config.is_rendering_ssao) { + if (config.is_rendering_ssao) { reprojectionControlSSAOTexture[i] = GlStateManager.generateTexture(); GlStateManager.bindTexture(reprojectionControlSSAOTexture[i]); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(reprojectionControlSSAOTexture[i]), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(reprojectionControlSSAOTexture[i]), 0); } - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { reprojectionSSRTexture[i] = GlStateManager.generateTexture(); GlStateManager.bindTexture(reprojectionSSRTexture[0]); // yes this should be 0 _wglFramebufferTexture2D(_GL_FRAMEBUFFER, @@ -504,58 +526,64 @@ public class EaglerDeferredPipeline { _wglDrawBuffers(SSRColorAttachments); GlStateManager.bindTexture(reprojectionSSRTexture[i]); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(reprojectionSSRTexture[i]), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(reprojectionSSRTexture[i]), 0); GlStateManager.bindTexture(reprojectionSSRHitVector[i]); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(reprojectionSSRHitVector[i]), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(reprojectionSSRHitVector[i]), 0); } } - shader_reproject_control = PipelineShaderReprojControl.compile(config.is_rendering_ssao, config.is_rendering_raytracing); + shader_reproject_control = PipelineShaderReprojControl.compile(config.is_rendering_ssao, + config.is_rendering_raytracing); shader_reproject_control.loadUniforms(); - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { shader_reproject_ssr = PipelineShaderReprojSSR.compile(); shader_reproject_ssr.loadUniforms(); } - reprojectionControlDrawBuffers = new int[(config.is_rendering_ssao ? 1 : 0) + (config.is_rendering_raytracing ? 2 : 0)]; + reprojectionControlDrawBuffers = new int[(config.is_rendering_ssao ? 1 : 0) + + (config.is_rendering_raytracing ? 2 : 0)]; int i = 0; - if(config.is_rendering_ssao) { + if (config.is_rendering_ssao) { reprojectionControlDrawBuffers[i] = _GL_COLOR_ATTACHMENT0; ++i; } - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { reprojectionControlDrawBuffers[i] = _GL_COLOR_ATTACHMENT0 + i; ++i; reprojectionControlDrawBuffers[i] = _GL_COLOR_ATTACHMENT0 + i; } - for(int j = 0; j < 2; ++j) { + for (int j = 0; j < 2; ++j) { _wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionControlFramebuffer[j]); _wglDrawBuffers(reprojectionControlDrawBuffers); } DeferredStateManager.checkGLError("Post: rebuild pipeline: reprojectionEngineEnable"); } - if(config.is_rendering_ssao) { + if (config.is_rendering_ssao) { ssaoGenerateFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, ssaoGenerateFramebuffer); ssaoGenerateTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(ssaoGenerateTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(ssaoGenerateTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(ssaoGenerateTexture), 0); ssaoNoiseTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(ssaoNoiseTexture); setNearest(); int noiseTexSize = 64, noiseTexLen = 16384; byte[] noiseTexDat = EagRuntime.getResourceBytes("assets/eagler/glsl/deferred/ssao_noise.bmp"); - if(noiseTexDat == null || noiseTexDat.length != noiseTexLen) { + if (noiseTexDat == null || noiseTexDat.length != noiseTexLen) { noiseTexDat = new byte[noiseTexLen]; - for(int i = 0; i < 4096; ++i) { - noiseTexDat[(i << 2) + 2] = (byte)255; // dumb fallback + for (int i = 0; i < 4096; ++i) { + noiseTexDat[(i << 2) + 2] = (byte) 255; // dumb fallback } } ByteBuffer noiseTextureBytes = EagRuntime.allocateByteBuffer(noiseTexLen); noiseTextureBytes.put(noiseTexDat); noiseTextureBytes.flip(); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, noiseTexSize, noiseTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, noiseTextureBytes); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, noiseTexSize, noiseTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, + noiseTextureBytes); EagRuntime.freeByteBuffer(noiseTextureBytes); shader_ssao_generate = PipelineShaderSSAOGenerate.compile(); shader_ssao_generate.loadUniforms(); @@ -567,24 +595,29 @@ public class EaglerDeferredPipeline { lightingHDRFramebufferColorTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(lightingHDRFramebufferColorTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(lightingHDRFramebufferColorTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(lightingHDRFramebufferColorTexture), 0); lightingHDRFramebufferDepthTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(lightingHDRFramebufferDepthTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(lightingHDRFramebufferDepthTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(lightingHDRFramebufferDepthTexture), 0); handRenderFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, handRenderFramebuffer); GlStateManager.bindTexture(lightingHDRFramebufferColorTexture); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(lightingHDRFramebufferColorTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(lightingHDRFramebufferColorTexture), 0); handRenderFramebufferDepthTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(handRenderFramebufferDepthTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(handRenderFramebufferDepthTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(handRenderFramebufferDepthTexture), 0); shader_hand_depth_mask = PipelineShaderHandDepthMask.compile(); shader_hand_depth_mask.loadUniforms(); - shader_deferred_combine = PipelineShaderGBufferCombine.compile(config.is_rendering_ssao, config.is_rendering_useEnvMap, config.is_rendering_raytracing); + shader_deferred_combine = PipelineShaderGBufferCombine.compile(config.is_rendering_ssao, + config.is_rendering_useEnvMap, config.is_rendering_raytracing); shader_deferred_combine.loadUniforms(); DeferredStateManager.checkGLError("Post: rebuild pipeline: lightingHDRFramebuffer"); @@ -594,10 +627,10 @@ public class EaglerDeferredPipeline { setLinear(); int brdfLutW = 64, brdfLutH = 64, brdfLutLen = 8192; byte[] brdfLutDat = EagRuntime.getResourceBytes("assets/eagler/glsl/deferred/brdf_lut.bmp"); - if(brdfLutDat == null || brdfLutDat.length != brdfLutLen) { + if (brdfLutDat == null || brdfLutDat.length != brdfLutLen) { brdfLutDat = new byte[brdfLutLen]; - for(int i = 0; i < 4096; ++i) { - brdfLutDat[i << 1] = (byte)192; // dumb fallback + for (int i = 0; i < 4096; ++i) { + brdfLutDat[i << 1] = (byte) 192; // dumb fallback } } ByteBuffer brdfLutDatBuffer = EagRuntime.allocateByteBuffer(brdfLutDat.length); @@ -622,7 +655,7 @@ public class EaglerDeferredPipeline { shader_lighting_sun = PipelineShaderLightingSun.compile(shadowsSun ? config.is_rendering_shadowsSun_clamped : 0, config.is_rendering_shadowsColored); shader_lighting_sun.loadUniforms(); - if(shadowsSun) { + if (shadowsSun) { shader_shadows_sun = PipelineShaderShadowsSun.compile(config.is_rendering_shadowsSun_clamped, config.is_rendering_shadowsSmoothed, config.is_rendering_shadowsColored); shader_shadows_sun.loadUniforms(); @@ -640,26 +673,28 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("Post: rebuild pipeline: compile shaders 1"); - if(config.is_rendering_lensFlares) { + if (config.is_rendering_lensFlares) { sunOcclusionValueFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, sunOcclusionValueFramebuffer); sunOcclusionValueTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(sunOcclusionValueTexture); setNearest(); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_R8, 1, 1, 0, GL_RED, GL_UNSIGNED_BYTE, (ByteBuffer)null); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(sunOcclusionValueTexture), 0); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_R8, 1, 1, 0, GL_RED, GL_UNSIGNED_BYTE, (ByteBuffer) null); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(sunOcclusionValueTexture), 0); shader_lens_sun_occlusion = PipelineShaderLensSunOcclusion.compile(); shader_lens_sun_occlusion.loadUniforms(); DeferredStateManager.checkGLError("Post: rebuild pipeline: sunOcclusionValueFramebuffer"); } - if(config.is_rendering_lensDistortion) { + if (config.is_rendering_lensDistortion) { lensDistortFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, lensDistortFramebuffer); lensDistortTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(lensDistortTexture); setLinear(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(lensDistortTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(lensDistortTexture), 0); shader_post_lens_distort = PipelineShaderLensDistortion.compile(); shader_post_lens_distort.loadUniforms(); DeferredStateManager.checkGLError("Post: rebuild pipeline: lens distortion"); @@ -673,7 +708,8 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(exposureBlendTexture); setNearest(); EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, 1, 1, GL_RED, true); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(exposureBlendTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(exposureBlendTexture), 0); DeferredStateManager.checkGLError("Post: rebuild pipeline: exposureBlendFramebuffer"); @@ -684,7 +720,8 @@ public class EaglerDeferredPipeline { throw new RuntimeException("Failed to load skybox!", e); } - pointLightMesh = new LightSourceMesh(new ResourceLocation("eagler:glsl/deferred/light_point_mesh.dat"), "light_point_mesh"); + pointLightMesh = new LightSourceMesh(new ResourceLocation("eagler:glsl/deferred/light_point_mesh.dat"), + "light_point_mesh"); try { pointLightMesh.load(); } catch (IOException e) { @@ -698,8 +735,10 @@ public class EaglerDeferredPipeline { atmosphereHDRFramebufferColorTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(atmosphereHDRFramebufferColorTexture); setNearest(); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, skybox.getAtmosLUTWidth(), skybox.getAtmosLUTHeight(), GL_RGBA, true); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(atmosphereHDRFramebufferColorTexture), 0); + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, skybox.getAtmosLUTWidth(), + skybox.getAtmosLUTHeight(), GL_RGBA, true); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(atmosphereHDRFramebufferColorTexture), 0); envMapAtmosphereFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, envMapAtmosphereFramebuffer); @@ -707,7 +746,8 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(envMapAtmosphereTexture); setLinear(); EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, 128, 256, GL_RGBA, true); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(envMapAtmosphereTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(envMapAtmosphereTexture), 0); envMapSkyFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, envMapSkyFramebuffer); @@ -715,7 +755,8 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(envMapSkyTexture); setLinear(); EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, 128, 256, GL_RGBA, true); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(envMapSkyTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(envMapSkyTexture), 0); irradiancePhase = 0; @@ -725,7 +766,8 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(atmosphereIrradianceTexture); setLinear(); EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, 32, 64, GL_RGBA, true); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(atmosphereIrradianceTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(atmosphereIrradianceTexture), 0); GlStateManager.clearColor(0.0f, 0.0f, 0.0f, 0.0f); GlStateManager.clear(GL_COLOR_BUFFER_BIT); @@ -735,7 +777,8 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(skyIrradianceTexture); setLinear(); EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, 32, 64, GL_RGBA, true); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(skyIrradianceTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(skyIrradianceTexture), 0); GlStateManager.clearColor(0.0f, 0.0f, 0.0f, 0.0f); GlStateManager.clear(GL_COLOR_BUFFER_BIT); @@ -749,20 +792,21 @@ public class EaglerDeferredPipeline { _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ByteBuffer copyBuffer = EagRuntime.allocateByteBuffer(262144); int mip = 0; - try(DataInputStream dis = new DataInputStream(EagRuntime.getResourceStream("/assets/eagler/glsl/deferred/eagler_moon.bmp"))) { - while(dis.read() == 'E') { + try (DataInputStream dis = new DataInputStream( + EagRuntime.getResourceStream("/assets/eagler/glsl/deferred/eagler_moon.bmp"))) { + while (dis.read() == 'E') { int w = dis.readShort(); int h = dis.readShort(); copyBuffer.clear(); - for(int i = 0, l = w * h * 4; i < l; ++i) { - copyBuffer.put((byte)dis.read()); + for (int i = 0, l = w * h * 4; i < l; ++i) { + copyBuffer.put((byte) dis.read()); } copyBuffer.flip(); _wglTexImage2D(GL_TEXTURE_2D, mip++, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, copyBuffer); } - }catch(IOException ex) { + } catch (IOException ex) { throw new RuntimeException("Could not load \"eagler_moon.bmp\"!", ex); - }finally { + } finally { EagRuntime.freeByteBuffer(copyBuffer); } _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mip - 1); @@ -778,7 +822,8 @@ public class EaglerDeferredPipeline { fogDepthCopyTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(fogDepthCopyTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(fogDepthCopyTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(fogDepthCopyTexture), 0); shader_atmosphere_fog = PipelineShaderGBufferFog.compile(false, true, config.is_rendering_lightShafts); shader_atmosphere_fog.loadUniforms(); @@ -789,40 +834,46 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("Post: rebuild pipeline: fog"); - if(config.is_rendering_useEnvMap) { + if (config.is_rendering_useEnvMap) { envMapFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, envMapFramebuffer); envMapColorTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(envMapColorTexture); setLinear(); EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, 128, 256, GL_RGBA, true); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(envMapColorTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(envMapColorTexture), 0); envMapDepthTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(envMapDepthTexture); setNearest(); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT24, 128, 256, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, (ByteBuffer)null); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(envMapDepthTexture), 0); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT24, 128, 256, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, + (ByteBuffer) null); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(envMapDepthTexture), 0); DeferredStateManager.checkGLError("Post: rebuild pipeline: env map"); } - if(config.is_rendering_realisticWater) { + if (config.is_rendering_realisticWater) { realisticWaterMaskFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterMaskFramebuffer); realisticWaterMaskTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(realisticWaterMaskTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterMaskTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterMaskTexture), 0); realisticWaterDepthBuffer = GlStateManager.generateTexture(); GlStateManager.bindTexture(realisticWaterDepthBuffer); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterDepthBuffer), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterDepthBuffer), 0); realisticWaterCombinedNormalsFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterCombinedNormalsFramebuffer); realisticWaterCombinedNormalsTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(realisticWaterCombinedNormalsTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterCombinedNormalsTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterCombinedNormalsTexture), 0); realisticWaterRefractionTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(realisticWaterRefractionTexture); setNearest(); @@ -831,23 +882,28 @@ public class EaglerDeferredPipeline { realisticWaterControlReflectionTexture[0] = GlStateManager.generateTexture(); realisticWaterControlReflectionTexture[1] = GlStateManager.generateTexture(); GlStateManager.bindTexture(realisticWaterControlReflectionTexture[0]); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterControlReflectionTexture[0]), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterControlReflectionTexture[0]), 0); realisticWaterControlHitVectorTexture[0] = GlStateManager.generateTexture(); realisticWaterControlHitVectorTexture[1] = GlStateManager.generateTexture(); GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[0]); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterControlHitVectorTexture[0]), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterControlHitVectorTexture[0]), 0); GlStateManager.bindTexture(realisticWaterRefractionTexture); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterRefractionTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterRefractionTexture), 0); _wglDrawBuffers(new int[] { _GL_COLOR_ATTACHMENT0, _GL_COLOR_ATTACHMENT1, _GL_COLOR_ATTACHMENT2 }); - for(int i = 0; i < 2; ++i) { + for (int i = 0; i < 2; ++i) { realisticWaterSSRFramebuffer[i] = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[i]); GlStateManager.bindTexture(realisticWaterControlReflectionTexture[i]); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterControlReflectionTexture[i]), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterControlReflectionTexture[i]), 0); GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[i]); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterControlHitVectorTexture[i]), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterControlHitVectorTexture[i]), 0); _wglDrawBuffers(new int[] { _GL_COLOR_ATTACHMENT0, _GL_COLOR_ATTACHMENT1 }); } realisticWaterDisplacementMapFramebuffer = _wglCreateFramebuffer(); @@ -855,7 +911,8 @@ public class EaglerDeferredPipeline { realisticWaterDisplacementMapTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(realisticWaterDisplacementMapTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterDisplacementMapTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterDisplacementMapTexture), 0); EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, 256, 256, GL_RED, true); realisticWaterNormalMapFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterNormalMapFramebuffer); @@ -865,8 +922,9 @@ public class EaglerDeferredPipeline { _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(realisticWaterNormalMapTexture), 0); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_RG8, 256, 256, 0, _GL_RG, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(realisticWaterNormalMapTexture), 0); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_RG8, 256, 256, 0, _GL_RG, GL_UNSIGNED_BYTE, (ByteBuffer) null); realisticWaterNoiseMap = GlStateManager.generateTexture(); GlStateManager.bindTexture(realisticWaterNoiseMap); _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -876,10 +934,10 @@ public class EaglerDeferredPipeline { String realistic_water_noise_filename = "assets/eagler/glsl/deferred/realistic_water_noise.bmp"; byte[] bitmapBytes = EagRuntime.getResourceBytes(realistic_water_noise_filename); try { - if(bitmapBytes.length != 32768) { + if (bitmapBytes.length != 32768) { throw new IOException("File is length " + bitmapBytes.length + ", expected " + 32768); } - }catch(Throwable t) { + } catch (Throwable t) { throw new RuntimeException("File \"" + realistic_water_noise_filename + "\" could not be loaded!", t); } ByteBuffer buf = EagRuntime.allocateByteBuffer(32768); @@ -894,7 +952,7 @@ public class EaglerDeferredPipeline { shader_realistic_water_normals = PipelineShaderRealisticWaterNormalMap.compile(); shader_realistic_water_normals.loadUniforms(); _wglUniform2f(shader_realistic_water_normals.uniforms.u_sampleOffset2f, 0.00390625f, 0.00390625f); - if(!config.is_rendering_raytracing) { + if (!config.is_rendering_raytracing) { shader_reproject_ssr = PipelineShaderReprojSSR.compile(); shader_reproject_ssr.loadUniforms(); } @@ -902,18 +960,19 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("Post: rebuild pipeline: realistic water"); } - if(config.is_rendering_fxaa) { + if (config.is_rendering_fxaa) { tonemapOutputFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, tonemapOutputFramebuffer); tonemapOutputTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(tonemapOutputTexture); setNearest(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(tonemapOutputTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(tonemapOutputTexture), 0); DeferredStateManager.checkGLError("Post: rebuild pipeline: fxaa"); } - if(config.is_rendering_lensFlares) { + if (config.is_rendering_lensFlares) { LensFlareMeshRenderer.initialize(); DeferredStateManager.checkGLError("Post: rebuild pipeline: lensFlares"); } @@ -946,20 +1005,22 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("Post: rebuild pipeline: skybox shaders"); - if(config.is_rendering_lightShafts) { + if (config.is_rendering_lightShafts) { lightShaftsFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, lightShaftsFramebuffer); lightShaftsTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(lightShaftsTexture); setLinear(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(lightShaftsTexture), 0); - shader_light_shafts_sample = PipelineShaderLightShaftsSample.compile(config.is_rendering_shadowsSun_clamped); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(lightShaftsTexture), 0); + shader_light_shafts_sample = PipelineShaderLightShaftsSample + .compile(config.is_rendering_shadowsSun_clamped); shader_light_shafts_sample.loadUniforms(); DeferredStateManager.checkGLError("Post: rebuild pipeline: light shafts"); } - if(config.is_rendering_bloom) { + if (config.is_rendering_bloom) { bloomBrightPassFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, bloomBrightPassFramebuffer); bloomBrightPassTexture = GlStateManager.generateTexture(); @@ -967,19 +1028,22 @@ public class EaglerDeferredPipeline { setNearest(); _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(bloomBrightPassTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(bloomBrightPassTexture), 0); bloomDownscaleAFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, bloomDownscaleAFramebuffer); bloomDownscaleATexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(bloomDownscaleATexture); setLinear(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(bloomDownscaleATexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(bloomDownscaleATexture), 0); bloomDownscaleBFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, bloomDownscaleBFramebuffer); bloomDownscaleBTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(bloomDownscaleBTexture); setLinear(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(bloomDownscaleBTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(bloomDownscaleBTexture), 0); bloomHBlurFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, bloomHBlurFramebuffer); bloomHBlurTexture = GlStateManager.generateTexture(); @@ -987,13 +1051,15 @@ public class EaglerDeferredPipeline { setNearest(); _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); _wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(bloomHBlurTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(bloomHBlurTexture), 0); bloomVBlurFramebuffer = _wglCreateFramebuffer(); _wglBindFramebuffer(_GL_FRAMEBUFFER, bloomVBlurFramebuffer); bloomVBlurTexture = GlStateManager.generateTexture(); GlStateManager.bindTexture(bloomVBlurTexture); setLinear(); - _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(bloomVBlurTexture), 0); + _wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + EaglercraftGPU.getNativeTexture(bloomVBlurTexture), 0); shader_post_bloom_bright = PipelineShaderBloomBrightPass.compile(); shader_post_bloom_bright.loadUniforms(); shader_post_bloom_blur = PipelineShaderBloomBlurPass.compile(); @@ -1005,7 +1071,7 @@ public class EaglerDeferredPipeline { gbufferEffectRenderer.initialize(); forwardEffectRenderer.initialize(config.is_rendering_dynamicLights, config.is_rendering_shadowsSun_clamped); - if(config.is_rendering_dynamicLights) { + if (config.is_rendering_dynamicLights) { shader_lighting_point = PipelineShaderLightingPoint.compile(false); shader_lighting_point.loadUniforms(); @@ -1013,7 +1079,7 @@ public class EaglerDeferredPipeline { EaglercraftGPU.bindGLUniformBuffer(buffer_chunkLightingData); int lightingDataLength = 8 * MAX_LIGHTS_PER_CHUNK + 4; chunkLightingDataCopyBuffer = EagRuntime.allocateByteBuffer(lightingDataLength << 2); - for(int i = 0; i < lightingDataLength; ++i) { + for (int i = 0; i < lightingDataLength; ++i) { chunkLightingDataCopyBuffer.putInt(0); } chunkLightingDataCopyBuffer.flip(); @@ -1025,7 +1091,7 @@ public class EaglerDeferredPipeline { buffer_worldLightingData = _wglGenBuffers(); EaglercraftGPU.bindGLUniformBuffer(buffer_worldLightingData); worldLightingDataCopyBuffer = EagRuntime.allocateByteBuffer(304); - for(int i = 0; i < 76; ++i) { + for (int i = 0; i < 76; ++i) { worldLightingDataCopyBuffer.putInt(0); } worldLightingDataCopyBuffer.flip(); @@ -1035,8 +1101,9 @@ public class EaglerDeferredPipeline { FixedFunctionPipeline.loadExtensionPipeline(deferredExtPipeline); - if(!EaglercraftGPU.checkHDRFramebufferSupport(16)) { - logger.warn("16-bit HDR (floating point) framebuffers are not supported on this device, 32-bit framebuffers will be used instead which may slow the game down"); + if (!EaglercraftGPU.checkHDRFramebufferSupport(16)) { + logger.warn( + "16-bit HDR (floating point) framebuffers are not supported on this device, 32-bit framebuffers will be used instead which may slow the game down"); } _wglBindFramebuffer(_GL_FRAMEBUFFER, null); @@ -1047,7 +1114,7 @@ public class EaglerDeferredPipeline { double distX = worldX - reprojectionOriginCoordinateX; double distY = worldY - reprojectionOriginCoordinateY; double distZ = worldZ - reprojectionOriginCoordinateZ; - if(distX * distX + distY * distY + distZ * distZ > 48.0 * 48.0) { + if (distX * distX + distY * distY + distZ * distZ > 48.0 * 48.0) { reprojectionOriginCoordinateX = worldX; reprojectionOriginCoordinateY = worldY; reprojectionOriginCoordinateZ = worldZ; @@ -1055,19 +1122,19 @@ public class EaglerDeferredPipeline { reprojectionViewerOffsetY = 0.0f; reprojectionViewerOffsetZ = 0.0f; reprojectionStartup = 0; - }else { + } else { reprojectionViewerOffsetX = (float) distX; reprojectionViewerOffsetY = (float) distY; reprojectionViewerOffsetZ = (float) distZ; } distX = worldX - cloudRenderOriginCoordinateX; distZ = worldZ - cloudRenderOriginCoordinateZ; - if(distX * distX + distZ * distZ > 256.0 * 256.0) { + if (distX * distX + distZ * distZ > 256.0 * 256.0) { cloudRenderOriginCoordinateX = worldX; cloudRenderOriginCoordinateZ = worldZ; cloudRenderViewerOffsetX = 0.0f; cloudRenderViewerOffsetZ = 0.0f; - }else { + } else { cloudRenderViewerOffsetX = (float) distX; cloudRenderViewerOffsetZ = (float) distZ; } @@ -1082,30 +1149,31 @@ public class EaglerDeferredPipeline { } public void resize(int w, int h) { - if(w == currentWidth && h == currentHeight) { + if (w == currentWidth && h == currentHeight) { return; } DeferredStateManager.checkGLError("Pre: resize pipeline to " + w + " x " + h); GlStateManager.bindTexture(gBufferDiffuseTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); GlStateManager.bindTexture(gBufferNormalsTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); GlStateManager.bindTexture(gBufferMaterialTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); GlStateManager.bindTexture(gBufferDepthTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, + (ByteBuffer) null); DeferredStateManager.checkGLError("Post: resize pipeline: gbuffer"); - if(config.is_rendering_shadowsSun_clamped > 0) { + if (config.is_rendering_shadowsSun_clamped > 0) { GlStateManager.bindTexture(sunLightingShadowTexture); - if(config.is_rendering_shadowsColored) { - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); - }else { - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, (ByteBuffer)null); + if (config.is_rendering_shadowsColored) { + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); + } else { + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, (ByteBuffer) null); } DeferredStateManager.checkGLError("Post: resize pipeline: sunLightingShadowTexture"); } @@ -1115,107 +1183,128 @@ public class EaglerDeferredPipeline { reprojectionTexHeight = h >> 1; shader_deferred_combine.useProgram(); - _wglUniform2f(shader_deferred_combine.uniforms.u_halfResolutionPixelAlignment2f, (float)w / (reprojectionTexWidth << 1), (float)h / (reprojectionTexHeight << 1)); + _wglUniform2f(shader_deferred_combine.uniforms.u_halfResolutionPixelAlignment2f, + (float) w / (reprojectionTexWidth << 1), (float) h / (reprojectionTexHeight << 1)); - if(config.is_rendering_ssao) { + if (config.is_rendering_ssao) { GlStateManager.bindTexture(ssaoGenerateTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_R8, reprojectionTexWidth, reprojectionTexHeight, 0, GL_RED, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_R8, reprojectionTexWidth, reprojectionTexHeight, 0, GL_RED, + GL_UNSIGNED_BYTE, (ByteBuffer) null); DeferredStateManager.checkGLError("Post: resize pipeline: ssao"); } - if(reprojectionEngineEnable || config.is_rendering_realisticWater) { + if (reprojectionEngineEnable || config.is_rendering_realisticWater) { GlStateManager.bindTexture(lastFrameColorTexture); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, reprojectionTexHeight, GL_RGBA, true); + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, reprojectionTexHeight, + GL_RGBA, true); GlStateManager.bindTexture(lastFrameDepthTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, reprojectionTexWidth, reprojectionTexHeight, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, reprojectionTexWidth, reprojectionTexHeight, 0, + _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer) null); GlStateManager.bindTexture(lastFrameGBufferDepthTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, + (ByteBuffer) null); DeferredStateManager.checkGLError("Post: resize pipeline: lastFrame"); } - if(config.is_rendering_raytracing || config.is_rendering_realisticWater) { + if (config.is_rendering_raytracing || config.is_rendering_realisticWater) { shader_reproject_ssr.useProgram(); - _wglUniform4f(shader_reproject_ssr.uniforms.u_pixelAlignment4f, reprojectionTexWidth, reprojectionTexHeight, w, h); + _wglUniform4f(shader_reproject_ssr.uniforms.u_pixelAlignment4f, reprojectionTexWidth, reprojectionTexHeight, + w, h); } - if(reprojectionEngineEnable) { + if (reprojectionEngineEnable) { GlStateManager.bindTexture(gBufferQuarterDepthTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, reprojectionTexWidth, reprojectionTexHeight, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, reprojectionTexWidth, reprojectionTexHeight, 0, + _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer) null); - for(int i = 0; i < 2; ++i) { - if(config.is_rendering_ssao) { + for (int i = 0; i < 2; ++i) { + if (config.is_rendering_ssao) { GlStateManager.bindTexture(reprojectionControlSSAOTexture[i]); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, reprojectionTexWidth, reprojectionTexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, reprojectionTexWidth, reprojectionTexHeight, 0, GL_RGBA, + GL_UNSIGNED_BYTE, (ByteBuffer) null); } - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { GlStateManager.bindTexture(reprojectionSSRTexture[i]); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, reprojectionTexHeight, GL_RGBA, true); + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, + reprojectionTexHeight, GL_RGBA, true); GlStateManager.bindTexture(reprojectionSSRHitVector[i]); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, reprojectionTexHeight, GL_RGBA, true); + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, + reprojectionTexHeight, GL_RGBA, true); } } shader_reproject_control.useProgram(); - _wglUniform4f(shader_reproject_control.uniforms.u_pixelAlignment4f, reprojectionTexWidth, reprojectionTexHeight, w, h); + _wglUniform4f(shader_reproject_control.uniforms.u_pixelAlignment4f, reprojectionTexWidth, + reprojectionTexHeight, w, h); DeferredStateManager.checkGLError("Post: resize pipeline: reprojectionEngineEnable"); } - if(config.is_rendering_realisticWater) { + if (config.is_rendering_realisticWater) { GlStateManager.bindTexture(realisticWaterMaskTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); GlStateManager.bindTexture(realisticWaterDepthBuffer); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, + (ByteBuffer) null); GlStateManager.bindTexture(realisticWaterCombinedNormalsTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); GlStateManager.bindTexture(realisticWaterRefractionTexture); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, reprojectionTexHeight, GL_RGBA, true); - for(int i = 0; i < 2; ++i) { + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, reprojectionTexHeight, + GL_RGBA, true); + for (int i = 0; i < 2; ++i) { GlStateManager.bindTexture(realisticWaterControlReflectionTexture[i]); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, reprojectionTexHeight, GL_RGBA, true); + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, + reprojectionTexHeight, GL_RGBA, true); GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[i]); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, reprojectionTexHeight, GL_RGBA, true); + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, + reprojectionTexHeight, GL_RGBA, true); } shader_realistic_water_control.useProgram(); - _wglUniform4f(shader_realistic_water_control.uniforms.u_pixelAlignment4f, reprojectionTexWidth, reprojectionTexHeight, w, h); + _wglUniform4f(shader_realistic_water_control.uniforms.u_pixelAlignment4f, reprojectionTexWidth, + reprojectionTexHeight, w, h); DeferredStateManager.checkGLError("Post: resize pipeline: realisticWater"); } - if(config.is_rendering_lightShafts) { + if (config.is_rendering_lightShafts) { GlStateManager.bindTexture(lightShaftsTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_R8, reprojectionTexWidth, reprojectionTexHeight, 0, GL_RED, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_R8, reprojectionTexWidth, reprojectionTexHeight, 0, GL_RED, + GL_UNSIGNED_BYTE, (ByteBuffer) null); DeferredStateManager.checkGLError("Post: resize pipeline: lightShafts"); } GlStateManager.bindTexture(lightingHDRFramebufferColorTexture); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, w, h, GL_RGBA, true); // USE RGBA! WebGL won't render to RGB16F + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, w, h, GL_RGBA, true); // USE RGBA! WebGL won't + // render to RGB16F GlStateManager.bindTexture(lightingHDRFramebufferDepthTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, + (ByteBuffer) null); GlStateManager.bindTexture(handRenderFramebufferDepthTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, + (ByteBuffer) null); DeferredStateManager.checkGLError("Post: resize pipeline: lightingHDRFramebuffer"); GlStateManager.bindTexture(fogDepthCopyTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, + (ByteBuffer) null); DeferredStateManager.checkGLError("Post: resize pipeline: fogDepthCopyTexture"); - if(config.is_rendering_lensDistortion) { + if (config.is_rendering_lensDistortion) { GlStateManager.bindTexture(lensDistortTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); DeferredStateManager.checkGLError("Post: resize pipeline: lensDistortion"); } - if(config.is_rendering_fxaa) { + if (config.is_rendering_fxaa) { GlStateManager.bindTexture(tonemapOutputTexture); - _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null); + _wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); DeferredStateManager.checkGLError("Post: resize pipeline: fxaa"); } - if(config.is_rendering_bloom) { + if (config.is_rendering_bloom) { int bloomStageW = w; int bloomStageH = h; GlStateManager.bindTexture(bloomBrightPassTexture); @@ -1224,27 +1313,29 @@ public class EaglerDeferredPipeline { bloomBrightPassTextureH = bloomStageH; bloomDownscaleATextureW = bloomDownscaleATextureH = 0; bloomDownscaleBTextureW = bloomDownscaleBTextureH = 0; - if(bloomStageW > 150 && bloomStageH > 85) { + if (bloomStageW > 150 && bloomStageH > 85) { setLinear(); bloomStageW >>= 1; bloomStageH >>= 1; - if(bloomStageW > 150 && bloomStageH > 85) { + if (bloomStageW > 150 && bloomStageH > 85) { GlStateManager.bindTexture(bloomDownscaleATexture); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, bloomStageW, bloomStageH, GL_RGBA, true); + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, bloomStageW, bloomStageH, GL_RGBA, + true); bloomDownscaleATextureW = bloomStageW; bloomDownscaleATextureH = bloomStageH; bloomStageW >>= 1; bloomStageH >>= 1; - if(bloomStageW > 150 && bloomStageH > 85) { + if (bloomStageW > 150 && bloomStageH > 85) { GlStateManager.bindTexture(bloomDownscaleBTexture); - EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, bloomStageW, bloomStageH, GL_RGBA, true); + EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, bloomStageW, bloomStageH, + GL_RGBA, true); bloomDownscaleBTextureW = bloomStageW; bloomDownscaleBTextureH = bloomStageH; bloomStageW >>= 1; bloomStageH >>= 1; } } - }else { + } else { setNearest(); } GlStateManager.bindTexture(bloomHBlurTexture); @@ -1256,21 +1347,21 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("Post: resize pipeline: bloom"); } - if(lumaAvgDownscaleFramebuffers != null) { - for(int i = 0; i < lumaAvgDownscaleFramebuffers.length; ++i) { + if (lumaAvgDownscaleFramebuffers != null) { + for (int i = 0; i < lumaAvgDownscaleFramebuffers.length; ++i) { _wglDeleteFramebuffer(lumaAvgDownscaleFramebuffers[i]); } } - if(lumaAvgDownscaleTexture != null) { - for(int i = 0; i < lumaAvgDownscaleTexture.length; ++i) { + if (lumaAvgDownscaleTexture != null) { + for (int i = 0; i < lumaAvgDownscaleTexture.length; ++i) { GlStateManager.deleteTexture(lumaAvgDownscaleTexture[i]); } } int j = 0; int k = h > w ? w : h; - while(k > 8) { + while (k > 8) { ++j; k >>= 2; } @@ -1281,7 +1372,7 @@ public class EaglerDeferredPipeline { int kw = w; int kh = h; int kw2, kh2; - for(int i = 0; i < j; ++i) { + for (int i = 0; i < j; ++i) { kw2 = kw >> 2; kh2 = kh >> 2; lumaAvgDownscaleFramebuffers[i] = _wglCreateFramebuffer(); @@ -1362,14 +1453,14 @@ public class EaglerDeferredPipeline { public void beginDrawMainShadowMap() { DeferredStateManager.checkGLError("Pre: beginDrawMainShadowMap()"); - if(config.is_rendering_shadowsColored) { + if (config.is_rendering_shadowsColored) { _wglBindFramebuffer(_GL_FRAMEBUFFER, sunShadowColorFramebuffer); _wglDrawBuffers(_GL_COLOR_ATTACHMENT0); GlStateManager.clearColor(1.0f, 1.0f, 1.0f, 1.0f); GlStateManager.clearDepth(1.0f); GlStateManager.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); _wglBindFramebuffer(_GL_FRAMEBUFFER, sunShadowFramebuffer); - }else { + } else { _wglBindFramebuffer(_GL_FRAMEBUFFER, sunShadowFramebuffer); _wglDrawBuffers(_GL_COLOR_ATTACHMENT0); GlStateManager.clearDepth(1.0f); @@ -1453,13 +1544,16 @@ public class EaglerDeferredPipeline { Matrix4f.invert(tmpMatrixViewProj, tmpMatrixInverseViewProj); Entity renderViewEntity = mc.getRenderViewEntity(); - if(renderViewEntity == null) { + if (renderViewEntity == null) { renderViewEntity = mc.thePlayer; } - double entityPosX = renderViewEntity.prevPosX + (renderViewEntity.posX - renderViewEntity.prevPosX) * partialTicks; - double entityPosY = renderViewEntity.prevPosY + (renderViewEntity.posY - renderViewEntity.prevPosY) * partialTicks; - double entityPosZ = renderViewEntity.prevPosZ + (renderViewEntity.posZ - renderViewEntity.prevPosZ) * partialTicks; + double entityPosX = renderViewEntity.prevPosX + + (renderViewEntity.posX - renderViewEntity.prevPosX) * partialTicks; + double entityPosY = renderViewEntity.prevPosY + + (renderViewEntity.posY - renderViewEntity.prevPosY) * partialTicks; + double entityPosZ = renderViewEntity.prevPosZ + + (renderViewEntity.posZ - renderViewEntity.prevPosZ) * partialTicks; int entityChunkOriginX = MathHelper.floor_double(entityPosX / 16.0) << 4; int entityChunkOriginY = MathHelper.floor_double(entityPosY / 16.0) << 4; int entityChunkOriginZ = MathHelper.floor_double(entityPosZ / 16.0) << 4; @@ -1473,15 +1567,15 @@ public class EaglerDeferredPipeline { // ==================== UPDATE CLOUD RENDERER ===================== // - if(dim == 0) { - CloudRenderWorker.setPosition(cloudRenderViewerOffsetX, (float)entityPosY, cloudRenderViewerOffsetZ); + if (dim == 0) { + CloudRenderWorker.setPosition(cloudRenderViewerOffsetX, (float) entityPosY, cloudRenderViewerOffsetZ); CloudRenderWorker.update(); DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): UPDATE CLOUD RENDERER"); } - if(millis - recalcAtmosphereTimer > 100l) { + if (millis - recalcAtmosphereTimer > 100l) { - if(dim == 0) { + if (dim == 0) { // =============== CALCULATE ATMOSPHERE COLORS ================ // @@ -1491,8 +1585,10 @@ public class EaglerDeferredPipeline { GlStateManager.setActiveTexture(GL_TEXTURE0); GlStateManager.bindTexture(skybox.getNormalsLUT()); GlStateManager.viewport(0, 0, skybox.getAtmosLUTWidth(), skybox.getAtmosLUTHeight()); - _wglUniform4f(shader_skybox_atmosphere.uniforms.u_sunDirectionIntensity4f, -currentSunAngle.x, -currentSunAngle.y, -currentSunAngle.z, 5.0f); - _wglUniform1f(shader_skybox_atmosphere.uniforms.u_altitude1f, Math.max((float)(entityPosY - 85.0), -20.0f)); + _wglUniform4f(shader_skybox_atmosphere.uniforms.u_sunDirectionIntensity4f, -currentSunAngle.x, + -currentSunAngle.y, -currentSunAngle.z, 5.0f); + _wglUniform1f(shader_skybox_atmosphere.uniforms.u_altitude1f, + Math.max((float) (entityPosY - 85.0), -20.0f)); Vector3f sunColorTmp = tmpVector3; sunColorTmp.set(DeferredStateManager.currentSunLightColor); float luma = sunColorTmp.x * 0.299f + sunColorTmp.y * 0.587f + sunColorTmp.z * 0.114f; @@ -1501,7 +1597,8 @@ public class EaglerDeferredPipeline { sunColorTmp.y = (sunColorTmp.y - luma) * sat + luma; sunColorTmp.z = (sunColorTmp.z - luma) * sat + luma; sunColorTmp.scale(0.3f - ff2 * 0.175f); - _wglUniform4f(shader_skybox_atmosphere.uniforms.u_blendColor4f, sunColorTmp.x * 0.05f, sunColorTmp.y * 0.05f, sunColorTmp.z * 0.05f, fff); + _wglUniform4f(shader_skybox_atmosphere.uniforms.u_blendColor4f, sunColorTmp.x * 0.05f, + sunColorTmp.y * 0.05f, sunColorTmp.z * 0.05f, fff); DrawUtils.drawStandardQuad2D(); @@ -1516,45 +1613,52 @@ public class EaglerDeferredPipeline { GlStateManager.setActiveTexture(GL_TEXTURE0); GlStateManager.bindTexture(atmosphereHDRFramebufferColorTexture); shader_skybox_render_paraboloid.useProgram(); - uniformMatrixHelper(shader_skybox_render_paraboloid.uniforms.u_viewMatrix4f, DeferredStateManager.paraboloidTopViewMatrix); + uniformMatrixHelper(shader_skybox_render_paraboloid.uniforms.u_viewMatrix4f, + DeferredStateManager.paraboloidTopViewMatrix); _wglUniform1f(shader_skybox_render_paraboloid.uniforms.u_farPlane1f, 2.0f); if (mc.theWorld.getLastLightningBolt() > 0) { float f = 0.3f + fff; - _wglUniform4f(shader_skybox_render_paraboloid.uniforms.u_lightningColor4f, 0.02f * f, 0.02f * f, 0.02f * f, 1.0f - f * 0.25f); - }else { + _wglUniform4f(shader_skybox_render_paraboloid.uniforms.u_lightningColor4f, 0.02f * f, 0.02f * f, + 0.02f * f, 1.0f - f * 0.25f); + } else { _wglUniform4f(shader_skybox_render_paraboloid.uniforms.u_lightningColor4f, 0.0f, 0.0f, 0.0f, 1.0f); } skybox.drawTop(); GlStateManager.viewport(0, 128, 128, 128); - uniformMatrixHelper(shader_skybox_render_paraboloid.uniforms.u_viewMatrix4f, DeferredStateManager.paraboloidBottomViewMatrix); + uniformMatrixHelper(shader_skybox_render_paraboloid.uniforms.u_viewMatrix4f, + DeferredStateManager.paraboloidBottomViewMatrix); skybox.drawBottom(); DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): GENERATE SKY REFLECTION MAP"); - - if(irradiancePhase++ % 10 == 0) { + if (irradiancePhase++ % 10 == 0) { // =============== GENERATE ATMOSPHERE REFLECTION MAP ================ // _wglBindFramebuffer(_GL_FRAMEBUFFER, envMapAtmosphereFramebuffer); GlStateManager.viewport(0, 0, 128, 128); shader_skybox_render_paraboloid_noclouds.useProgram(); - uniformMatrixHelper(shader_skybox_render_paraboloid_noclouds.uniforms.u_viewMatrix4f, DeferredStateManager.paraboloidTopViewMatrix); + uniformMatrixHelper(shader_skybox_render_paraboloid_noclouds.uniforms.u_viewMatrix4f, + DeferredStateManager.paraboloidTopViewMatrix); _wglUniform1f(shader_skybox_render_paraboloid_noclouds.uniforms.u_farPlane1f, 2.0f); if (mc.theWorld.getLastLightningBolt() > 0) { float f = 0.3f + fff; - _wglUniform4f(shader_skybox_render_paraboloid_noclouds.uniforms.u_lightningColor4f, 0.02f * f, 0.02f * f, 0.02f * f, 1.0f - f * 0.25f); - }else { - _wglUniform4f(shader_skybox_render_paraboloid_noclouds.uniforms.u_lightningColor4f, 0.0f, 0.0f, 0.0f, 1.0f); + _wglUniform4f(shader_skybox_render_paraboloid_noclouds.uniforms.u_lightningColor4f, 0.02f * f, + 0.02f * f, 0.02f * f, 1.0f - f * 0.25f); + } else { + _wglUniform4f(shader_skybox_render_paraboloid_noclouds.uniforms.u_lightningColor4f, 0.0f, 0.0f, + 0.0f, 1.0f); } skybox.drawTop(); GlStateManager.viewport(0, 128, 128, 128); - uniformMatrixHelper(shader_skybox_render_paraboloid_noclouds.uniforms.u_viewMatrix4f, DeferredStateManager.paraboloidBottomViewMatrix); + uniformMatrixHelper(shader_skybox_render_paraboloid_noclouds.uniforms.u_viewMatrix4f, + DeferredStateManager.paraboloidBottomViewMatrix); skybox.drawBottom(); - DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): GENERATE ATMOSPHERE REFLECTION MAP"); + DeferredStateManager + .checkGLError("combineGBuffersAndIlluminate(): GENERATE ATMOSPHERE REFLECTION MAP"); // =============== GENERATE ATMOSPHERE IRRADIANCE MAP ================ // @@ -1576,9 +1680,10 @@ public class EaglerDeferredPipeline { GlStateManager.disableBlend(); - DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): GENERATE ATMOSPHERE IRRADIANCE MAP"); + DeferredStateManager + .checkGLError("combineGBuffersAndIlluminate(): GENERATE ATMOSPHERE IRRADIANCE MAP"); - }else { + } else { // =============== GENERATE SKY IRRADIANCE MAP ================ // @@ -1602,7 +1707,7 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): GENERATE SKY IRRADIANCE MAP"); } - }else if(dim == -1) { + } else if (dim == -1) { // =============== NETHER SKY REFLECTION MAP ================ // @@ -1620,7 +1725,7 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): NETHER SKY IRRADIANCE MAP"); - }else if(dim == 1) { + } else if (dim == 1) { // =============== END SKY REFLECTION MAP ================ // @@ -1642,7 +1747,7 @@ public class EaglerDeferredPipeline { } - if(reprojectionEngineEnable) { + if (reprojectionEngineEnable) { // ============ DOWNSCALE DEPTH BUFFER, FOR PERFORMANCE =========== // @@ -1654,15 +1759,17 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(gBufferDepthTexture); _wglDrawBuffers(GL_NONE); GlStateManager.viewport(0, 0, reprojectionTexWidth, reprojectionTexHeight); - TextureCopyUtil.alignPixelsTopLeft(reprojectionTexWidth << 1, reprojectionTexHeight << 1, reprojectionTexWidth, reprojectionTexHeight); + TextureCopyUtil.alignPixelsTopLeft(reprojectionTexWidth << 1, reprojectionTexHeight << 1, + reprojectionTexWidth, reprojectionTexHeight); TextureCopyUtil.blitTextureDepth(); GlStateManager.disableDepth(); GlStateManager.depthMask(false); GlStateManager.depthFunc(GL_LEQUAL); - DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): DOWNSCALE DEPTH BUFFER, FOR PERFORMANCE"); + DeferredStateManager + .checkGLError("combineGBuffersAndIlluminate(): DOWNSCALE DEPTH BUFFER, FOR PERFORMANCE"); - if(config.is_rendering_ssao) { + if (config.is_rendering_ssao) { // ====================== RUN SSAO ALGORITHM ====================== // @@ -1675,13 +1782,19 @@ public class EaglerDeferredPipeline { GlStateManager.setActiveTexture(GL_TEXTURE0); GlStateManager.bindTexture(gBufferQuarterDepthTexture); shader_ssao_generate.useProgram(); - uniformMatrixHelper(shader_ssao_generate.uniforms.u_projectionMatrix4f, DeferredStateManager.projMatrix); - uniformMatrixHelper(shader_ssao_generate.uniforms.u_inverseProjectionMatrix4f, DeferredStateManager.inverseProjMatrix); + uniformMatrixHelper(shader_ssao_generate.uniforms.u_projectionMatrix4f, + DeferredStateManager.projMatrix); + uniformMatrixHelper(shader_ssao_generate.uniforms.u_inverseProjectionMatrix4f, + DeferredStateManager.inverseProjMatrix); matrixCopyBuffer.clear(); - matrixCopyBuffer.put(((random.nextFloat() * 25.0f - 12.5f) + (random.nextBoolean() ? 1.0f : -1.0f) * (random.nextFloat() * 6.0f + 6.0f)) * 10.0f); - matrixCopyBuffer.put(((random.nextFloat() * 25.0f - 12.5f) + (random.nextBoolean() ? 1.0f : -1.0f) * (random.nextFloat() * 6.0f + 6.0f)) * 10.0f); - matrixCopyBuffer.put(((random.nextFloat() * 25.0f - 12.5f) + (random.nextBoolean() ? 1.0f : -1.0f) * (random.nextFloat() * 6.0f + 6.0f)) * 10.0f); - matrixCopyBuffer.put(((random.nextFloat() * 25.0f - 12.5f) + (random.nextBoolean() ? 1.0f : -1.0f) * (random.nextFloat() * 6.0f + 6.0f)) * 10.0f); + matrixCopyBuffer.put(((random.nextFloat() * 25.0f - 12.5f) + + (random.nextBoolean() ? 1.0f : -1.0f) * (random.nextFloat() * 6.0f + 6.0f)) * 10.0f); + matrixCopyBuffer.put(((random.nextFloat() * 25.0f - 12.5f) + + (random.nextBoolean() ? 1.0f : -1.0f) * (random.nextFloat() * 6.0f + 6.0f)) * 10.0f); + matrixCopyBuffer.put(((random.nextFloat() * 25.0f - 12.5f) + + (random.nextBoolean() ? 1.0f : -1.0f) * (random.nextFloat() * 6.0f + 6.0f)) * 10.0f); + matrixCopyBuffer.put(((random.nextFloat() * 25.0f - 12.5f) + + (random.nextBoolean() ? 1.0f : -1.0f) * (random.nextFloat() * 6.0f + 6.0f)) * 10.0f); matrixCopyBuffer.flip(); _wglUniformMatrix2fv(shader_ssao_generate.uniforms.u_randomizerDataMatrix2f, false, matrixCopyBuffer); @@ -1695,45 +1808,46 @@ public class EaglerDeferredPipeline { // ============== RUN REPROJECTION CONTROL SHADER ================ // GlStateManager.setActiveTexture(GL_TEXTURE8); - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { GlStateManager.bindTexture(gBufferMaterialTexture); - }else { + } else { GlStateManager.bindTexture(-1); } GlStateManager.setActiveTexture(GL_TEXTURE7); - GlStateManager.bindTexture(lastFrameGBufferDepthTexture); // may be full of garbage data, let's pretend it won't + GlStateManager.bindTexture(lastFrameGBufferDepthTexture); // may be full of garbage data, let's pretend it + // won't GlStateManager.setActiveTexture(GL_TEXTURE6); - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { GlStateManager.bindTexture(lastFrameColorTexture); - }else { + } else { GlStateManager.bindTexture(-1); } GlStateManager.setActiveTexture(GL_TEXTURE5); - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { GlStateManager.bindTexture(reprojectionSSRHitVector[1]); // may be garbage data - }else { + } else { GlStateManager.bindTexture(-1); } GlStateManager.setActiveTexture(GL_TEXTURE4); - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { GlStateManager.bindTexture(reprojectionSSRTexture[1]); // may be garbage data - }else { + } else { GlStateManager.bindTexture(-1); } - + GlStateManager.setActiveTexture(GL_TEXTURE3); GlStateManager.bindTexture(gBufferNormalsTexture); GlStateManager.setActiveTexture(GL_TEXTURE2); - if(config.is_rendering_ssao) { + if (config.is_rendering_ssao) { GlStateManager.bindTexture(reprojectionControlSSAOTexture[1 - reprojectionPhase]); // may be garbage - }else { + } else { GlStateManager.bindTexture(-1); } GlStateManager.setActiveTexture(GL_TEXTURE1); - if(config.is_rendering_ssao) { + if (config.is_rendering_ssao) { GlStateManager.bindTexture(ssaoGenerateTexture); - }else { + } else { GlStateManager.bindTexture(-1); } GlStateManager.setActiveTexture(GL_TEXTURE0); @@ -1747,12 +1861,16 @@ public class EaglerDeferredPipeline { Matrix4f.mul(DeferredStateManager.viewMatrix, tmpMatrix1, tmpMatrixViewReproject); Matrix4f.mul(tmpMatrixViewProj, tmpMatrix1, tmpMatrixViewProjReproject); Matrix4f.invert(tmpMatrixViewProjReproject, tmpMatrixInverseViewProjReproject); - - uniformMatrixHelper(shader_reproject_control.uniforms.u_inverseViewProjMatrix4f, tmpMatrixInverseViewProjReproject); - uniformMatrixHelper(shader_reproject_control.uniforms.u_reprojectionMatrix4f, tmpMatrixLastFrameViewProjReproject); - if(config.is_rendering_raytracing) { - uniformMatrixHelper(shader_reproject_control.uniforms.u_projectionMatrix4f, DeferredStateManager.projMatrix); - uniformMatrixHelper(shader_reproject_control.uniforms.u_inverseProjectionMatrix4f, DeferredStateManager.inverseProjMatrix); + + uniformMatrixHelper(shader_reproject_control.uniforms.u_inverseViewProjMatrix4f, + tmpMatrixInverseViewProjReproject); + uniformMatrixHelper(shader_reproject_control.uniforms.u_reprojectionMatrix4f, + tmpMatrixLastFrameViewProjReproject); + if (config.is_rendering_raytracing) { + uniformMatrixHelper(shader_reproject_control.uniforms.u_projectionMatrix4f, + DeferredStateManager.projMatrix); + uniformMatrixHelper(shader_reproject_control.uniforms.u_inverseProjectionMatrix4f, + DeferredStateManager.inverseProjMatrix); Matrix4f.invert(tmpMatrixLastFrameProj, tmpMatrix1); uniformMatrixHelper(shader_reproject_control.uniforms.u_lastInverseProjMatrix4f, tmpMatrix1); Matrix4f.invert(tmpMatrixLastFrameViewReproject, tmpMatrix1); @@ -1763,14 +1881,15 @@ public class EaglerDeferredPipeline { uniformMatrixHelper(shader_reproject_control.uniforms.u_viewToPreviousProjMatrix4f, tmpMatrix1); } _wglUniform4f(shader_reproject_control.uniforms.u_nearFarPlane4f, DeferredStateManager.gbufferNearPlane, - DeferredStateManager.gbufferFarPlane, DeferredStateManager.gbufferNearPlane * DeferredStateManager.gbufferFarPlane * 2.0f, + DeferredStateManager.gbufferFarPlane, + DeferredStateManager.gbufferNearPlane * DeferredStateManager.gbufferFarPlane * 2.0f, DeferredStateManager.gbufferFarPlane - DeferredStateManager.gbufferNearPlane); DrawUtils.drawStandardQuad2D(); DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RUN REPROJECTION CONTROL SHADER"); - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { // =========== RUN SCREENSPACE REFLECTIONS ALGORITHM ============= // @@ -1790,7 +1909,8 @@ public class EaglerDeferredPipeline { _wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionSSRFramebuffer[1]); shader_reproject_ssr.useProgram(); - uniformMatrixHelper(shader_reproject_ssr.uniforms.u_inverseProjectionMatrix4f, DeferredStateManager.inverseProjMatrix); + uniformMatrixHelper(shader_reproject_ssr.uniforms.u_inverseProjectionMatrix4f, + DeferredStateManager.inverseProjMatrix); Matrix4f.mul(tmpMatrixLastFrameViewProjReproject, tmpMatrixInverseViewProjReproject, tmpMatrix1); Matrix4f.mul(tmpMatrix1, DeferredStateManager.projMatrix, tmpMatrix1); uniformMatrixHelper(shader_reproject_ssr.uniforms.u_lastProjectionMatrix4f, tmpMatrix1); @@ -1805,7 +1925,8 @@ public class EaglerDeferredPipeline { matrixCopyBuffer.put(tmpMatrix1.m32); matrixCopyBuffer.put(tmpMatrix1.m33); matrixCopyBuffer.flip(); - _wglUniformMatrix4x2fv(shader_reproject_ssr.uniforms.u_lastInverseProjMatrix4x2f, false, matrixCopyBuffer); + _wglUniformMatrix4x2fv(shader_reproject_ssr.uniforms.u_lastInverseProjMatrix4x2f, false, + matrixCopyBuffer); _wglUniform1f(shader_reproject_ssr.uniforms.u_sampleStep1f, 0.125f); DrawUtils.drawStandardQuad2D(); // sample 1 @@ -1842,11 +1963,12 @@ public class EaglerDeferredPipeline { DrawUtils.drawStandardQuad2D(); // sample 5 - DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RUN SCREENSPACE REFLECTIONS ALGORITHM"); + DeferredStateManager + .checkGLError("combineGBuffersAndIlluminate(): RUN SCREENSPACE REFLECTIONS ALGORITHM"); } } - if(config.is_rendering_shadowsSun_clamped > 0) { + if (config.is_rendering_shadowsSun_clamped > 0) { // ==================== RENDER SUNLIGHT SHADOWS ===================== // @@ -1854,16 +1976,17 @@ public class EaglerDeferredPipeline { GlStateManager.viewport(0, 0, currentWidth, currentHeight); shader_shadows_sun.useProgram(); - uniformMatrixHelper(shader_shadows_sun.uniforms.u_inverseViewMatrix4f, DeferredStateManager.inverseViewMatrix); + uniformMatrixHelper(shader_shadows_sun.uniforms.u_inverseViewMatrix4f, + DeferredStateManager.inverseViewMatrix); uniformMatrixHelper(shader_shadows_sun.uniforms.u_inverseViewProjMatrix4f, tmpMatrixInverseViewProj); - if(config.is_rendering_shadowsColored) { + if (config.is_rendering_shadowsColored) { GlStateManager.setActiveTexture(GL_TEXTURE3); GlStateManager.bindTexture(sunShadowColorBuffer); } GlStateManager.setActiveTexture(GL_TEXTURE2); GlStateManager.bindTexture(sunShadowDepthBuffer); - if(config.is_rendering_shadowsSmoothed) { + if (config.is_rendering_shadowsSmoothed) { setLinear(); } GlStateManager.setActiveTexture(GL_TEXTURE1); @@ -1872,20 +1995,24 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(gBufferNormalsTexture); Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix0, tmpShadowLOD0MatrixTexSpace); uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD04f, tmpShadowLOD0MatrixTexSpace); - if(config.is_rendering_shadowsSun_clamped > 1) { - Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix1, tmpShadowLOD1MatrixTexSpace); + if (config.is_rendering_shadowsSun_clamped > 1) { + Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix1, + tmpShadowLOD1MatrixTexSpace); uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD14f, tmpShadowLOD1MatrixTexSpace); - if(config.is_rendering_shadowsSun_clamped > 2) { - Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix2, tmpShadowLOD2MatrixTexSpace); - uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD24f, tmpShadowLOD2MatrixTexSpace); + if (config.is_rendering_shadowsSun_clamped > 2) { + Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix2, + tmpShadowLOD2MatrixTexSpace); + uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD24f, + tmpShadowLOD2MatrixTexSpace); } } Vector3f currentSunShadowAngle = DeferredStateManager.currentSunLightAngle; - _wglUniform3f(shader_shadows_sun.uniforms.u_sunDirection3f, -currentSunShadowAngle.x, -currentSunShadowAngle.y, -currentSunShadowAngle.z); + _wglUniform3f(shader_shadows_sun.uniforms.u_sunDirection3f, -currentSunShadowAngle.x, + -currentSunShadowAngle.y, -currentSunShadowAngle.z); DrawUtils.drawStandardQuad2D(); - if(config.is_rendering_shadowsSmoothed) { + if (config.is_rendering_shadowsSmoothed) { GlStateManager.setActiveTexture(GL_TEXTURE2); setNearest(); GlStateManager.setActiveTexture(GL_TEXTURE0); @@ -1899,13 +2026,14 @@ public class EaglerDeferredPipeline { GlStateManager.viewport(0, 0, currentWidth, currentHeight); _wglBindFramebuffer(_GL_READ_FRAMEBUFFER, gBufferFramebuffer); _wglBindFramebuffer(_GL_DRAW_FRAMEBUFFER, lightingHDRFramebuffer); - _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST); + _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, + GL_NEAREST); _wglBindFramebuffer(_GL_FRAMEBUFFER, lightingHDRFramebuffer); - if(dim == -1) { + if (dim == -1) { float f = 0.13f; GlStateManager.clearColor(0.57f * 0.57f * f, 0.38f * 0.38f * f, 0.20f * 0.20f * f, 0.0f); - }else { + } else { GlStateManager.clearColor(0.0f, 0.0f, 0.0f, 0.0f); } GlStateManager.clear(GL_COLOR_BUFFER_BIT); @@ -1921,21 +2049,21 @@ public class EaglerDeferredPipeline { GlStateManager.setActiveTexture(GL_TEXTURE7); GlStateManager.bindTexture(skyIrradianceTexture); GlStateManager.setActiveTexture(GL_TEXTURE6); - if(config.is_rendering_useEnvMap) { + if (config.is_rendering_useEnvMap) { GlStateManager.bindTexture(envMapColorTexture); - }else { + } else { GlStateManager.bindTexture(-1); } GlStateManager.setActiveTexture(GL_TEXTURE5); - if(config.is_rendering_raytracing) { + if (config.is_rendering_raytracing) { GlStateManager.bindTexture(reprojectionSSRTexture[1]); - }else { + } else { GlStateManager.bindTexture(-1); } GlStateManager.setActiveTexture(GL_TEXTURE4); - if(config.is_rendering_ssao) { + if (config.is_rendering_ssao) { GlStateManager.bindTexture(reprojectionControlSSAOTexture[reprojectionPhase]); - }else { + } else { GlStateManager.bindTexture(-1); } GlStateManager.setActiveTexture(GL_TEXTURE3); @@ -1948,12 +2076,16 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(gBufferDiffuseTexture); shader_deferred_combine.useProgram(); - uniformMatrixHelper(shader_deferred_combine.uniforms.u_inverseViewMatrix4f, DeferredStateManager.inverseViewMatrix); - uniformMatrixHelper(shader_deferred_combine.uniforms.u_inverseProjMatrix4f, DeferredStateManager.inverseProjMatrix); - _wglUniform3f(shader_deferred_combine.uniforms.u_sunDirection3f, DeferredStateManager.currentSunAngle.x, DeferredStateManager.currentSunAngle.y, DeferredStateManager.currentSunAngle.z); + uniformMatrixHelper(shader_deferred_combine.uniforms.u_inverseViewMatrix4f, + DeferredStateManager.inverseViewMatrix); + uniformMatrixHelper(shader_deferred_combine.uniforms.u_inverseProjMatrix4f, + DeferredStateManager.inverseProjMatrix); + _wglUniform3f(shader_deferred_combine.uniforms.u_sunDirection3f, DeferredStateManager.currentSunAngle.x, + DeferredStateManager.currentSunAngle.y, DeferredStateManager.currentSunAngle.z); float lightningBoost = mc.theWorld.getLastLightningBolt() > 0 ? 1.0f : 0.0f; lightningBoost *= 0.3f + fff; - _wglUniform1f(shader_deferred_combine.uniforms.u_skyLightFactor1f, getSkyBrightnessTimeParam() + lightningBoost); + _wglUniform1f(shader_deferred_combine.uniforms.u_skyLightFactor1f, + getSkyBrightnessTimeParam() + lightningBoost); DrawUtils.drawStandardQuad2D(); DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER AMBIENT LIGHTING"); @@ -1965,77 +2097,86 @@ public class EaglerDeferredPipeline { // ==================== RENDER SUNLIGHT ===================== // - if(dim == 0) { + if (dim == 0) { shader_lighting_sun.useProgram(); - uniformMatrixHelper(shader_lighting_sun.uniforms.u_inverseViewMatrix4f, DeferredStateManager.inverseViewMatrix); - uniformMatrixHelper(shader_lighting_sun.uniforms.u_inverseProjectionMatrix4f, DeferredStateManager.inverseProjMatrix); + uniformMatrixHelper(shader_lighting_sun.uniforms.u_inverseViewMatrix4f, + DeferredStateManager.inverseViewMatrix); + uniformMatrixHelper(shader_lighting_sun.uniforms.u_inverseProjectionMatrix4f, + DeferredStateManager.inverseProjMatrix); GlStateManager.setActiveTexture(GL_TEXTURE5); GlStateManager.bindTexture(MetalsLUT.getGLTexture()); GlStateManager.setActiveTexture(GL_TEXTURE4); - if(config.is_rendering_shadowsSun_clamped > 0) { + if (config.is_rendering_shadowsSun_clamped > 0) { GlStateManager.bindTexture(sunLightingShadowTexture); - }else { + } else { GlStateManager.bindTexture(-1); } GlStateManager.setActiveTexture(GL_TEXTURE0); - + float ffff = getSkyBrightnessParam(); float[] sunRGB; - if(currentSunAngle.y < 0.05f) { - sunRGB = TemperaturesLUT.getColorTemperature((int)sunKelvin); + if (currentSunAngle.y < 0.05f) { + sunRGB = TemperaturesLUT.getColorTemperature((int) sunKelvin); Vector3f currentSunLightColor3f = DeferredStateManager.currentSunLightColor; // reuse variable currentSunLightColor3f.x = sunRGB[0] * 8.0f * (0.1f + ffff * 0.9f); currentSunLightColor3f.y = sunRGB[1] * 8.0f * (0.1f + ffff * 0.9f); currentSunLightColor3f.z = sunRGB[2] * 8.0f * (0.1f + ffff * 0.9f); - _wglUniform3f(shader_lighting_sun.uniforms.u_sunColor3f, sunRGB[0] * 4.0f * ffff, sunRGB[1] * 4.0f * ffff, sunRGB[2] * 4.0f * ffff); - }else { - sunRGB = TemperaturesLUT.getColorTemperature((int)(9000.0f + 2500.0f * currentSunAngle.y)); + _wglUniform3f(shader_lighting_sun.uniforms.u_sunColor3f, sunRGB[0] * 4.0f * ffff, + sunRGB[1] * 4.0f * ffff, sunRGB[2] * 4.0f * ffff); + } else { + sunRGB = TemperaturesLUT.getColorTemperature((int) (9000.0f + 2500.0f * currentSunAngle.y)); Vector3f currentSunLightColor3f = DeferredStateManager.currentSunLightColor; // reuse variable currentSunLightColor3f.x = sunRGB[0] * 0.3f * (0.2f + ffff * 0.8f); currentSunLightColor3f.y = sunRGB[1] * 0.3f * (0.2f + ffff * 0.8f); currentSunLightColor3f.z = sunRGB[2] * 0.3f * (0.2f + ffff * 0.8f); - _wglUniform3f(shader_lighting_sun.uniforms.u_sunColor3f, sunRGB[0] * 0.1f * (0.5f + ffff * 0.5f), sunRGB[1] * 0.1f * (0.5f + ffff * 0.5f), sunRGB[2] * 0.1f * (0.5f + ffff * 0.5f)); + _wglUniform3f(shader_lighting_sun.uniforms.u_sunColor3f, sunRGB[0] * 0.1f * (0.5f + ffff * 0.5f), + sunRGB[1] * 0.1f * (0.5f + ffff * 0.5f), sunRGB[2] * 0.1f * (0.5f + ffff * 0.5f)); } - - _wglUniform3f(shader_lighting_sun.uniforms.u_sunDirection3f, -DeferredStateManager.currentSunLightAngle.x, -DeferredStateManager.currentSunLightAngle.y, -DeferredStateManager.currentSunLightAngle.z); - + + _wglUniform3f(shader_lighting_sun.uniforms.u_sunDirection3f, -DeferredStateManager.currentSunLightAngle.x, + -DeferredStateManager.currentSunLightAngle.y, -DeferredStateManager.currentSunLightAngle.z); + DrawUtils.drawStandardQuad2D(); - + DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SUNLIGHT"); - }else { + } else { DeferredStateManager.currentSunLightColor.set(0.0f, 0.0f, 0.0f); } // ================== RENDER DYNAMIC LIGHTS =================== // - if(config.is_rendering_dynamicLights) { + if (config.is_rendering_dynamicLights) { shader_lighting_point.useProgram(); - uniformMatrixHelper(shader_lighting_point.uniforms.u_inverseProjectionMatrix4f, DeferredStateManager.inverseProjMatrix); - uniformMatrixHelper(shader_lighting_point.uniforms.u_inverseViewMatrix4f, DeferredStateManager.inverseViewMatrix); + uniformMatrixHelper(shader_lighting_point.uniforms.u_inverseProjectionMatrix4f, + DeferredStateManager.inverseProjMatrix); + uniformMatrixHelper(shader_lighting_point.uniforms.u_inverseViewMatrix4f, + DeferredStateManager.inverseViewMatrix); _wglUniform2f(shader_lighting_point.uniforms.u_viewportSize2f, 1.0f / currentWidth, 1.0f / currentHeight); Iterator itr = DynamicLightManager.lightRenderList.iterator(); AxisAlignedBB aabb = renderViewEntity.getEntityBoundingBox(); double eyeHeight = renderViewEntity.getEyeHeight(); - while(itr.hasNext()) { + while (itr.hasNext()) { DynamicLightInstance dl = itr.next(); - float lightPosX = (float)(dl.posX - entityPosX); - float lightPosY = (float)(dl.posY - entityPosY); - float lightPosZ = (float)(dl.posZ - entityPosZ); - float lightChunkPosX = (float)(dl.posX - entityChunkOriginX); - float lightChunkPosY = (float)(dl.posY - entityChunkOriginY); - float lightChunkPosZ = (float)(dl.posZ - entityChunkOriginZ); + float lightPosX = (float) (dl.posX - entityPosX); + float lightPosY = (float) (dl.posY - entityPosY); + float lightPosZ = (float) (dl.posZ - entityPosZ); + float lightChunkPosX = (float) (dl.posX - entityChunkOriginX); + float lightChunkPosY = (float) (dl.posY - entityChunkOriginY); + float lightChunkPosZ = (float) (dl.posZ - entityChunkOriginZ); bucketLightSource(lightChunkPosX, lightChunkPosY, lightChunkPosZ, dl); - if(dl.posX > aabb.minX - 0.25 && dl.posY > aabb.minY + eyeHeight - 0.25 && dl.posZ > aabb.minZ - 0.25 && - dl.posX < aabb.maxX + 0.25 && dl.posY < aabb.minY + eyeHeight + 0.25 && dl.posZ < aabb.maxZ + 0.25) { + if (dl.posX > aabb.minX - 0.25 && dl.posY > aabb.minY + eyeHeight - 0.25 && dl.posZ > aabb.minZ - 0.25 + && + dl.posX < aabb.maxX + 0.25 && dl.posY < aabb.minY + eyeHeight + 0.25 + && dl.posZ < aabb.maxZ + 0.25) { tmpMatrix1.setIdentity(); uniformMatrixHelper(shader_lighting_point.uniforms.u_modelViewProjMatrix4f, tmpMatrix1); _wglUniform3f(shader_lighting_point.uniforms.u_lightColor3f, dl.red, dl.green, dl.blue); _wglUniform3f(shader_lighting_point.uniforms.u_lightPosition3f, lightPosX, lightPosY, lightPosZ); DrawUtils.drawStandardQuad3D(); - }else { + } else { float radius = dl.radius; tmpVector1.set(lightPosX, lightPosY, lightPosZ); - if(DeferredStateManager.currentGBufferFrustum.testSphere(tmpVector1, radius)) { + if (DeferredStateManager.currentGBufferFrustum.testSphere(tmpVector1, radius)) { tmpMatrix1.setIdentity(); Matrix4f.translate(tmpVector1, tmpMatrix1, tmpMatrix1); tmpVector1.set(radius, radius, radius); @@ -2043,7 +2184,8 @@ public class EaglerDeferredPipeline { Matrix4f.mul(tmpMatrixViewProj, tmpMatrix1, tmpMatrix1); uniformMatrixHelper(shader_lighting_point.uniforms.u_modelViewProjMatrix4f, tmpMatrix1); _wglUniform3f(shader_lighting_point.uniforms.u_lightColor3f, dl.red, dl.green, dl.blue); - _wglUniform3f(shader_lighting_point.uniforms.u_lightPosition3f, lightPosX, lightPosY, lightPosZ); + _wglUniform3f(shader_lighting_point.uniforms.u_lightPosition3f, lightPosX, lightPosY, + lightPosZ); pointLightMesh.drawMeshVAO(); } } @@ -2058,13 +2200,14 @@ public class EaglerDeferredPipeline { GlStateManager.disableBlend(); - if(reprojectionEngineEnable || config.realisticWater) { + if (reprojectionEngineEnable || config.realisticWater) { // =========== SAVE REPROJECTION DATA FOR NEXT FRAME ============= // _wglBindFramebuffer(_GL_READ_FRAMEBUFFER, lightingHDRFramebuffer); _wglBindFramebuffer(_GL_DRAW_FRAMEBUFFER, lastFrameGBufferFramebuffer); - _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST); + _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, + GL_DEPTH_BUFFER_BIT, GL_NEAREST); DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): SAVE REPROJECTION DATA FOR NEXT FRAME"); } @@ -2073,7 +2216,7 @@ public class EaglerDeferredPipeline { // =================== RENDER SKYBOX MESH =================== // - if(dim == 0) { + if (dim == 0) { GlStateManager.enableDepth(); GlStateManager.setActiveTexture(GL_TEXTURE2); GlStateManager.bindTexture(CloudRenderWorker.cloudOcclusionTexture); @@ -2084,26 +2227,29 @@ public class EaglerDeferredPipeline { shader_skybox_render.useProgram(); uniformMatrixHelper(shader_skybox_render.uniforms.u_viewMatrix4f, DeferredStateManager.viewMatrix); uniformMatrixHelper(shader_skybox_render.uniforms.u_projMatrix4f, DeferredStateManager.projMatrix); - _wglUniform3f(shader_skybox_render.uniforms.u_sunDirection3f, -currentSunAngle.x, -currentSunAngle.y, -currentSunAngle.z); + _wglUniform3f(shader_skybox_render.uniforms.u_sunDirection3f, -currentSunAngle.x, -currentSunAngle.y, + -currentSunAngle.z); float mag = 25.0f; - float[] sunRGB2 = TemperaturesLUT.getColorTemperature((int)sunKelvin - 1000); - _wglUniform3f(shader_skybox_render.uniforms.u_sunColor3f, sunRGB2[0] * mag, sunRGB2[1] * mag, sunRGB2[2] * mag); + float[] sunRGB2 = TemperaturesLUT.getColorTemperature((int) sunKelvin - 1000); + _wglUniform3f(shader_skybox_render.uniforms.u_sunColor3f, sunRGB2[0] * mag, sunRGB2[1] * mag, + sunRGB2[2] * mag); if (mc.theWorld.getLastLightningBolt() > 0) { float f = 0.3f + fff; - _wglUniform4f(shader_skybox_render.uniforms.u_lightningColor4f, 0.02f * f, 0.02f * f, 0.02f * f, 1.0f - f * 0.25f); - }else { + _wglUniform4f(shader_skybox_render.uniforms.u_lightningColor4f, 0.02f * f, 0.02f * f, 0.02f * f, + 1.0f - f * 0.25f); + } else { _wglUniform4f(shader_skybox_render.uniforms.u_lightningColor4f, 0.0f, 0.0f, 0.0f, 1.0f); } skybox.drawFull(); - + DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SKYBOX MESH"); - }else if(dim == 1) { + } else if (dim == 1) { GlStateManager.enableDepth(); GlStateManager.setActiveTexture(GL_TEXTURE0); mc.getTextureManager().bindTexture(locationEndSkyPng); - if(shader_skybox_render_end == null) { + if (shader_skybox_render_end == null) { shader_skybox_render_end = PipelineShaderSkyboxRenderEnd.compile(); shader_skybox_render_end.loadUniforms(); } @@ -2118,7 +2264,7 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SKYBOX MESH"); } - if(dim == 0 && fff < 1.0f) { + if (dim == 0 && fff < 1.0f) { // ===================== RENDER MOON ====================== // @@ -2145,22 +2291,22 @@ public class EaglerDeferredPipeline { moonMatrix.m21 = tmpVector4.y; moonMatrix.m22 = tmpVector4.z; Matrix4f.mul(moonMatrix, tmpMatrix2, moonMatrix); - + GlStateManager.bindTexture(moonTextures); shader_moon_render.useProgram(); - + uniformMatrixHelper(shader_moon_render.uniforms.u_modelMatrix4f, moonMatrix); uniformMatrixHelper(shader_moon_render.uniforms.u_viewMatrix4f, DeferredStateManager.viewMatrix); uniformMatrixHelper(shader_moon_render.uniforms.u_projMatrix4f, DeferredStateManager.projMatrix); float fffff = 0.1f + MathHelper.clamp_float((-currentSunAngle.y + 0.1f) * 8.0f, 0.0f, 0.5f); _wglUniform3f(shader_moon_render.uniforms.u_moonColor3f, 1.4f * fffff, 1.2f * fffff, 1.0f * fffff); - - float f = (float)(Minecraft.getMinecraft().theWorld.getWorldTime() - 18000f) / 24000f / 4f * 3.14159f; + + float f = (float) (Minecraft.getMinecraft().theWorld.getWorldTime() - 18000f) / 24000f / 4f * 3.14159f; _wglUniform3f(shader_moon_render.uniforms.u_lightDir3f, MathHelper.sin(f), 0.0f, MathHelper.cos(f)); - + GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ZERO); - + DrawUtils.drawStandardQuad2D(); DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER MOON"); @@ -2177,11 +2323,11 @@ public class EaglerDeferredPipeline { int bucketX = (relativeBlockX >> 4) + hw; int bucketY = (relativeBlockY >> 4) + hh; int bucketZ = (relativeBlockZ >> 4) + hw; - if(bucketX >= 0 && bucketY >= 0 && bucketZ >= 0 && bucketX < lightSourceBucketsWidth + if (bucketX >= 0 && bucketY >= 0 && bucketZ >= 0 && bucketX < lightSourceBucketsWidth && bucketY < lightSourceBucketsHeight && bucketZ < lightSourceBucketsWidth) { currentLightSourceBucket = lightSourceBuckets[bucketY * lightSourceBucketsWidth * lightSourceBucketsWidth + bucketZ * lightSourceBucketsWidth + bucketX]; - }else { + } else { currentLightSourceBucket = null; } updateLightSourceUBO(); @@ -2193,10 +2339,10 @@ public class EaglerDeferredPipeline { cx += hw; cy += hh; cz += hw; - if(cx < 0 || cx >= lightSourceBucketsWidth || cy < 0 || cy >= lightSourceBucketsHeight || cz < 0 + if (cx < 0 || cx >= lightSourceBucketsWidth || cy < 0 || cy >= lightSourceBucketsHeight || cz < 0 || cz >= lightSourceBucketsWidth) { return null; - }else { + } else { return lightSourceBuckets[cy * lightSourceBucketsWidth * lightSourceBucketsWidth + cz * lightSourceBucketsWidth + cx]; } @@ -2204,7 +2350,7 @@ public class EaglerDeferredPipeline { public void addLightSourceToBucket(int cx, int cy, int cz, DynamicLightInstance dl) { ListSerial lst = getLightSourceBucketRelativeChunkCoords(cx, cy, cz); - if(lst != null) { + if (lst != null) { lst.add(dl); } } @@ -2222,52 +2368,53 @@ public class EaglerDeferredPipeline { float lightLocalZ = z - (bucketZ << 4); float radius = dl.radius; boolean outOfBounds = false; - if(lightLocalX - radius < 0.0f) { + if (lightLocalX - radius < 0.0f) { minX -= 1; outOfBounds = true; addLightSourceToBucket(bucketX - 1, bucketY, bucketZ, dl); } - if(lightLocalY - radius < 0.0f) { + if (lightLocalY - radius < 0.0f) { minY -= 1; outOfBounds = true; addLightSourceToBucket(bucketX, bucketY - 1, bucketZ, dl); } - if(lightLocalZ - radius < 0.0f) { + if (lightLocalZ - radius < 0.0f) { minZ -= 1; outOfBounds = true; addLightSourceToBucket(bucketX, bucketY, bucketZ - 1, dl); } - if(lightLocalX + radius >= 16.0f) { + if (lightLocalX + radius >= 16.0f) { maxX += 1; outOfBounds = true; addLightSourceToBucket(bucketX + 1, bucketY, bucketZ, dl); } - if(lightLocalY + radius >= 16.0f) { + if (lightLocalY + radius >= 16.0f) { maxY += 1; outOfBounds = true; addLightSourceToBucket(bucketX, bucketY + 1, bucketZ, dl); } - if(lightLocalZ + radius >= 16.0f) { + if (lightLocalZ + radius >= 16.0f) { maxZ += 1; outOfBounds = true; addLightSourceToBucket(bucketX, bucketY, bucketZ + 1, dl); } - if(!outOfBounds) { + if (!outOfBounds) { return; } radius *= radius; - for(int yy = minY; yy <= maxY; ++yy) { - for(int zz = minZ; zz <= maxZ; ++zz) { - for(int xx = minX; xx <= maxX; ++xx) { - if((xx == bucketX ? 1 : 0) + (yy == bucketY ? 1 : 0) + (zz == bucketZ ? 1 : 0) > 1) { + for (int yy = minY; yy <= maxY; ++yy) { + for (int zz = minZ; zz <= maxZ; ++zz) { + for (int xx = minX; xx <= maxX; ++xx) { + if ((xx == bucketX ? 1 : 0) + (yy == bucketY ? 1 : 0) + (zz == bucketZ ? 1 : 0) > 1) { continue; } List lst = getLightSourceBucketRelativeChunkCoords(xx, yy, zz); - if(lst != null) { + if (lst != null) { int bucketBoundsX = xx << 4; int bucketBoundsY = yy << 4; int bucketBoundsZ = zz << 4; - if(testAabSphere(bucketBoundsX, bucketBoundsY, bucketBoundsZ, bucketBoundsX + 16, bucketBoundsY + 16, bucketBoundsZ + 16, x, y, z, radius)) { + if (testAabSphere(bucketBoundsX, bucketBoundsY, bucketBoundsZ, bucketBoundsX + 16, + bucketBoundsY + 16, bucketBoundsZ + 16, x, y, z, radius)) { lst.add(dl); } } @@ -2277,7 +2424,8 @@ public class EaglerDeferredPipeline { } /** - * source: https://github.com/JOML-CI/JOML/blob/main/src/main/java/org/joml/Intersectionf.java + * source: + * https://github.com/JOML-CI/JOML/blob/main/src/main/java/org/joml/Intersectionf.java */ public static boolean testAabSphere(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, float centerX, float centerY, float centerZ, float radius2) { @@ -2306,9 +2454,9 @@ public class EaglerDeferredPipeline { } public void updateLightSourceUBO() { - if(currentLightSourceBucket == null) { + if (currentLightSourceBucket == null) { currentBoundLightSourceBucket = null; - if(isChunkLightingEnabled) { + if (isChunkLightingEnabled) { isChunkLightingEnabled = false; EaglercraftGPU.bindGLUniformBuffer(buffer_chunkLightingData); chunkLightingDataCopyBuffer.clear(); @@ -2316,16 +2464,16 @@ public class EaglerDeferredPipeline { chunkLightingDataCopyBuffer.flip(); _wglBufferSubData(_GL_UNIFORM_BUFFER, 0, chunkLightingDataCopyBuffer); } - }else { + } else { boolean isNew; - if(!isChunkLightingEnabled) { + if (!isChunkLightingEnabled) { isChunkLightingEnabled = true; isNew = true; - }else { + } else { isNew = currentLightSourceBucket != currentBoundLightSourceBucket; } currentBoundLightSourceBucket = currentLightSourceBucket; - if(isNew || currentBoundLightSourceBucket.eaglerCheck()) { + if (isNew || currentBoundLightSourceBucket.eaglerCheck()) { populateLightSourceUBOFromBucket(currentBoundLightSourceBucket); currentBoundLightSourceBucket.eaglerResetCheck(); } @@ -2339,7 +2487,7 @@ public class EaglerDeferredPipeline { private void populateLightSourceUBOFromBucket(List lights) { int max = lights.size(); - if(max > MAX_LIGHTS_PER_CHUNK) { + if (max > MAX_LIGHTS_PER_CHUNK) { tmpListLights.clear(); tmpListLights.addAll(lights); lights = tmpListLights; @@ -2348,20 +2496,20 @@ public class EaglerDeferredPipeline { } chunkLightingDataCopyBuffer.clear(); chunkLightingDataCopyBuffer.putInt(max); - if(max > 0) { - chunkLightingDataCopyBuffer.putInt(0); //padding - chunkLightingDataCopyBuffer.putInt(0); //padding - chunkLightingDataCopyBuffer.putInt(0); //padding - for(int i = 0; i < max; ++i) { + if (max > 0) { + chunkLightingDataCopyBuffer.putInt(0); // padding + chunkLightingDataCopyBuffer.putInt(0); // padding + chunkLightingDataCopyBuffer.putInt(0); // padding + for (int i = 0; i < max; ++i) { DynamicLightInstance dl = lights.get(i); - chunkLightingDataCopyBuffer.putFloat((float)(dl.posX - currentRenderX)); - chunkLightingDataCopyBuffer.putFloat((float)(dl.posY - currentRenderY)); - chunkLightingDataCopyBuffer.putFloat((float)(dl.posZ - currentRenderZ)); - chunkLightingDataCopyBuffer.putInt(0); //padding + chunkLightingDataCopyBuffer.putFloat((float) (dl.posX - currentRenderX)); + chunkLightingDataCopyBuffer.putFloat((float) (dl.posY - currentRenderY)); + chunkLightingDataCopyBuffer.putFloat((float) (dl.posZ - currentRenderZ)); + chunkLightingDataCopyBuffer.putInt(0); // padding chunkLightingDataCopyBuffer.putFloat(dl.red); chunkLightingDataCopyBuffer.putFloat(dl.green); chunkLightingDataCopyBuffer.putFloat(dl.blue); - chunkLightingDataCopyBuffer.putInt(0); //padding + chunkLightingDataCopyBuffer.putInt(0); // padding } } chunkLightingDataCopyBuffer.flip(); @@ -2380,9 +2528,10 @@ public class EaglerDeferredPipeline { updateForwardRenderWorldLightingData(); EaglercraftGPU.bindGLUniformBuffer(buffer_worldLightingData); EaglercraftGPU.bindUniformBufferRange(0, buffer_worldLightingData, 0, worldLightingDataCopyBuffer.remaining()); - if(config.is_rendering_dynamicLights) { + if (config.is_rendering_dynamicLights) { EaglercraftGPU.bindGLUniformBuffer(buffer_chunkLightingData); - EaglercraftGPU.bindUniformBufferRange(1, buffer_chunkLightingData, 0, chunkLightingDataCopyBuffer.capacity()); + EaglercraftGPU.bindUniformBufferRange(1, buffer_chunkLightingData, 0, + chunkLightingDataCopyBuffer.capacity()); } GlStateManager.matrixMode(GL_PROJECTION); GlStateManager.pushMatrix(); @@ -2434,9 +2583,9 @@ public class EaglerDeferredPipeline { private void bindEnvMapBlockTexture() { DeferredStateManager.checkGLError("Pre: bindEnvMapBlockTexture()"); GlStateManager.setActiveTexture(GL_TEXTURE4); - if(config.is_rendering_shadowsSun_clamped > 0) { + if (config.is_rendering_shadowsSun_clamped > 0) { GlStateManager.bindTexture(sunShadowDepthBuffer); - }else { + } else { GlStateManager.bindTexture(-1); } TextureManager mgr = mc.getTextureManager(); @@ -2487,11 +2636,11 @@ public class EaglerDeferredPipeline { worldLightingDataCopyBuffer.putFloat(-DeferredStateManager.currentSunLightAngle.z); worldLightingDataCopyBuffer.putFloat(-DeferredStateManager.currentSunAngle.y); float f = getSkyBrightnessParam(); - if(DeferredStateManager.currentSunAngle.y > 0.05f) { // moon: + if (DeferredStateManager.currentSunAngle.y > 0.05f) { // moon: worldLightingDataCopyBuffer.putFloat(DeferredStateManager.currentSunLightColor.x * 0.025f * f); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.currentSunLightColor.y * 0.025f * f); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.currentSunLightColor.z * 0.025f * f); - }else { + } else { worldLightingDataCopyBuffer.putFloat(DeferredStateManager.currentSunLightColor.x * f); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.currentSunLightColor.y * f); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.currentSunLightColor.z * f); @@ -2499,7 +2648,7 @@ public class EaglerDeferredPipeline { float lightningBoost = mc.theWorld.getLastLightningBolt() > 0 ? 1.0f : 0.0f; lightningBoost *= 0.3f + mc.theWorld.getRainStrength(partialTicks); worldLightingDataCopyBuffer.putFloat(getSkyBrightnessTimeParam() + lightningBoost); - worldLightingDataCopyBuffer.putFloat((float)DeferredStateManager.fogLinearExp); + worldLightingDataCopyBuffer.putFloat((float) DeferredStateManager.fogLinearExp); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.fogDensity); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.fogNear); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.fogFar); @@ -2511,7 +2660,8 @@ public class EaglerDeferredPipeline { worldLightingDataCopyBuffer.putFloat(DeferredStateManager.fogColorLightG); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.fogColorLightB); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.fogColorLightA); - float mul = 0.05f * MathHelper.clamp_float(-1.0f - DeferredStateManager.getSunHeight() * 20.0f, 0.0f, 1.0f) + 0.01f; + float mul = 0.05f * MathHelper.clamp_float(-1.0f - DeferredStateManager.getSunHeight() * 20.0f, 0.0f, 1.0f) + + 0.01f; worldLightingDataCopyBuffer.putFloat(DeferredStateManager.currentSunLightColor.x * mul); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.currentSunLightColor.y * mul); worldLightingDataCopyBuffer.putFloat(DeferredStateManager.currentSunLightColor.z * mul); @@ -2520,11 +2670,11 @@ public class EaglerDeferredPipeline { worldLightingDataCopyBuffer.putFloat(1.0f); worldLightingDataCopyBuffer.putFloat(1.0f); worldLightingDataCopyBuffer.putFloat(1.0f); - if(config.is_rendering_shadowsSun_clamped > 0) { + if (config.is_rendering_shadowsSun_clamped > 0) { tmpShadowLOD0MatrixTexSpace.store(worldLightingDataCopyBuffer); - if(config.is_rendering_shadowsSun_clamped > 1) { + if (config.is_rendering_shadowsSun_clamped > 1) { tmpShadowLOD1MatrixTexSpace.store(worldLightingDataCopyBuffer); - if(config.is_rendering_shadowsSun_clamped > 2) { + if (config.is_rendering_shadowsSun_clamped > 2) { tmpShadowLOD2MatrixTexSpace.store(worldLightingDataCopyBuffer); } } @@ -2552,14 +2702,16 @@ public class EaglerDeferredPipeline { } private float getSkyBrightnessTimeParam() { - return (2.0f + MathHelper.clamp_float(-DeferredStateManager.currentSunAngle.y * 8.0f, 0.0f, 1.5f)) * getSkyBrightnessParam(); + return (2.0f + MathHelper.clamp_float(-DeferredStateManager.currentSunAngle.y * 8.0f, 0.0f, 1.5f)) + * getSkyBrightnessParam(); } public void beginDrawRealisticWaterMask() { DeferredStateManager.checkGLError("Pre: beginDrawRealisticWaterMask()"); _wglBindFramebuffer(_GL_READ_FRAMEBUFFER, gBufferFramebuffer); _wglBindFramebuffer(_GL_DRAW_FRAMEBUFFER, realisticWaterMaskFramebuffer); - _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST); + _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, + GL_NEAREST); _wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterMaskFramebuffer); GlStateManager.viewport(0, 0, currentWidth, currentHeight); GlStateManager.clearColor(0.0f, 0.0f, 0.0f, 0.0f); @@ -2579,7 +2731,7 @@ public class EaglerDeferredPipeline { DeferredStateManager.disableDrawRealisticWaterMask(); GlStateManager.disableExtensionPipeline(); - if(config.is_rendering_lightShafts) { + if (config.is_rendering_lightShafts) { // ================== RENDER LIGHT SHAFTS =================== // @@ -2592,18 +2744,26 @@ public class EaglerDeferredPipeline { GlStateManager.setActiveTexture(GL_TEXTURE0); GlStateManager.bindTexture(realisticWaterDepthBuffer); shader_light_shafts_sample.useProgram(); - _wglUniform2f(shader_light_shafts_sample.uniforms.u_ditherScale2f, reprojectionTexWidth * 0.125f, reprojectionTexHeight * 0.125f); - uniformMatrixHelper(shader_light_shafts_sample.uniforms.u_inverseViewProjMatrix4f, tmpMatrixInverseViewProj); - _wglUniform3f(shader_light_shafts_sample.uniforms.u_eyePosition3f, DeferredStateManager.inverseViewMatrix.m30, + _wglUniform2f(shader_light_shafts_sample.uniforms.u_ditherScale2f, reprojectionTexWidth * 0.125f, + reprojectionTexHeight * 0.125f); + uniformMatrixHelper(shader_light_shafts_sample.uniforms.u_inverseViewProjMatrix4f, + tmpMatrixInverseViewProj); + _wglUniform3f(shader_light_shafts_sample.uniforms.u_eyePosition3f, + DeferredStateManager.inverseViewMatrix.m30, DeferredStateManager.inverseViewMatrix.m31, DeferredStateManager.inverseViewMatrix.m32); Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix0, tmpShadowLOD0MatrixTexSpace); - uniformMatrixHelper(shader_light_shafts_sample.uniforms.u_sunShadowMatrixLOD04f, tmpShadowLOD0MatrixTexSpace); - if(config.is_rendering_shadowsSun_clamped > 1) { - Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix1, tmpShadowLOD1MatrixTexSpace); - uniformMatrixHelper(shader_light_shafts_sample.uniforms.u_sunShadowMatrixLOD14f, tmpShadowLOD1MatrixTexSpace); - if(config.is_rendering_shadowsSun_clamped > 2) { - Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix2, tmpShadowLOD2MatrixTexSpace); - uniformMatrixHelper(shader_light_shafts_sample.uniforms.u_sunShadowMatrixLOD24f, tmpShadowLOD2MatrixTexSpace); + uniformMatrixHelper(shader_light_shafts_sample.uniforms.u_sunShadowMatrixLOD04f, + tmpShadowLOD0MatrixTexSpace); + if (config.is_rendering_shadowsSun_clamped > 1) { + Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix1, + tmpShadowLOD1MatrixTexSpace); + uniformMatrixHelper(shader_light_shafts_sample.uniforms.u_sunShadowMatrixLOD14f, + tmpShadowLOD1MatrixTexSpace); + if (config.is_rendering_shadowsSun_clamped > 2) { + Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix2, + tmpShadowLOD2MatrixTexSpace); + uniformMatrixHelper(shader_light_shafts_sample.uniforms.u_sunShadowMatrixLOD24f, + tmpShadowLOD2MatrixTexSpace); } } @@ -2667,7 +2827,7 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(lightingHDRFramebufferColorTexture); shader_realistic_water_control.useProgram(); - if(!reprojectionEngineEnable) { + if (!reprojectionEngineEnable) { tmpVector1.set(-reprojectionViewerOffsetX, -reprojectionViewerOffsetY, -reprojectionViewerOffsetZ); tmpMatrix1.setIdentity(); Matrix4f.translate(tmpVector1, tmpMatrix1, tmpMatrix1); @@ -2676,11 +2836,15 @@ public class EaglerDeferredPipeline { Matrix4f.invert(tmpMatrixViewProjReproject, tmpMatrixInverseViewProjReproject); } - uniformMatrixHelper(shader_realistic_water_control.uniforms.u_inverseViewProjMatrix4f, tmpMatrixInverseViewProjReproject); - uniformMatrixHelper(shader_realistic_water_control.uniforms.u_reprojectionMatrix4f, tmpMatrixLastFrameViewProjReproject); + uniformMatrixHelper(shader_realistic_water_control.uniforms.u_inverseViewProjMatrix4f, + tmpMatrixInverseViewProjReproject); + uniformMatrixHelper(shader_realistic_water_control.uniforms.u_reprojectionMatrix4f, + tmpMatrixLastFrameViewProjReproject); - uniformMatrixHelper(shader_realistic_water_control.uniforms.u_projectionMatrix4f, DeferredStateManager.projMatrix); - uniformMatrixHelper(shader_realistic_water_control.uniforms.u_inverseProjectionMatrix4f, DeferredStateManager.inverseProjMatrix); + uniformMatrixHelper(shader_realistic_water_control.uniforms.u_projectionMatrix4f, + DeferredStateManager.projMatrix); + uniformMatrixHelper(shader_realistic_water_control.uniforms.u_inverseProjectionMatrix4f, + DeferredStateManager.inverseProjMatrix); Matrix4f.invert(tmpMatrixLastFrameProj, tmpMatrix1); uniformMatrixHelper(shader_realistic_water_control.uniforms.u_lastInverseProjMatrix4f, tmpMatrix1); Matrix4f.invert(tmpMatrixLastFrameViewReproject, tmpMatrix1); @@ -2701,7 +2865,8 @@ public class EaglerDeferredPipeline { float fac = MathHelper.clamp_float(DeferredStateManager.currentSunAngle.y * -4.0f, 0.1f, 1.0f); _wglUniform4f(shader_realistic_water_control.uniforms.u_refractFogColor4f, fr * ff, fg * ff, fb * ff, fac); - uniformMatrixHelper(shader_realistic_water_control.uniforms.u_inverseProjectionMatrix4f, DeferredStateManager.inverseProjMatrix); + uniformMatrixHelper(shader_realistic_water_control.uniforms.u_inverseProjectionMatrix4f, + DeferredStateManager.inverseProjMatrix); DrawUtils.drawStandardQuad2D(); @@ -2725,7 +2890,8 @@ public class EaglerDeferredPipeline { _wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[1]); shader_reproject_ssr.useProgram(); - uniformMatrixHelper(shader_reproject_ssr.uniforms.u_inverseProjectionMatrix4f, DeferredStateManager.inverseProjMatrix); + uniformMatrixHelper(shader_reproject_ssr.uniforms.u_inverseProjectionMatrix4f, + DeferredStateManager.inverseProjMatrix); Matrix4f.mul(tmpMatrixLastFrameViewProjReproject, tmpMatrixInverseViewProjReproject, tmpMatrix1); Matrix4f.mul(tmpMatrix1, DeferredStateManager.projMatrix, tmpMatrix1); uniformMatrixHelper(shader_reproject_ssr.uniforms.u_lastProjectionMatrix4f, tmpMatrix1); @@ -2788,7 +2954,7 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(realisticWaterNoiseMap); shader_realistic_water_noise.useProgram(); - float waveTimer = (float)((System.currentTimeMillis() % 600000l) * 0.001); + float waveTimer = (float) ((System.currentTimeMillis() % 600000l) * 0.001); _wglUniform4f(shader_realistic_water_noise.uniforms.u_waveTimer4f, waveTimer, 0.0f, 0.0f, 0.0f); DrawUtils.drawStandardQuad2D(); @@ -2806,15 +2972,16 @@ public class EaglerDeferredPipeline { public void applyGBufferFog() { DeferredStateManager.checkGLError("Pre: applyGBufferFog()"); - if(DeferredStateManager.fogLinearExp == 0) { + if (DeferredStateManager.fogLinearExp == 0) { _wglBindFramebuffer(_GL_FRAMEBUFFER, lightingHDRFramebuffer); return; } _wglBindFramebuffer(_GL_READ_FRAMEBUFFER, lightingHDRFramebuffer); _wglBindFramebuffer(_GL_DRAW_FRAMEBUFFER, fogDepthCopyBuffer); - _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST); + _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, + GL_NEAREST); _wglBindFramebuffer(_GL_FRAMEBUFFER, lightingHDRFramebuffer); - if(config.is_rendering_lightShafts) { + if (config.is_rendering_lightShafts) { GlStateManager.setActiveTexture(GL_TEXTURE4); GlStateManager.bindTexture(lightShaftsTexture); } @@ -2830,26 +2997,31 @@ public class EaglerDeferredPipeline { tmpMatrix1.m30 = tmpMatrix1.m31 = tmpMatrix1.m32 = 0.0f; Matrix4f.mul(tmpMatrix1, DeferredStateManager.inverseProjMatrix, tmpMatrix1); PipelineShaderGBufferFog fogShader; - switch(DeferredStateManager.fogLinearExp) { - case 1: - fogShader = shader_colored_fog_linear; - fogShader.useProgram(); - _wglUniform2f(fogShader.uniforms.u_linearFogParam2f, DeferredStateManager.fogNear, DeferredStateManager.fogFar); - break; - case 2: - fogShader = shader_colored_fog_exp; - fogShader.useProgram(); - _wglUniform1f(fogShader.uniforms.u_expFogDensity1f, DeferredStateManager.fogDensity); - break; - case 6: - fogShader = shader_atmosphere_fog; - fogShader.useProgram(); - _wglUniform1f(fogShader.uniforms.u_expFogDensity1f, DeferredStateManager.fogDensity); - float mul = 0.05f * MathHelper.clamp_float(-1.0f - DeferredStateManager.getSunHeight() * 20.0f, 0.0f, 1.0f) + 0.01f; - _wglUniform3f(fogShader.uniforms.u_sunColorAdd3f, DeferredStateManager.currentSunLightColor.x * mul, DeferredStateManager.currentSunLightColor.y * mul, DeferredStateManager.currentSunLightColor.z * mul); - break; - default: - throw new RuntimeException("Invalid fog type: " + DeferredStateManager.fogLinearExp); + switch (DeferredStateManager.fogLinearExp) { + case 1: + fogShader = shader_colored_fog_linear; + fogShader.useProgram(); + _wglUniform2f(fogShader.uniforms.u_linearFogParam2f, DeferredStateManager.fogNear, + DeferredStateManager.fogFar); + break; + case 2: + fogShader = shader_colored_fog_exp; + fogShader.useProgram(); + _wglUniform1f(fogShader.uniforms.u_expFogDensity1f, DeferredStateManager.fogDensity); + break; + case 6: + fogShader = shader_atmosphere_fog; + fogShader.useProgram(); + _wglUniform1f(fogShader.uniforms.u_expFogDensity1f, DeferredStateManager.fogDensity); + float mul = 0.05f + * MathHelper.clamp_float(-1.0f - DeferredStateManager.getSunHeight() * 20.0f, 0.0f, 1.0f) + + 0.01f; + _wglUniform3f(fogShader.uniforms.u_sunColorAdd3f, DeferredStateManager.currentSunLightColor.x * mul, + DeferredStateManager.currentSunLightColor.y * mul, + DeferredStateManager.currentSunLightColor.z * mul); + break; + default: + throw new RuntimeException("Invalid fog type: " + DeferredStateManager.fogLinearExp); } uniformMatrixHelper(fogShader.uniforms.u_inverseViewProjMatrix4f, tmpMatrix1); _wglUniform4f(fogShader.uniforms.u_fogColorLight4f, DeferredStateManager.fogColorLightR, @@ -2881,20 +3053,21 @@ public class EaglerDeferredPipeline { updateForwardRenderWorldLightingData(); EaglercraftGPU.bindGLUniformBuffer(buffer_worldLightingData); EaglercraftGPU.bindUniformBufferRange(0, buffer_worldLightingData, 0, worldLightingDataCopyBuffer.remaining()); - if(config.is_rendering_dynamicLights) { + if (config.is_rendering_dynamicLights) { EaglercraftGPU.bindGLUniformBuffer(buffer_chunkLightingData); - EaglercraftGPU.bindUniformBufferRange(1, buffer_chunkLightingData, 0, chunkLightingDataCopyBuffer.capacity()); + EaglercraftGPU.bindUniformBufferRange(1, buffer_chunkLightingData, 0, + chunkLightingDataCopyBuffer.capacity()); } _wglBindFramebuffer(_GL_FRAMEBUFFER, lightingHDRFramebuffer); GlStateManager.viewport(0, 0, currentWidth, currentHeight); DeferredStateManager.setPassMatrixToGBuffer(); GlStateManager.setActiveTexture(GL_TEXTURE10); GlStateManager.bindTexture(skyIrradianceTexture); - if(config.is_rendering_lightShafts) { + if (config.is_rendering_lightShafts) { GlStateManager.setActiveTexture(GL_TEXTURE11); GlStateManager.bindTexture(lightShaftsTexture); } - if(config.is_rendering_useEnvMap) { + if (config.is_rendering_useEnvMap) { GlStateManager.setActiveTexture(GL_TEXTURE5); GlStateManager.bindTexture(envMapColorTexture); } @@ -2916,12 +3089,12 @@ public class EaglerDeferredPipeline { GlStateManager.setActiveTexture(GL_TEXTURE5); GlStateManager.bindTexture(envMapSkyTexture); GlStateManager.setActiveTexture(GL_TEXTURE4); - if(config.is_rendering_shadowsSun_clamped > 0) { + if (config.is_rendering_shadowsSun_clamped > 0) { GlStateManager.bindTexture(sunShadowDepthBuffer); - if(config.is_rendering_shadowsSmoothed) { + if (config.is_rendering_shadowsSmoothed) { setLinear(); } - }else { + } else { GlStateManager.bindTexture(-1); } TextureManager mgr = mc.getTextureManager(); @@ -2936,7 +3109,7 @@ public class EaglerDeferredPipeline { public void endDrawRealisticWaterSurface() { DeferredStateManager.checkGLError("Pre: endDrawRealisticWaterSurface()"); DeferredStateManager.disableDrawRealisticWaterRender(); - if(config.is_rendering_useEnvMap) { + if (config.is_rendering_useEnvMap) { GlStateManager.setActiveTexture(GL_TEXTURE5); GlStateManager.bindTexture(envMapColorTexture); GlStateManager.setActiveTexture(GL_TEXTURE0); @@ -2970,12 +3143,12 @@ public class EaglerDeferredPipeline { public void beginDrawTranslucentEntities() { DeferredStateManager.checkGLError("Pre: beginDrawTranslucentEntities()"); GlStateManager.setActiveTexture(GL_TEXTURE4); - if(config.is_rendering_shadowsSun_clamped > 0) { + if (config.is_rendering_shadowsSun_clamped > 0) { GlStateManager.bindTexture(sunShadowDepthBuffer); - if(config.is_rendering_shadowsSmoothed) { + if (config.is_rendering_shadowsSmoothed) { setLinear(); } - }else { + } else { GlStateManager.bindTexture(-1); } TextureManager mgr = mc.getTextureManager(); @@ -2989,7 +3162,7 @@ public class EaglerDeferredPipeline { public void saveReprojData() { DeferredStateManager.checkGLError("Pre: saveReprojData()"); - if(reprojectionEngineEnable || config.is_rendering_realisticWater) { + if (reprojectionEngineEnable || config.is_rendering_realisticWater) { // =========== SAVE REPROJECTION DATA FOR NEXT FRAME ============= // @@ -3003,14 +3176,16 @@ public class EaglerDeferredPipeline { GlStateManager.setActiveTexture(GL_TEXTURE0); GlStateManager.bindTexture(lightingHDRFramebufferColorTexture); _wglDrawBuffers(_GL_COLOR_ATTACHMENT0); - TextureCopyUtil.alignPixelsTopLeft(reprojectionTexWidth << 1, reprojectionTexHeight << 1, reprojectionTexWidth, reprojectionTexHeight); + TextureCopyUtil.alignPixelsTopLeft(reprojectionTexWidth << 1, reprojectionTexHeight << 1, + reprojectionTexWidth, reprojectionTexHeight); TextureCopyUtil.blitTexture(); GlStateManager.bindTexture(lightingHDRFramebufferDepthTexture); GlStateManager.enableDepth(); GlStateManager.depthFunc(GL_ALWAYS); GlStateManager.depthMask(true); _wglDrawBuffers(GL_NONE); - TextureCopyUtil.alignPixelsTopLeft(reprojectionTexWidth << 1, reprojectionTexHeight << 1, reprojectionTexWidth, reprojectionTexHeight); + TextureCopyUtil.alignPixelsTopLeft(reprojectionTexWidth << 1, reprojectionTexHeight << 1, + reprojectionTexWidth, reprojectionTexHeight); TextureCopyUtil.blitTextureDepth(); GlStateManager.disableDepth(); GlStateManager.depthMask(false); @@ -3061,7 +3236,7 @@ public class EaglerDeferredPipeline { GlStateManager.disableAlpha(); GlStateManager.disableBlend(); GlStateManager.disableExtensionPipeline(); - if(config.is_rendering_shadowsSun_clamped > 0 && config.is_rendering_shadowsSmoothed) { + if (config.is_rendering_shadowsSun_clamped > 0 && config.is_rendering_shadowsSmoothed) { GlStateManager.bindTexture(sunShadowDepthBuffer); setNearest(); } @@ -3071,7 +3246,7 @@ public class EaglerDeferredPipeline { public void endDrawDeferred() { DeferredStateManager.checkGLError("Pre: endDrawDeferred()"); - if(config.is_rendering_lensFlares && mc.theWorld.provider.getDimensionId() == 0 && + if (config.is_rendering_lensFlares && mc.theWorld.provider.getDimensionId() == 0 && DeferredStateManager.currentSunAngle.y < 0.2f && mc.theWorld.getRainStrength(partialTicks) < 1.0f) { // =============== CALCULATE SUN COORDINATES ================ // @@ -3080,9 +3255,9 @@ public class EaglerDeferredPipeline { tmpVector2.y = DeferredStateManager.currentSunAngle.y * 10.0f; tmpVector2.z = DeferredStateManager.currentSunAngle.z * 10.0f; tmpVector2.w = 1.0f; - + Matrix4f.transform(tmpMatrixViewProj, tmpVector2, tmpVector2); - + tmpVector2.z /= tmpVector2.w; float margin = 0.2f; if (tmpVector2.z <= -1.0f) { @@ -3097,7 +3272,7 @@ public class EaglerDeferredPipeline { && tmpVector2.y > -1.0f - margin) { // ============ CALCULATE DEPTH SUN OCCLUSION ============ // - + _wglBindFramebuffer(_GL_FRAMEBUFFER, sunOcclusionValueFramebuffer); GlStateManager.viewport(0, 0, 1, 1); @@ -3108,14 +3283,14 @@ public class EaglerDeferredPipeline { float fov = 90.0f / mc.entityRenderer.getFOVModifier(partialTicks, true); float radius = 0.05f * fov; - float aspectRatio = (float)currentHeight / (float)currentWidth; - + float aspectRatio = (float) currentHeight / (float) currentWidth; + tmpMatrix3.setIdentity(); tmpMatrix3.m00 = aspectRatio * radius; tmpMatrix3.m11 = radius; tmpMatrix3.m20 = tmpVector2.x * 0.5f + 0.5f; tmpMatrix3.m21 = tmpVector2.y * 0.5f + 0.5f; - + shader_lens_sun_occlusion.useProgram(); uniformMatrixHelper(shader_lens_sun_occlusion.uniforms.u_sampleMatrix3f, tmpMatrix3); @@ -3139,34 +3314,36 @@ public class EaglerDeferredPipeline { // ================ DOWNSCALE AND AVERAGE LUMA =============== // long millis = System.currentTimeMillis(); - if(millis - lastExposureUpdate > 33l) { - if(lumaAvgDownscaleFramebuffers.length == 0) { + if (millis - lastExposureUpdate > 33l) { + if (lumaAvgDownscaleFramebuffers.length == 0) { _wglBindFramebuffer(_GL_FRAMEBUFFER, exposureBlendFramebuffer); GlStateManager.clearColor(1.0f, 1.0f, 1.0f, 1.0f); GlStateManager.clear(GL_COLOR_BUFFER_BIT); - }else { + } else { GlStateManager.setActiveTexture(GL_TEXTURE0); GlStateManager.bindTexture(lightingHDRFramebufferColorTexture); setLinear(); - + int iw = currentWidth; int ih = currentHeight; int iw2 = 0, ih2 = 0, iw3 = 0, ih3 = 0; - for(int i = 0; i < lumaAvgDownscaleFramebuffers.length; ++i) { + for (int i = 0; i < lumaAvgDownscaleFramebuffers.length; ++i) { iw2 = iw >> 2; ih2 = ih >> 2; // cheap way to round up: iw3 = ((iw & 3) != 0) ? (iw2 + 1) : iw2; ih3 = ((ih & 3) != 0) ? (ih2 + 1) : ih2; _wglBindFramebuffer(_GL_FRAMEBUFFER, lumaAvgDownscaleFramebuffers[i]); - - if(i == 0) { + + if (i == 0) { shader_post_exposure_avg_luma.useProgram(); - _wglUniform4f(shader_post_exposure_avg_luma.uniforms.u_sampleOffset4f, 1.0f / iw3, 1.0f / ih3, 4.0f / iw, 4.0f / ih); - }else { + _wglUniform4f(shader_post_exposure_avg_luma.uniforms.u_sampleOffset4f, 1.0f / iw3, 1.0f / ih3, + 4.0f / iw, 4.0f / ih); + } else { shader_post_exposure_avg.useProgram(); GlStateManager.bindTexture(lumaAvgDownscaleTexture[i - 1]); - _wglUniform4f(shader_post_exposure_avg.uniforms.u_sampleOffset4f, 1.0f / iw3, 1.0f / ih3, 4.0f / iw, 4.0f / ih); + _wglUniform4f(shader_post_exposure_avg.uniforms.u_sampleOffset4f, 1.0f / iw3, 1.0f / ih3, + 4.0f / iw, 4.0f / ih); } GlStateManager.viewport(0, 0, iw3, ih3); @@ -3186,7 +3363,8 @@ public class EaglerDeferredPipeline { GlStateManager.enableBlend(); GlStateManager.blendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); - GlStateManager.setBlendConstants(0.0f, 0.0f, 0.0f, Math.min((float)((millis - lastExposureUpdate) * 0.001), 1.0f)); + GlStateManager.setBlendConstants(0.0f, 0.0f, 0.0f, + Math.min((float) ((millis - lastExposureUpdate) * 0.001), 1.0f)); GlStateManager.setActiveTexture(GL_TEXTURE0); GlStateManager.bindTexture(lumaAvgDownscaleTexture[lumaAvgDownscaleTexture.length - 1]); @@ -3204,7 +3382,7 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("endDrawDeferred(): DOWNSCALE AND AVERAGE LUMA"); } - if(config.is_rendering_bloom) { + if (config.is_rendering_bloom) { // ==================== BLOOM: BRIGHT PASS ==================== // @@ -3215,20 +3393,21 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(lightingHDRFramebufferDepthTexture); GlStateManager.setActiveTexture(GL_TEXTURE2); GlStateManager.bindTexture(gBufferMaterialTexture); - if(flag) { + if (flag) { setLinear(); } GlStateManager.setActiveTexture(GL_TEXTURE1); GlStateManager.bindTexture(exposureBlendTexture); GlStateManager.setActiveTexture(GL_TEXTURE0); GlStateManager.bindTexture(lightingHDRFramebufferColorTexture); - if(flag) { + if (flag) { setLinear(); } shader_post_bloom_bright.useProgram(); - _wglUniform4f(shader_post_bloom_bright.uniforms.u_outputSize4f, bloomBrightPassTextureW, bloomBrightPassTextureH, (flag ? 2.0f : 1.0f) / currentWidth, (flag ? 2.0f : 1.0f) / currentHeight); + _wglUniform4f(shader_post_bloom_bright.uniforms.u_outputSize4f, bloomBrightPassTextureW, + bloomBrightPassTextureH, (flag ? 2.0f : 1.0f) / currentWidth, (flag ? 2.0f : 1.0f) / currentHeight); DrawUtils.drawStandardQuad2D(); - if(flag) { + if (flag) { setNearest(); GlStateManager.setActiveTexture(GL_TEXTURE2); setNearest(); @@ -3242,7 +3421,7 @@ public class EaglerDeferredPipeline { int bloomStageW = bloomBrightPassTextureW; int bloomStageH = bloomBrightPassTextureH; int texx = bloomBrightPassTexture; - if(bloomStageW > 300 && bloomStageH > 170) { + if (bloomStageW > 300 && bloomStageH > 170) { bloomStageW >>= 1; bloomStageH >>= 1; _wglBindFramebuffer(_GL_FRAMEBUFFER, bloomDownscaleAFramebuffer); @@ -3254,10 +3433,10 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("endDrawDeferred(): BLOOM: DOWNSCALE A"); - if(bloomStageW > 300 && bloomStageH > 170) { - + if (bloomStageW > 300 && bloomStageH > 170) { + // ==================== BLOOM: DOWNSCALE B ==================== // - + bloomStageW >>= 1; bloomStageH >>= 1; _wglBindFramebuffer(_GL_FRAMEBUFFER, bloomDownscaleBFramebuffer); @@ -3279,7 +3458,8 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(texx); shader_post_bloom_blur.useProgram(); _wglUniform2f(shader_post_bloom_blur.uniforms.u_sampleOffset2f, (flag ? 2.0f : 1.0f) / bloomStageW, 0.0f); - _wglUniform4f(shader_post_bloom_blur.uniforms.u_outputSize4f, bloomBlurTextureW, bloomBlurTextureH, (flag ? 2.0f : 1.0f) / bloomStageW, (flag ? 2.0f : 1.0f) / bloomStageH); + _wglUniform4f(shader_post_bloom_blur.uniforms.u_outputSize4f, bloomBlurTextureW, bloomBlurTextureH, + (flag ? 2.0f : 1.0f) / bloomStageW, (flag ? 2.0f : 1.0f) / bloomStageH); DrawUtils.drawStandardQuad2D(); DeferredStateManager.checkGLError("endDrawDeferred(): BLOOM: HORZ BLUR"); @@ -3290,7 +3470,8 @@ public class EaglerDeferredPipeline { GlStateManager.bindTexture(bloomHBlurTexture); shader_post_bloom_blur.useProgram(); _wglUniform2f(shader_post_bloom_blur.uniforms.u_sampleOffset2f, 0.0f, 1.0f / bloomBlurTextureH); - _wglUniform4f(shader_post_bloom_blur.uniforms.u_outputSize4f, bloomBlurTextureW, bloomBlurTextureH, 1.0f / bloomBlurTextureW, 1.0f / bloomBlurTextureH); + _wglUniform4f(shader_post_bloom_blur.uniforms.u_outputSize4f, bloomBlurTextureW, bloomBlurTextureH, + 1.0f / bloomBlurTextureW, 1.0f / bloomBlurTextureH); DrawUtils.drawStandardQuad2D(); DeferredStateManager.checkGLError("endDrawDeferred(): BLOOM: VERT BLUR"); @@ -3313,12 +3494,12 @@ public class EaglerDeferredPipeline { float exposure = 1.0f; - if(config.is_rendering_fxaa) { + if (config.is_rendering_fxaa) { _wglBindFramebuffer(_GL_FRAMEBUFFER, tonemapOutputFramebuffer); - }else { - if(config.is_rendering_lensDistortion) { + } else { + if (config.is_rendering_lensDistortion) { _wglBindFramebuffer(_GL_FRAMEBUFFER, lensDistortFramebuffer); - }else { + } else { _wglBindFramebuffer(_GL_FRAMEBUFFER, null); } } @@ -3340,13 +3521,13 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("endDrawDeferred(): APPLY TONEMAPPING"); - if(config.is_rendering_fxaa) { - + if (config.is_rendering_fxaa) { + // ======================= APPLY FXAA ======================== // - if(config.is_rendering_lensDistortion) { + if (config.is_rendering_lensDistortion) { _wglBindFramebuffer(_GL_FRAMEBUFFER, lensDistortFramebuffer); - }else { + } else { _wglBindFramebuffer(_GL_FRAMEBUFFER, null); } shader_post_fxaa.useProgram(); @@ -3356,9 +3537,9 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("endDrawDeferred(): APPLY FXAA"); } - - if(config.is_rendering_lensDistortion) { - + + if (config.is_rendering_lensDistortion) { + // ================= APPLY LENS DISTORTION ================== // _wglBindFramebuffer(_GL_FRAMEBUFFER, null); @@ -3369,10 +3550,10 @@ public class EaglerDeferredPipeline { DeferredStateManager.checkGLError("endDrawDeferred(): APPLY LENS DISTORTION"); } - + // =========== BLIT WORLD DEPTH BUFFER TO OUTPUT ============= // - if(EagRuntime.getPlatformType() == EnumPlatformType.DESKTOP) { + if (EagRuntime.getPlatformType() == EnumPlatformType.DESKTOP) { _wglBindFramebuffer(_GL_FRAMEBUFFER, null); GlStateManager.enableDepth(); GlStateManager.depthFunc(GL_ALWAYS); @@ -3382,10 +3563,11 @@ public class EaglerDeferredPipeline { GlStateManager.disableDepth(); GlStateManager.depthFunc(GL_LEQUAL); GlStateManager.depthMask(false); - }else { + } else { _wglBindFramebuffer(_GL_READ_FRAMEBUFFER, lightingHDRFramebuffer); _wglBindFramebuffer(_GL_DRAW_FRAMEBUFFER, null); - _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST); + _wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, + GL_DEPTH_BUFFER_BIT, GL_NEAREST); } DeferredStateManager.checkGLError("endDrawDeferred(): BLIT WORLD DEPTH BUFFER TO OUTPUT"); @@ -3395,7 +3577,7 @@ public class EaglerDeferredPipeline { _wglBindFramebuffer(_GL_FRAMEBUFFER, null); drawDebugViewIfEnabled(); - for(int i = 0; i < lightSourceBuckets.length; ++i) { + for (int i = 0; i < lightSourceBuckets.length; ++i) { lightSourceBuckets[i].clear(); } @@ -3432,7 +3614,7 @@ public class EaglerDeferredPipeline { public PipelineShaderGBufferDebugView useDebugViewShader(int idx) { PipelineShaderGBufferDebugView dbgShader = shader_gbuffer_debug_view[idx]; - if(dbgShader == null) { + if (dbgShader == null) { shader_gbuffer_debug_view[idx] = dbgShader = PipelineShaderGBufferDebugView.compile(idx); dbgShader.loadUniforms(); } @@ -3441,501 +3623,501 @@ public class EaglerDeferredPipeline { } private void drawDebugViewIfEnabled() { - if(DebugFramebufferView.debugViewShown) { + if (DebugFramebufferView.debugViewShown) { DebugFramebufferView.renderDebugView(); } } public void destroy() { DeferredStateManager.checkGLError("Pre: destroy()"); - if(gBufferFramebuffer != null) { + if (gBufferFramebuffer != null) { _wglDeleteFramebuffer(gBufferFramebuffer); gBufferFramebuffer = null; } - if(gBufferDiffuseTexture != -1) { + if (gBufferDiffuseTexture != -1) { GlStateManager.bindTexture(gBufferDiffuseTexture); gBufferDiffuseTexture = -1; } - if(gBufferNormalsTexture != -1) { + if (gBufferNormalsTexture != -1) { GlStateManager.bindTexture(gBufferNormalsTexture); gBufferNormalsTexture = -1; } - if(gBufferMaterialTexture != -1) { + if (gBufferMaterialTexture != -1) { GlStateManager.bindTexture(gBufferMaterialTexture); gBufferMaterialTexture = -1; } - if(gBufferDepthTexture != -1) { + if (gBufferDepthTexture != -1) { GlStateManager.bindTexture(gBufferDepthTexture); gBufferDepthTexture = -1; } - if(sunShadowFramebuffer != null) { + if (sunShadowFramebuffer != null) { _wglDeleteFramebuffer(sunShadowFramebuffer); sunShadowFramebuffer = null; } - if(sunShadowDepthBuffer != -1) { + if (sunShadowDepthBuffer != -1) { GlStateManager.deleteTexture(sunShadowDepthBuffer); sunShadowDepthBuffer = -1; } - if(sunLightingShadowFramebuffer != null) { + if (sunLightingShadowFramebuffer != null) { _wglDeleteFramebuffer(sunLightingShadowFramebuffer); sunLightingShadowFramebuffer = null; } - if(sunLightingShadowTexture != -1) { + if (sunLightingShadowTexture != -1) { GlStateManager.deleteTexture(sunLightingShadowTexture); sunLightingShadowTexture = -1; } - if(ssaoGenerateFramebuffer != null) { + if (ssaoGenerateFramebuffer != null) { _wglDeleteFramebuffer(ssaoGenerateFramebuffer); ssaoGenerateFramebuffer = null; } - if(ssaoGenerateTexture != -1) { + if (ssaoGenerateTexture != -1) { GlStateManager.deleteTexture(ssaoGenerateTexture); ssaoGenerateTexture = -1; reprojectionTexWidth = -1; reprojectionTexHeight = -1; } - if(shader_ssao_generate != null) { + if (shader_ssao_generate != null) { shader_ssao_generate.destroy(); shader_ssao_generate = null; } - if(ssaoNoiseTexture != -1) { + if (ssaoNoiseTexture != -1) { GlStateManager.deleteTexture(ssaoNoiseTexture); ssaoNoiseTexture = -1; } - for(int i = 0; i < 2; ++i) { - if(reprojectionControlFramebuffer[i] != null) { + for (int i = 0; i < 2; ++i) { + if (reprojectionControlFramebuffer[i] != null) { _wglDeleteFramebuffer(reprojectionControlFramebuffer[i]); reprojectionControlFramebuffer[i] = null; } - if(reprojectionControlSSAOTexture[i] != -1) { + if (reprojectionControlSSAOTexture[i] != -1) { GlStateManager.deleteTexture(reprojectionControlSSAOTexture[i]); reprojectionControlSSAOTexture[i] = -1; } - if(reprojectionSSRFramebuffer[i] != null) { + if (reprojectionSSRFramebuffer[i] != null) { _wglDeleteFramebuffer(reprojectionSSRFramebuffer[i]); reprojectionSSRFramebuffer[i] = null; } - if(reprojectionSSRTexture[i] != -1) { + if (reprojectionSSRTexture[i] != -1) { GlStateManager.deleteTexture(reprojectionSSRTexture[i]); reprojectionSSRTexture[i] = -1; } - if(reprojectionSSRHitVector[i] != -1) { + if (reprojectionSSRHitVector[i] != -1) { GlStateManager.deleteTexture(reprojectionSSRHitVector[i]); reprojectionSSRHitVector[i] = -1; } } - if(lastFrameFramebuffer != null) { + if (lastFrameFramebuffer != null) { _wglDeleteFramebuffer(lastFrameFramebuffer); lastFrameFramebuffer = null; } - if(lastFrameColorTexture != -1) { + if (lastFrameColorTexture != -1) { GlStateManager.deleteTexture(lastFrameColorTexture); lastFrameColorTexture = -1; } - if(lastFrameDepthTexture != -1) { + if (lastFrameDepthTexture != -1) { GlStateManager.deleteTexture(lastFrameDepthTexture); lastFrameDepthTexture = -1; } - if(gBufferQuarterFramebuffer != null) { + if (gBufferQuarterFramebuffer != null) { _wglDeleteFramebuffer(gBufferQuarterFramebuffer); gBufferQuarterFramebuffer = null; } - if(gBufferQuarterDepthTexture != -1) { + if (gBufferQuarterDepthTexture != -1) { GlStateManager.deleteTexture(gBufferQuarterDepthTexture); gBufferQuarterDepthTexture = -1; } - if(lastFrameGBufferFramebuffer != null) { + if (lastFrameGBufferFramebuffer != null) { _wglDeleteFramebuffer(lastFrameGBufferFramebuffer); lastFrameGBufferFramebuffer = null; } - if(lastFrameGBufferDepthTexture != -1) { + if (lastFrameGBufferDepthTexture != -1) { GlStateManager.deleteTexture(lastFrameGBufferDepthTexture); lastFrameGBufferDepthTexture = -1; } - if(lightingHDRFramebuffer != null) { + if (lightingHDRFramebuffer != null) { _wglDeleteFramebuffer(lightingHDRFramebuffer); lightingHDRFramebuffer = null; } - if(lightingHDRFramebufferColorTexture != -1) { + if (lightingHDRFramebufferColorTexture != -1) { GlStateManager.deleteTexture(lightingHDRFramebufferColorTexture); lightingHDRFramebufferColorTexture = -1; } - if(lightingHDRFramebufferDepthTexture != -1) { + if (lightingHDRFramebufferDepthTexture != -1) { GlStateManager.deleteTexture(lightingHDRFramebufferDepthTexture); lightingHDRFramebufferDepthTexture = -1; } - if(handRenderFramebuffer != null) { + if (handRenderFramebuffer != null) { _wglDeleteFramebuffer(handRenderFramebuffer); handRenderFramebuffer = null; } - if(handRenderFramebufferDepthTexture != -1) { + if (handRenderFramebufferDepthTexture != -1) { GlStateManager.deleteTexture(handRenderFramebufferDepthTexture); handRenderFramebufferDepthTexture = -1; } - if(atmosphereHDRFramebuffer != null) { + if (atmosphereHDRFramebuffer != null) { _wglDeleteFramebuffer(atmosphereHDRFramebuffer); atmosphereHDRFramebuffer = null; } - if(atmosphereHDRFramebufferColorTexture != -1) { + if (atmosphereHDRFramebufferColorTexture != -1) { GlStateManager.deleteTexture(atmosphereHDRFramebufferColorTexture); atmosphereHDRFramebufferColorTexture = -1; } - if(envMapAtmosphereFramebuffer != null) { + if (envMapAtmosphereFramebuffer != null) { _wglDeleteFramebuffer(envMapAtmosphereFramebuffer); envMapAtmosphereFramebuffer = null; } - if(envMapAtmosphereTexture != -1) { + if (envMapAtmosphereTexture != -1) { GlStateManager.deleteTexture(envMapAtmosphereTexture); envMapAtmosphereTexture = -1; } - if(envMapSkyFramebuffer != null) { + if (envMapSkyFramebuffer != null) { _wglDeleteFramebuffer(envMapSkyFramebuffer); envMapSkyFramebuffer = null; } - if(envMapSkyTexture != -1) { + if (envMapSkyTexture != -1) { GlStateManager.deleteTexture(envMapSkyTexture); envMapSkyTexture = -1; } - if(moonTextures != -1) { + if (moonTextures != -1) { GlStateManager.deleteTexture(moonTextures); moonTextures = -1; } - if(envMapFramebuffer != null) { + if (envMapFramebuffer != null) { _wglDeleteFramebuffer(envMapFramebuffer); envMapFramebuffer = null; } - if(envMapColorTexture != -1) { + if (envMapColorTexture != -1) { GlStateManager.deleteTexture(envMapColorTexture); envMapColorTexture = -1; } - if(envMapDepthTexture != -1) { + if (envMapDepthTexture != -1) { GlStateManager.deleteTexture(envMapDepthTexture); envMapDepthTexture = -1; } - if(atmosphereIrradianceFramebuffer != null) { + if (atmosphereIrradianceFramebuffer != null) { _wglDeleteFramebuffer(atmosphereIrradianceFramebuffer); atmosphereIrradianceFramebuffer = null; } - if(atmosphereIrradianceTexture != -1) { + if (atmosphereIrradianceTexture != -1) { GlStateManager.deleteTexture(atmosphereIrradianceTexture); atmosphereIrradianceTexture = -1; } - if(skyIrradianceFramebuffer != null) { + if (skyIrradianceFramebuffer != null) { _wglDeleteFramebuffer(skyIrradianceFramebuffer); skyIrradianceFramebuffer = null; } - if(skyIrradianceTexture != -1) { + if (skyIrradianceTexture != -1) { GlStateManager.deleteTexture(skyIrradianceTexture); skyIrradianceTexture = -1; } - if(tonemapOutputFramebuffer != null) { + if (tonemapOutputFramebuffer != null) { _wglDeleteFramebuffer(tonemapOutputFramebuffer); tonemapOutputFramebuffer = null; } - if(tonemapOutputTexture != -1) { + if (tonemapOutputTexture != -1) { GlStateManager.deleteTexture(tonemapOutputTexture); tonemapOutputTexture = -1; } - if(lensDistortFramebuffer != null) { + if (lensDistortFramebuffer != null) { _wglDeleteFramebuffer(lensDistortFramebuffer); lensDistortFramebuffer = null; } - if(lensDistortTexture != -1) { + if (lensDistortTexture != -1) { GlStateManager.deleteTexture(lensDistortTexture); lensDistortTexture = -1; } - if(lumaAvgDownscaleFramebuffers != null) { - for(int i = 0; i < lumaAvgDownscaleFramebuffers.length; ++i) { + if (lumaAvgDownscaleFramebuffers != null) { + for (int i = 0; i < lumaAvgDownscaleFramebuffers.length; ++i) { _wglDeleteFramebuffer(lumaAvgDownscaleFramebuffers[i]); } lumaAvgDownscaleFramebuffers = null; } - if(lumaAvgDownscaleTexture != null) { - for(int i = 0; i < lumaAvgDownscaleTexture.length; ++i) { + if (lumaAvgDownscaleTexture != null) { + for (int i = 0; i < lumaAvgDownscaleTexture.length; ++i) { GlStateManager.deleteTexture(lumaAvgDownscaleTexture[i]); } lumaAvgDownscaleTexture = null; } - if(exposureBlendFramebuffer != null) { + if (exposureBlendFramebuffer != null) { _wglDeleteFramebuffer(exposureBlendFramebuffer); exposureBlendFramebuffer = null; } - if(exposureBlendTexture != -1) { + if (exposureBlendTexture != -1) { GlStateManager.deleteTexture(exposureBlendTexture); exposureBlendTexture = -1; } - if(bloomBrightPassFramebuffer != null) { + if (bloomBrightPassFramebuffer != null) { _wglDeleteFramebuffer(bloomBrightPassFramebuffer); bloomBrightPassFramebuffer = null; } - if(bloomBrightPassTexture != -1) { + if (bloomBrightPassTexture != -1) { GlStateManager.bindTexture(bloomBrightPassTexture); bloomBrightPassTexture = -1; } - if(bloomHBlurFramebuffer != null) { + if (bloomHBlurFramebuffer != null) { _wglDeleteFramebuffer(bloomHBlurFramebuffer); bloomHBlurFramebuffer = null; } - if(bloomHBlurTexture != -1) { + if (bloomHBlurTexture != -1) { GlStateManager.deleteTexture(bloomHBlurTexture); bloomHBlurTexture = -1; } - if(bloomVBlurFramebuffer != null) { + if (bloomVBlurFramebuffer != null) { _wglDeleteFramebuffer(bloomVBlurFramebuffer); bloomVBlurFramebuffer = null; } - if(bloomVBlurTexture != -1) { + if (bloomVBlurTexture != -1) { GlStateManager.deleteTexture(bloomVBlurTexture); bloomVBlurTexture = -1; } - if(bloomDownscaleAFramebuffer != null) { + if (bloomDownscaleAFramebuffer != null) { _wglDeleteFramebuffer(bloomDownscaleAFramebuffer); bloomDownscaleAFramebuffer = null; } - if(bloomDownscaleATexture != -1) { + if (bloomDownscaleATexture != -1) { GlStateManager.deleteTexture(bloomDownscaleATexture); bloomDownscaleATexture = -1; } - if(bloomDownscaleBFramebuffer != null) { + if (bloomDownscaleBFramebuffer != null) { _wglDeleteFramebuffer(bloomDownscaleBFramebuffer); bloomDownscaleBFramebuffer = null; } - if(bloomDownscaleBTexture != -1) { + if (bloomDownscaleBTexture != -1) { GlStateManager.deleteTexture(bloomDownscaleBTexture); bloomDownscaleBTexture = -1; } - if(sunOcclusionValueFramebuffer != null) { + if (sunOcclusionValueFramebuffer != null) { _wglDeleteFramebuffer(sunOcclusionValueFramebuffer); sunOcclusionValueFramebuffer = null; } - if(sunOcclusionValueTexture != -1) { + if (sunOcclusionValueTexture != -1) { GlStateManager.deleteTexture(sunOcclusionValueTexture); sunOcclusionValueTexture = -1; } - if(dither8x8Texture != -1) { + if (dither8x8Texture != -1) { GlStateManager.deleteTexture(dither8x8Texture); dither8x8Texture = -1; } - if(shader_deferred_combine != null) { + if (shader_deferred_combine != null) { shader_deferred_combine.destroy(); shader_deferred_combine = null; } - if(shader_hand_depth_mask != null) { + if (shader_hand_depth_mask != null) { shader_hand_depth_mask.destroy(); shader_hand_depth_mask = null; } - if(brdfTexture != -1) { + if (brdfTexture != -1) { GlStateManager.deleteTexture(brdfTexture); brdfTexture = -1; } - if(shader_lighting_sun != null) { + if (shader_lighting_sun != null) { shader_lighting_sun.destroy(); shader_lighting_sun = null; } - if(shader_shadows_sun != null) { + if (shader_shadows_sun != null) { shader_shadows_sun.destroy(); shader_shadows_sun = null; } - if(shader_light_shafts_sample != null) { + if (shader_light_shafts_sample != null) { shader_light_shafts_sample.destroy(); shader_light_shafts_sample = null; } - if(skybox != null) { + if (skybox != null) { skybox.destroy(); skybox = null; } - if(pointLightMesh != null) { + if (pointLightMesh != null) { pointLightMesh.destroy(); pointLightMesh = null; } - if(shader_skybox_atmosphere != null) { + if (shader_skybox_atmosphere != null) { shader_skybox_atmosphere.destroy(); shader_skybox_atmosphere = null; } - if(shader_skybox_render != null) { + if (shader_skybox_render != null) { shader_skybox_render.destroy(); shader_skybox_render = null; } - if(shader_lighting_point != null) { + if (shader_lighting_point != null) { shader_lighting_point.destroy(); shader_lighting_point = null; } - if(shader_post_lens_distort != null) { + if (shader_post_lens_distort != null) { shader_post_lens_distort.destroy(); shader_post_lens_distort = null; } - if(shader_post_tonemap != null) { + if (shader_post_tonemap != null) { shader_post_tonemap.destroy(); shader_post_tonemap = null; } - if(shader_post_exposure_avg != null) { + if (shader_post_exposure_avg != null) { shader_post_exposure_avg.destroy(); shader_post_exposure_avg = null; } - if(shader_post_exposure_avg_luma != null) { + if (shader_post_exposure_avg_luma != null) { shader_post_exposure_avg_luma.destroy(); shader_post_exposure_avg_luma = null; } - if(shader_post_exposure_final != null) { + if (shader_post_exposure_final != null) { shader_post_exposure_final.destroy(); shader_post_exposure_final = null; } - if(shader_post_bloom_bright != null) { + if (shader_post_bloom_bright != null) { shader_post_bloom_bright.destroy(); shader_post_bloom_bright = null; } - if(shader_post_bloom_blur != null) { + if (shader_post_bloom_blur != null) { shader_post_bloom_blur.destroy(); shader_post_bloom_blur = null; } - if(shader_lens_sun_occlusion != null) { + if (shader_lens_sun_occlusion != null) { shader_lens_sun_occlusion.destroy(); shader_lens_sun_occlusion = null; } - if(shader_realistic_water_control != null) { + if (shader_realistic_water_control != null) { shader_realistic_water_control.destroy(); shader_realistic_water_control = null; } - if(shader_realistic_water_noise != null) { + if (shader_realistic_water_noise != null) { shader_realistic_water_noise.destroy(); shader_realistic_water_noise = null; } - if(shader_realistic_water_normals != null) { + if (shader_realistic_water_normals != null) { shader_realistic_water_normals.destroy(); shader_realistic_water_normals = null; } - if(shader_post_fxaa != null) { + if (shader_post_fxaa != null) { shader_post_fxaa.destroy(); shader_post_fxaa = null; } - if(shader_skybox_render_paraboloid != null) { + if (shader_skybox_render_paraboloid != null) { shader_skybox_render_paraboloid.destroy(); shader_skybox_render_paraboloid = null; } - if(shader_skybox_render_paraboloid_noclouds != null) { + if (shader_skybox_render_paraboloid_noclouds != null) { shader_skybox_render_paraboloid_noclouds.destroy(); shader_skybox_render_paraboloid_noclouds = null; } - if(shader_skybox_render_end != null) { + if (shader_skybox_render_end != null) { shader_skybox_render_end.destroy(); shader_skybox_render_end = null; } - for(int i = 0; i < 3; ++i) { - if(shader_skybox_irradiance[i] != null) { + for (int i = 0; i < 3; ++i) { + if (shader_skybox_irradiance[i] != null) { shader_skybox_irradiance[i].destroy(); shader_skybox_irradiance[i] = null; } } - if(shader_colored_fog_linear != null) { + if (shader_colored_fog_linear != null) { shader_colored_fog_linear.destroy(); shader_colored_fog_linear = null; } - if(shader_colored_fog_exp != null) { + if (shader_colored_fog_exp != null) { shader_colored_fog_exp.destroy(); shader_colored_fog_exp = null; } - if(shader_atmosphere_fog != null) { + if (shader_atmosphere_fog != null) { shader_atmosphere_fog.destroy(); shader_atmosphere_fog = null; } - if(shader_moon_render != null) { + if (shader_moon_render != null) { shader_moon_render.destroy(); shader_moon_render = null; } - if(shader_reproject_control != null) { + if (shader_reproject_control != null) { shader_reproject_control.destroy(); shader_reproject_control = null; } - if(shader_reproject_ssr != null) { + if (shader_reproject_ssr != null) { shader_reproject_ssr.destroy(); shader_reproject_ssr = null; } - if(realisticWaterMaskFramebuffer != null) { + if (realisticWaterMaskFramebuffer != null) { _wglDeleteFramebuffer(realisticWaterMaskFramebuffer); realisticWaterMaskFramebuffer = null; } - if(realisticWaterMaskTexture != -1) { + if (realisticWaterMaskTexture != -1) { GlStateManager.deleteTexture(realisticWaterMaskTexture); realisticWaterMaskTexture = -1; } - if(realisticWaterDepthBuffer != -1) { + if (realisticWaterDepthBuffer != -1) { GlStateManager.deleteTexture(realisticWaterDepthBuffer); realisticWaterDepthBuffer = -1; } - if(realisticWaterCombinedNormalsFramebuffer != null) { + if (realisticWaterCombinedNormalsFramebuffer != null) { _wglDeleteFramebuffer(realisticWaterCombinedNormalsFramebuffer); realisticWaterCombinedNormalsFramebuffer = null; } - if(realisticWaterCombinedNormalsTexture != -1) { + if (realisticWaterCombinedNormalsTexture != -1) { GlStateManager.deleteTexture(realisticWaterCombinedNormalsTexture); realisticWaterCombinedNormalsTexture = -1; } - if(realisticWaterRefractionTexture != -1) { + if (realisticWaterRefractionTexture != -1) { GlStateManager.deleteTexture(realisticWaterRefractionTexture); realisticWaterRefractionTexture = -1; } - if(realisticWaterControlFramebuffer != null) { + if (realisticWaterControlFramebuffer != null) { _wglDeleteFramebuffer(realisticWaterControlFramebuffer); realisticWaterControlFramebuffer = null; } - for(int i = 0; i < 2; ++i) { - if(realisticWaterSSRFramebuffer[i] != null) { + for (int i = 0; i < 2; ++i) { + if (realisticWaterSSRFramebuffer[i] != null) { _wglDeleteFramebuffer(realisticWaterSSRFramebuffer[i]); realisticWaterSSRFramebuffer[i] = null; } - if(realisticWaterControlReflectionTexture[i] != -1) { + if (realisticWaterControlReflectionTexture[i] != -1) { GlStateManager.deleteTexture(realisticWaterControlReflectionTexture[i]); realisticWaterControlReflectionTexture[i] = -1; } - if(realisticWaterControlHitVectorTexture[i] != -1) { + if (realisticWaterControlHitVectorTexture[i] != -1) { GlStateManager.deleteTexture(realisticWaterControlHitVectorTexture[i]); realisticWaterControlHitVectorTexture[i] = -1; } } - if(realisticWaterNormalMapFramebuffer != null) { + if (realisticWaterNormalMapFramebuffer != null) { _wglDeleteFramebuffer(realisticWaterNormalMapFramebuffer); realisticWaterNormalMapFramebuffer = null; } - if(realisticWaterNormalMapTexture != -1) { + if (realisticWaterNormalMapTexture != -1) { GlStateManager.deleteTexture(realisticWaterNormalMapTexture); realisticWaterNormalMapTexture = -1; } - if(realisticWaterDisplacementMapFramebuffer != null) { + if (realisticWaterDisplacementMapFramebuffer != null) { _wglDeleteFramebuffer(realisticWaterDisplacementMapFramebuffer); realisticWaterDisplacementMapFramebuffer = null; } - if(realisticWaterDisplacementMapTexture != -1) { + if (realisticWaterDisplacementMapTexture != -1) { GlStateManager.deleteTexture(realisticWaterDisplacementMapTexture); realisticWaterDisplacementMapTexture = -1; } - if(realisticWaterNoiseMap != -1) { + if (realisticWaterNoiseMap != -1) { GlStateManager.deleteTexture(realisticWaterNoiseMap); realisticWaterNoiseMap = -1; } - if(buffer_chunkLightingData != null) { + if (buffer_chunkLightingData != null) { _wglDeleteBuffers(buffer_chunkLightingData); buffer_chunkLightingData = null; } - if(buffer_worldLightingData != null) { + if (buffer_worldLightingData != null) { _wglDeleteBuffers(buffer_worldLightingData); buffer_worldLightingData = null; } - if(worldLightingDataCopyBuffer != null) { + if (worldLightingDataCopyBuffer != null) { EagRuntime.freeByteBuffer(worldLightingDataCopyBuffer); worldLightingDataCopyBuffer = null; } - if(chunkLightingDataCopyBuffer != null) { + if (chunkLightingDataCopyBuffer != null) { EagRuntime.freeByteBuffer(chunkLightingDataCopyBuffer); chunkLightingDataCopyBuffer = null; } - for(int i = 0; i < lightSourceBuckets.length; ++i) { + for (int i = 0; i < lightSourceBuckets.length; ++i) { lightSourceBuckets[i].clear(); } currentLightSourceBucket = null; currentBoundLightSourceBucket = null; isChunkLightingEnabled = false; - for(int i = 0; i < shader_gbuffer_debug_view.length; ++i) { - if(shader_gbuffer_debug_view[i] != null) { + for (int i = 0; i < shader_gbuffer_debug_view.length; ++i) { + if (shader_gbuffer_debug_view[i] != null) { shader_gbuffer_debug_view[i].destroy(); shader_gbuffer_debug_view[i] = null; } @@ -3976,7 +4158,7 @@ public class EaglerDeferredPipeline { GlStateManager.loadIdentity(); GlStateManager.matrixMode(GL_MODELVIEW); GlStateManager.loadIdentity(); - if(config.is_rendering_shadowsSun_clamped > 0 && config.is_rendering_shadowsSmoothed) { + if (config.is_rendering_shadowsSun_clamped > 0 && config.is_rendering_shadowsSmoothed) { GlStateManager.bindTexture(sunShadowDepthBuffer); _wglTexParameteri(GL_TEXTURE_2D, _GL_TEXTURE_COMPARE_MODE, _GL_COMPARE_REF_TO_TEXTURE); setNearest(); @@ -3988,9 +4170,9 @@ public class EaglerDeferredPipeline { } public static final String getReasonUnsupported() { - if(!EaglercraftGPU.checkHasHDRFramebufferSupportWithFilter()) { + if (!EaglercraftGPU.checkHasHDRFramebufferSupportWithFilter()) { return I18n.format("shaders.gui.unsupported.reason.hdrFramebuffer"); - }else { + } else { return null; } } diff --git a/src/main/java/net/minecraft/block/Block.java b/src/main/java/net/minecraft/block/Block.java index 4c69a83..bb836ba 100644 --- a/src/main/java/net/minecraft/block/Block.java +++ b/src/main/java/net/minecraft/block/Block.java @@ -3,6 +3,8 @@ package net.minecraft.block; import java.util.Arrays; import java.util.List; +import javax.annotation.Nullable; + import net.hoosiertransfer.EaglerItems; import net.hoosiertransfer.Alfheim.ILightInfoProvider; import net.hoosiertransfer.Alfheim.ILightLevelProvider; @@ -492,6 +494,17 @@ public class Block implements ILitBlock { } + protected static void addCollisionBoxToList(BlockPos pos, AxisAlignedBB entityBox, + List collidingBoxes, @Nullable AxisAlignedBB blockBox) { + if (blockBox != null) { + AxisAlignedBB axisalignedbb = blockBox.offset(pos); + + if (entityBox.intersectsWith(axisalignedbb)) { + collidingBoxes.add(axisalignedbb); + } + } + } + public AxisAlignedBB getCollisionBoundingBox(World var1, BlockPos blockpos, IBlockState var3) { return new AxisAlignedBB((double) blockpos.getX() + this.minX, (double) blockpos.getY() + this.minY, (double) blockpos.getZ() + this.minZ, (double) blockpos.getX() + this.maxX, @@ -1644,6 +1657,12 @@ public class Block implements ILitBlock { registerEaglerBlock(198, "end_rod", (new BlockEndRod()).setHardness(0.0F).setLightLevel(0.9375F) .setStepSound(soundTypeWood).setUnlocalizedName("endRod")); + registerEaglerBlock(199, "chorus_plant", + (new BlockChorusPlant()).setHardness(0.4F).setStepSound(soundTypeWood) + .setUnlocalizedName("chorusPlant")); + registerEaglerBlock(200, "chorus_flower", + (new BlockChorusFlower()).setHardness(0.4F).setStepSound(soundTypeWood) + .setUnlocalizedName("chorusFlower")); Block purpurBlock = (new Block(Material.rock)).setHardness(1.5F).setResistance(10.0F) .setStepSound(soundTypeStone).setCreativeTab(CreativeTabs.tabBlock).setUnlocalizedName("purpurBlock"); registerEaglerBlock(201, (String) "purpur_block", purpurBlock); @@ -1665,6 +1684,8 @@ public class Block implements ILitBlock { Block block15 = (new BlockGrassPath()).setHardness(0.65F).setStepSound(soundTypeGrass) .setUnlocalizedName("grassPath").disableStats(); registerEaglerBlock(208, "grass_path", block15); + registerEaglerBlock(209, "end_gateway", + (new BlockEndGateway(Material.portal)).setHardness(-1.0F).setResistance(6000000.0F), false); blockRegistry.validateKey(); diff --git a/src/main/java/net/minecraft/block/BlockChorusFlower.java b/src/main/java/net/minecraft/block/BlockChorusFlower.java new file mode 100644 index 0000000..ea28ce2 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockChorusFlower.java @@ -0,0 +1,277 @@ +package net.minecraft.block; + +import java.util.Random; + +import javax.annotation.Nullable; + +import net.hoosiertransfer.EaglerItems; +import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; +import net.minecraft.block.material.Material; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyInteger; +import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.world.World; + +public class BlockChorusFlower extends Block { + public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 5); + + protected BlockChorusFlower() { + super(Material.plants); + this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0))); + this.setCreativeTab(CreativeTabs.tabDecorations); + this.setTickRandomly(true); + } + + @Nullable + + /** + * Get the Item that this Block should drop when harvested. + */ + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return null; + } + + public void updateTick(World worldIn, BlockPos pos, IBlockState state, EaglercraftRandom rand) { + if (!this.canSurvive(worldIn, pos)) { + worldIn.destroyBlock(pos, true); + } else { + BlockPos blockpos = pos.up(); + + if (worldIn.isAirBlock(blockpos) && blockpos.getY() < 256) { + int i = ((Integer) state.getValue(AGE)).intValue(); + + if (i < 5 && rand.nextInt(1) == 0) { + boolean flag = false; + boolean flag1 = false; + Block block = worldIn.getBlockState(pos.down()).getBlock(); + + if (block == Blocks.end_stone) { + flag = true; + } else if (block == EaglerItems.getEaglerBlock("chorus_plant")) { + int j = 1; + + for (int k = 0; k < 4; ++k) { + Block block1 = worldIn.getBlockState(pos.down(j + 1)).getBlock(); + + if (block1 != EaglerItems.getEaglerBlock("chorus_plant")) { + if (block1 == Blocks.end_stone) { + flag1 = true; + } + + break; + } + + ++j; + } + + int i1 = 4; + + if (flag1) { + ++i1; + } + + if (j < 2 || rand.nextInt(i1) >= j) { + flag = true; + } + } else if (block == Blocks.air) { + flag = true; + } + + if (flag && areAllNeighborsEmpty(worldIn, blockpos, (EnumFacing) null) + && worldIn.isAirBlock(pos.up(2))) { + worldIn.setBlockState(pos, EaglerItems.getEaglerBlock("chorus_plant").getDefaultState(), 2); + this.placeGrownFlower(worldIn, blockpos, i); + } else if (i < 4) { + int l = rand.nextInt(4); + boolean flag2 = false; + + if (flag1) { + ++l; + } + + for (int j1 = 0; j1 < l; ++j1) { + EnumFacing enumfacing = EnumFacing.Plane.HORIZONTAL.random(rand); + BlockPos blockpos1 = pos.offset(enumfacing); + + if (worldIn.isAirBlock(blockpos1) && worldIn.isAirBlock(blockpos1.down()) + && areAllNeighborsEmpty(worldIn, blockpos1, enumfacing.getOpposite())) { + this.placeGrownFlower(worldIn, blockpos1, i + 1); + flag2 = true; + } + } + + if (flag2) { + worldIn.setBlockState(pos, EaglerItems.getEaglerBlock("chorus_plant").getDefaultState(), 2); + } else { + this.placeDeadFlower(worldIn, pos); + } + } else if (i == 4) { + this.placeDeadFlower(worldIn, pos); + } + } + } + } + } + + private void placeGrownFlower(World p_185602_1_, BlockPos p_185602_2_, int p_185602_3_) { + p_185602_1_.setBlockState(p_185602_2_, this.getDefaultState().withProperty(AGE, Integer.valueOf(p_185602_3_)), + 2); + // TODO: implement soundf + p_185602_1_.playAuxSFX(1033, p_185602_2_, 0); + } + + private void placeDeadFlower(World p_185605_1_, BlockPos p_185605_2_) { + p_185605_1_.setBlockState(p_185605_2_, this.getDefaultState().withProperty(AGE, Integer.valueOf(5)), 2); + p_185605_1_.playAuxSFX(1034, p_185605_2_, 0); + } + + private static boolean areAllNeighborsEmpty(World p_185604_0_, BlockPos p_185604_1_, EnumFacing p_185604_2_) { + for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { + if (enumfacing != p_185604_2_ && !p_185604_0_.isAirBlock(p_185604_1_.offset(enumfacing))) { + return false; + } + } + + return true; + } + + public boolean isFullCube() { + return false; + } + + public boolean isOpaqueCube() { + return false; + } + + public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { + return super.canPlaceBlockAt(worldIn, pos) && this.canSurvive(worldIn, pos); + } + + public void onNeighborBlockChange(IBlockState p_189540_1_, World p_189540_2_, BlockPos p_189540_3_, + Block p_189540_4_) { + if (!this.canSurvive(p_189540_2_, p_189540_3_)) { + p_189540_2_.scheduleUpdate(p_189540_3_, this, 1); + } + } + + public boolean canSurvive(World worldIn, BlockPos pos) { + Block block = worldIn.getBlockState(pos.down()).getBlock(); + + if (block != EaglerItems.getEaglerBlock("chorus_plant") && block != Blocks.end_stone) { + if (block == Blocks.air) { + int i = 0; + + for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { + Block block1 = worldIn.getBlockState(pos.offset(enumfacing)).getBlock(); + + if (block1 == EaglerItems.getEaglerBlock("chorus_plant")) { + ++i; + } else if (block1 != Blocks.air) { + return false; + } + } + + return i == 1; + } else { + return false; + } + } else { + return true; + } + } + + public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, + @Nullable TileEntity te) { + super.harvestBlock(worldIn, player, pos, state, te); + spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this))); + } + + protected ItemStack createStackedBlock(IBlockState state) { + return null; + } + + public EnumWorldBlockLayer getBlockLayer() { + return EnumWorldBlockLayer.CUTOUT; + } + + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta)); + } + + public int getMetaFromState(IBlockState state) { + return ((Integer) state.getValue(AGE)).intValue(); + } + + protected BlockState createBlockState() { + return new BlockState(this, new IProperty[] { AGE }); + } + + public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { + super.onBlockAdded(worldIn, pos, state); + } + + public static void generatePlant(World worldIn, BlockPos pos, EaglercraftRandom rand, int p_185603_3_) { + worldIn.setBlockState(pos, EaglerItems.getEaglerBlock("chorus_plant").getDefaultState(), 2); + growTreeRecursive(worldIn, pos, rand, pos, p_185603_3_, 0); + } + + private static void growTreeRecursive(World worldIn, BlockPos p_185601_1_, EaglercraftRandom rand, + BlockPos p_185601_3_, + int p_185601_4_, int p_185601_5_) { + int i = rand.nextInt(4) + 1; + + if (p_185601_5_ == 0) { + ++i; + } + + for (int j = 0; j < i; ++j) { + BlockPos blockpos = p_185601_1_.up(j + 1); + + if (!areAllNeighborsEmpty(worldIn, blockpos, (EnumFacing) null)) { + return; + } + + worldIn.setBlockState(blockpos, EaglerItems.getEaglerBlock("chorus_plant").getDefaultState(), 2); + } + + boolean flag = false; + + if (p_185601_5_ < 4) { + int l = rand.nextInt(4); + + if (p_185601_5_ == 0) { + ++l; + } + + for (int k = 0; k < l; ++k) { + EnumFacing enumfacing = EnumFacing.Plane.HORIZONTAL.random(rand); + BlockPos blockpos1 = p_185601_1_.up(i).offset(enumfacing); + + if (Math.abs(blockpos1.getX() - p_185601_3_.getX()) < p_185601_4_ + && Math.abs(blockpos1.getZ() - p_185601_3_.getZ()) < p_185601_4_ + && worldIn.isAirBlock(blockpos1) && worldIn.isAirBlock(blockpos1.down()) + && areAllNeighborsEmpty(worldIn, blockpos1, enumfacing.getOpposite())) { + flag = true; + worldIn.setBlockState(blockpos1, EaglerItems.getEaglerBlock("chorus_plant").getDefaultState(), 2); + growTreeRecursive(worldIn, blockpos1, rand, p_185601_3_, p_185601_4_, p_185601_5_ + 1); + } + } + } + + if (!flag) { + worldIn.setBlockState(p_185601_1_.up(i), + EaglerItems.getEaglerBlock("chorus_plant").getDefaultState().withProperty(AGE, Integer.valueOf(5)), + 2); + } + } +} diff --git a/src/main/java/net/minecraft/block/BlockChorusPlant.java b/src/main/java/net/minecraft/block/BlockChorusPlant.java new file mode 100644 index 0000000..c1e34e3 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockChorusPlant.java @@ -0,0 +1,222 @@ +package net.minecraft.block; + +import java.util.List; +import java.util.Random; + +import javax.annotation.Nullable; + +import net.hoosiertransfer.EaglerItems; +import net.minecraft.block.material.Material; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.chunk.BlockStateContainer; + +public class BlockChorusPlant extends Block { + public static final PropertyBool NORTH = PropertyBool.create("north"); + public static final PropertyBool EAST = PropertyBool.create("east"); + public static final PropertyBool SOUTH = PropertyBool.create("south"); + public static final PropertyBool WEST = PropertyBool.create("west"); + public static final PropertyBool UP = PropertyBool.create("up"); + public static final PropertyBool DOWN = PropertyBool.create("down"); + + protected BlockChorusPlant() { + super(Material.plants); + this.setCreativeTab(CreativeTabs.tabDecorations); + this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)) + .withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)) + .withProperty(WEST, Boolean.valueOf(false)).withProperty(UP, Boolean.valueOf(false)) + .withProperty(DOWN, Boolean.valueOf(false))); + } + + /** + * Get the actual Block state of this Block at the given position. This applies + * properties not visible in the + * metadata, such as fence connections. + */ + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { + Block block = worldIn.getBlockState(pos.down()).getBlock(); + Block block1 = worldIn.getBlockState(pos.up()).getBlock(); + Block block2 = worldIn.getBlockState(pos.north()).getBlock(); + Block block3 = worldIn.getBlockState(pos.east()).getBlock(); + Block block4 = worldIn.getBlockState(pos.south()).getBlock(); + Block block5 = worldIn.getBlockState(pos.west()).getBlock(); + return state + .withProperty(DOWN, + Boolean.valueOf(block == this || block == EaglerItems.getEaglerBlock("chorus_flower") + || block == Blocks.end_stone)) + .withProperty(UP, + Boolean.valueOf(block1 == this || block1 == EaglerItems.getEaglerBlock("chorus_flower"))) + .withProperty(NORTH, + Boolean.valueOf(block2 == this || block2 == EaglerItems.getEaglerBlock("chorus_flower"))) + .withProperty(EAST, + Boolean.valueOf(block3 == this || block3 == EaglerItems.getEaglerBlock("chorus_flower"))) + .withProperty(SOUTH, + Boolean.valueOf(block4 == this || block4 == EaglerItems.getEaglerBlock("chorus_flower"))) + .withProperty(WEST, + Boolean.valueOf(block5 == this || block5 == EaglerItems.getEaglerBlock("chorus_flower"))); + } + + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + state = state.getBlock().getActualState(state, source, pos); + float f = 0.1875F; + float f1 = ((Boolean) state.getValue(WEST)).booleanValue() ? 0.0F : 0.1875F; + float f2 = ((Boolean) state.getValue(DOWN)).booleanValue() ? 0.0F : 0.1875F; + float f3 = ((Boolean) state.getValue(NORTH)).booleanValue() ? 0.0F : 0.1875F; + float f4 = ((Boolean) state.getValue(EAST)).booleanValue() ? 1.0F : 0.8125F; + float f5 = ((Boolean) state.getValue(UP)).booleanValue() ? 1.0F : 0.8125F; + float f6 = ((Boolean) state.getValue(SOUTH)).booleanValue() ? 1.0F : 0.8125F; + return new AxisAlignedBB((double) f1, (double) f2, (double) f3, (double) f4, (double) f5, (double) f6); + } + + public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos blockpos, IBlockState var3) { + return this.getBoundingBox(var3, world, blockpos); + } + + public void addCollisionBoxesToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, + List collidingBoxes, @Nullable Entity entityIn) { + state = state.getBlock().getActualState(state, worldIn, pos); + float f = 0.1875F; + float f1 = 0.8125F; + addCollisionBoxToList(pos, entityBox, collidingBoxes, + new AxisAlignedBB(0.1875D, 0.1875D, 0.1875D, 0.8125D, 0.8125D, 0.8125D)); + + if (((Boolean) state.getValue(WEST)).booleanValue()) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, + new AxisAlignedBB(0.0D, 0.1875D, 0.1875D, 0.1875D, 0.8125D, 0.8125D)); + } + + if (((Boolean) state.getValue(EAST)).booleanValue()) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, + new AxisAlignedBB(0.8125D, 0.1875D, 0.1875D, 1.0D, 0.8125D, 0.8125D)); + } + + if (((Boolean) state.getValue(UP)).booleanValue()) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, + new AxisAlignedBB(0.1875D, 0.8125D, 0.1875D, 0.8125D, 1.0D, 0.8125D)); + } + + if (((Boolean) state.getValue(DOWN)).booleanValue()) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, + new AxisAlignedBB(0.1875D, 0.0D, 0.1875D, 0.8125D, 0.1875D, 0.8125D)); + } + + if (((Boolean) state.getValue(NORTH)).booleanValue()) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, + new AxisAlignedBB(0.1875D, 0.1875D, 0.0D, 0.8125D, 0.8125D, 0.1875D)); + } + + if (((Boolean) state.getValue(SOUTH)).booleanValue()) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, + new AxisAlignedBB(0.1875D, 0.1875D, 0.8125D, 0.8125D, 0.8125D, 1.0D)); + } + } + + /** + * Convert the BlockState into the correct metadata value + */ + public int getMetaFromState(IBlockState state) { + return 0; + } + + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (!this.canSurviveAt(worldIn, pos)) { + worldIn.destroyBlock(pos, true); + } + } + + @Nullable + + /** + * Get the Item that this Block should drop when harvested. + */ + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return EaglerItems.getEaglerItem("chorus_fruit"); + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + public int quantityDropped(Random random) { + return random.nextInt(2); + } + + public boolean isFullCube() { + return false; + } + + /** + * Used to determine ambient occlusion and culling when rebuilding chunks for + * render + */ + public boolean isOpaqueCube() { + return false; + } + + public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { + return super.canPlaceBlockAt(worldIn, pos) ? this.canSurviveAt(worldIn, pos) : false; + } + + public void onNeighborBlockChange(IBlockState p_189540_1_, World p_189540_2_, BlockPos p_189540_3_, + Block p_189540_4_) { + if (!this.canSurviveAt(p_189540_2_, p_189540_3_)) { + p_189540_2_.scheduleUpdate(p_189540_3_, this, 1); + } + } + + public boolean canSurviveAt(World wordIn, BlockPos pos) { + boolean flag = wordIn.isAirBlock(pos.up()); + boolean flag1 = wordIn.isAirBlock(pos.down()); + + for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { + BlockPos blockpos = pos.offset(enumfacing); + Block block = wordIn.getBlockState(blockpos).getBlock(); + + if (block == this) { + if (!flag && !flag1) { + return false; + } + + Block block1 = wordIn.getBlockState(blockpos.down()).getBlock(); + + if (block1 == this || block1 == Blocks.end_stone) { + return true; + } + } + } + + Block block2 = wordIn.getBlockState(pos.down()).getBlock(); + return block2 == this || block2 == Blocks.end_stone; + } + + public EnumWorldBlockLayer getBlockLayer() { + return EnumWorldBlockLayer.CUTOUT; + } + + public boolean shouldSideBeRendered(IBlockAccess blockAccess, BlockPos pos, + EnumFacing side) { + Block block = blockAccess.getBlockState(pos.offset(side)).getBlock(); + return block != this && block != EaglerItems.getEaglerBlock("chorus_flower") + && (side != EnumFacing.DOWN || block != Blocks.end_stone); + } + + protected BlockState createBlockState() { + return new BlockState(this, new IProperty[] { NORTH, EAST, SOUTH, WEST, UP, DOWN }); + } + + public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { + return false; + } +} diff --git a/src/main/java/net/minecraft/block/BlockEndGateway.java b/src/main/java/net/minecraft/block/BlockEndGateway.java new file mode 100644 index 0000000..126730e --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockEndGateway.java @@ -0,0 +1,96 @@ +package net.minecraft.block; + +import javax.annotation.Nullable; + +import net.hoosiertransfer.EaglerItems; +import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityEndGateway; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockEndGateway extends BlockContainer { + protected BlockEndGateway(Material p_i46687_1_) { + super(p_i46687_1_); + this.setLightLevel(1.0F); + } + + public TileEntity createNewTileEntity(World worldIn, int meta) { + return new TileEntityEndGateway(); + } + + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, BlockPos blockpos, EnumFacing enumfacing) { + IBlockState iblockstate = iblockaccess.getBlockState(blockpos.offset(enumfacing)); + Block block = iblockstate.getBlock(); + return !iblockstate.getBlock().isOpaqueCube() && block != EaglerItems.getEaglerBlock("end_gateway"); + } + + public AxisAlignedBB getCollisionBoundingBox(World var1, BlockPos var2, IBlockState var3) { + return null; + } + + /** + * Used to determine ambient occlusion and culling when rebuilding chunks for + * render + */ + public boolean isOpaqueCube() { + return false; + } + + public boolean isFullCube() { + return false; + } + + public int quantityDropped(EaglercraftRandom random) { + return 0; + } + + public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, EaglercraftRandom rand) { + TileEntity tileentity = worldIn.getTileEntity(pos); + + if (tileentity instanceof TileEntityEndGateway) { + int i = ((TileEntityEndGateway) tileentity).getParticleAmount(); + + for (int j = 0; j < i; ++j) { + double d0 = (double) ((float) pos.getX() + rand.nextFloat()); + double d1 = (double) ((float) pos.getY() + rand.nextFloat()); + double d2 = (double) ((float) pos.getZ() + rand.nextFloat()); + double d3 = ((double) rand.nextFloat() - 0.5D) * 0.5D; + double d4 = ((double) rand.nextFloat() - 0.5D) * 0.5D; + double d5 = ((double) rand.nextFloat() - 0.5D) * 0.5D; + int k = rand.nextInt(2) * 2 - 1; + + if (rand.nextBoolean()) { + d2 = (double) pos.getZ() + 0.5D + 0.25D * (double) k; + d5 = (double) (rand.nextFloat() * 2.0F * (float) k); + } else { + d0 = (double) pos.getX() + 0.5D + 0.25D * (double) k; + d3 = (double) (rand.nextFloat() * 2.0F * (float) k); + } + + worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]); + } + } + } + + @Nullable + public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { + return null; + } + + /** + * Get the MapColor for this Block and the given BlockState + */ + public MapColor getMapColor(IBlockState state) { + return MapColor.blackColor; + } +} diff --git a/src/main/java/net/minecraft/block/BlockGrassPath.java b/src/main/java/net/minecraft/block/BlockGrassPath.java index 47cab8c..ff96152 100644 --- a/src/main/java/net/minecraft/block/BlockGrassPath.java +++ b/src/main/java/net/minecraft/block/BlockGrassPath.java @@ -31,9 +31,8 @@ public class BlockGrassPath extends Block { case SOUTH: case WEST: case EAST: - IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side)); - Block block = iblockstate.getBlock(); - return !iblockstate.getBlock().isOpaqueCube() && block != Blocks.farmland + Block block = blockAccess.getBlockState(pos).getBlock(); + return !block.isOpaqueCube() && block != Blocks.farmland && block != EaglerItems.getEaglerBlock("grass_path"); default: @@ -59,11 +58,11 @@ public class BlockGrassPath extends Block { * Used to determine ambient occlusion and culling when rebuilding chunks for * render */ - public boolean isOpaqueCube(IBlockState state) { + public boolean isOpaqueCube() { return false; } - public boolean isFullCube(IBlockState state) { + public boolean isFullCube() { return false; } diff --git a/src/main/java/net/minecraft/client/Minecraft.java b/src/main/java/net/minecraft/client/Minecraft.java index 23ece79..7fea14e 100644 --- a/src/main/java/net/minecraft/client/Minecraft.java +++ b/src/main/java/net/minecraft/client/Minecraft.java @@ -2046,7 +2046,7 @@ public class Minecraft implements IThreadListener { } if (flag) { - int j = this.thePlayer.inventoryContainer.inventorySlots.size() - 9 + inventoryplayer.currentItem; + int j = 36 + inventoryplayer.currentItem; this.playerController.sendSlotPacket(inventoryplayer.getStackInSlot(inventoryplayer.currentItem), j); } diff --git a/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java b/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java index faaeccd..0f872e9 100644 --- a/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java +++ b/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java @@ -202,6 +202,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityBanner; import net.minecraft.tileentity.TileEntityBeacon; import net.minecraft.tileentity.TileEntityCommandBlock; +import net.minecraft.tileentity.TileEntityEndGateway; import net.minecraft.tileentity.TileEntityFlowerPot; import net.minecraft.tileentity.TileEntityMobSpawner; import net.minecraft.tileentity.TileEntitySign; @@ -1161,7 +1162,7 @@ public class NetHandlerPlayClient implements INetHandlerPlayClient { || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner // || i == 7 && tileentity instanceof TileEntityStructure - // || i == 8 && tileentity instanceof TileEntityEndGateway + || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign) { tileentity.readFromNBT(packetIn.getNbtCompound()); } diff --git a/src/main/java/net/minecraft/client/renderer/BlockModelShapes.java b/src/main/java/net/minecraft/client/renderer/BlockModelShapes.java index 0f08504..8972900 100644 --- a/src/main/java/net/minecraft/client/renderer/BlockModelShapes.java +++ b/src/main/java/net/minecraft/client/renderer/BlockModelShapes.java @@ -6,6 +6,7 @@ import java.util.Map.Entry; import com.google.common.collect.Maps; +import net.hoosiertransfer.EaglerItems; import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite; import net.minecraft.block.Block; import net.minecraft.block.BlockBed; @@ -175,7 +176,7 @@ public class BlockModelShapes { this.registerBuiltInBlocks(new Block[] { Blocks.air, Blocks.flowing_water, Blocks.water, Blocks.flowing_lava, Blocks.lava, Blocks.piston_extension, Blocks.chest, Blocks.ender_chest, Blocks.trapped_chest, Blocks.standing_sign, Blocks.skull, Blocks.end_portal, Blocks.barrier, Blocks.wall_sign, - Blocks.wall_banner, Blocks.standing_banner }); + Blocks.wall_banner, Blocks.standing_banner, EaglerItems.getEaglerBlock("end_gateway") }); this.registerBlockWithStateMapper(Blocks.stone, (new StateMap.Builder()).withName(BlockStone.VARIANT).build()); this.registerBlockWithStateMapper(Blocks.prismarine, (new StateMap.Builder()).withName(BlockPrismarine.VARIANT).build()); diff --git a/src/main/java/net/minecraft/client/renderer/RenderGlobal.java b/src/main/java/net/minecraft/client/renderer/RenderGlobal.java index 199aacf..491dc2d 100644 --- a/src/main/java/net/minecraft/client/renderer/RenderGlobal.java +++ b/src/main/java/net/minecraft/client/renderer/RenderGlobal.java @@ -46,6 +46,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.audio.SoundCategory; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.chunk.CompiledChunk; @@ -72,6 +73,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityWitherSkull; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemDye; import net.minecraft.item.ItemRecord; @@ -2490,6 +2492,14 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene return; case 2005: ItemDye.spawnBonemealParticles(this.theWorld, blockpos, j); + case 3000: + this.theWorld.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, true, (double) blockpos.getX() + 0.5D, + (double) blockpos.getY() + 0.5D, (double) blockpos.getZ() + 0.5D, 0.0D, 0.0D, 0.0D, + new int[0]); + this.theWorld.playSound(blockpos, SoundEvents.BLOCK_END_GATEWAY_SPAWN, SoundCategory.BLOCKS, 10.0F, + (1.0F + (this.theWorld.rand.nextFloat() - this.theWorld.rand.nextFloat()) * 0.2F) * 0.7F, + false); + break; } } diff --git a/src/main/java/net/minecraft/client/renderer/entity/layers/LayerSheepWool.java b/src/main/java/net/minecraft/client/renderer/entity/layers/LayerSheepWool.java index d4f868a..05b2157 100644 --- a/src/main/java/net/minecraft/client/renderer/entity/layers/LayerSheepWool.java +++ b/src/main/java/net/minecraft/client/renderer/entity/layers/LayerSheepWool.java @@ -56,12 +56,12 @@ public class LayerSheepWool implements LayerRenderer { int k = i % j; int l = (i + 1) % j; float f7 = ((float) (entitysheep.ticksExisted % 25) + f2) / 25.0F; - float[] afloat1 = EntitySheep.func_175513_a(EnumDyeColor.byMetadata(k)); - float[] afloat2 = EntitySheep.func_175513_a(EnumDyeColor.byMetadata(l)); + float[] afloat1 = EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(k)); + float[] afloat2 = EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(l)); GlStateManager.color(afloat1[0] * (1.0F - f7) + afloat2[0] * f7, afloat1[1] * (1.0F - f7) + afloat2[1] * f7, afloat1[2] * (1.0F - f7) + afloat2[2] * f7); } else { - float[] afloat = EntitySheep.func_175513_a(entitysheep.getFleeceColor()); + float[] afloat = EntitySheep.getDyeRgb(entitysheep.getFleeceColor()); GlStateManager.color(afloat[0], afloat[1], afloat[2]); } diff --git a/src/main/java/net/minecraft/client/renderer/entity/layers/LayerWolfCollar.java b/src/main/java/net/minecraft/client/renderer/entity/layers/LayerWolfCollar.java index ed3fc4c..8af3ccb 100644 --- a/src/main/java/net/minecraft/client/renderer/entity/layers/LayerWolfCollar.java +++ b/src/main/java/net/minecraft/client/renderer/entity/layers/LayerWolfCollar.java @@ -49,7 +49,7 @@ public class LayerWolfCollar implements LayerRenderer { if (entitywolf.isTamed() && !entitywolf.isInvisible()) { this.wolfRenderer.bindTexture(WOLF_COLLAR); EnumDyeColor enumdyecolor = EnumDyeColor.byMetadata(entitywolf.getCollarColor().getMetadata()); - float[] afloat = EntitySheep.func_175513_a(enumdyecolor); + float[] afloat = EntitySheep.getDyeRgb(enumdyecolor); GlStateManager.color(afloat[0], afloat[1], afloat[2]); this.wolfRenderer.getMainModel().render(entitywolf, f, f1, f2, f3, f4, f5); } diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer.java index 023d4ad..6127620 100644 --- a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer.java +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer.java @@ -301,6 +301,129 @@ public class TileEntityBeaconRenderer extends TileEntitySpecialRenderer { + private static final ResourceLocation END_SKY_TEXTURE = new ResourceLocation("textures/environment/end_sky.png"); + private static final ResourceLocation END_PORTAL_TEXTURE = new ResourceLocation("textures/entity/end_portal.png"); + private static final ResourceLocation END_GATEWAY_BEAM_TEXTURE = new ResourceLocation( + "textures/entity/end_gateway_beam.png"); + private static final EaglercraftRandom RANDOM = new EaglercraftRandom(31100L); + private static final float[] MODELVIEW = new float[16]; + private static final float[] PROJECTION = new float[16]; + FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16); + + public void renderTileEntityAt(TileEntityEndGateway var1, double d0, double d1, double d2, float var8, int var9) { + if (DeferredStateManager.isInDeferredPass()) { + if (!DeferredStateManager.isInParaboloidPass() && !DeferredStateManager.isEnableShadowRender() + && DeferredStateManager.forwardCallbackHandler != null) { + DeferredStateManager.forwardCallbackHandler + .push(new ShadersRenderPassFuture((float) d0, (float) d1, (float) d2, var8) { + @Override + public void draw(PassType pass) { + if (pass == PassType.MAIN) { + DeferredStateManager.reportForwardRenderObjectPosition2(x, y, z); + } + DeferredStateManager.setDefaultMaterialConstants(); + DeferredStateManager.setRoughnessConstant(0.3f); + DeferredStateManager.setMetalnessConstant(0.3f); + DeferredStateManager.setEmissionConstant(0.9f); + renderTileEntityAt0(var1, d0, d1, d2, var8, var9); + DeferredStateManager.setDefaultMaterialConstants(); + DeferredStateManager.setHDRTranslucentPassBlendFunc(); + } + }); + } + return; + } + renderTileEntityAt0(var1, d0, d1, d2, var8, var9); + } + + public void renderTileEntityAt0(TileEntityEndGateway te, double x, double y, double z, float partialTicks, + int destroyStage) { + // ! fix this it looks like shit + GlStateManager.disableFog(); + + if (te.isSpawning() || te.isCoolingDown()) { + GlStateManager.alphaFunc(516, 0.1F); + this.bindTexture(END_GATEWAY_BEAM_TEXTURE); + float f = te.isSpawning() ? te.getSpawnPercent() : te.getCooldownPercent(); + double d0 = te.isSpawning() ? 256.0D - y : 25.0D; + f = MathHelper.sin(f * (float) Math.PI); + int j = MathHelper.floor_double((double) f * d0); + float[] afloat = EntitySheep.getDyeRgb(te.isSpawning() ? EnumDyeColor.MAGENTA : EnumDyeColor.YELLOW); + TileEntityBeaconRenderer.renderBeamSegment(x, y, z, (double) partialTicks, (double) f, + (double) te.getWorld().getTotalWorldTime(), 0, j, afloat, 0.15D, 0.175D); + TileEntityBeaconRenderer.renderBeamSegment(x, y, z, (double) partialTicks, (double) f, + (double) te.getWorld().getTotalWorldTime(), 0, -j, afloat, 0.15D, 0.175D); + } + + GlStateManager.disableLighting(); + RANDOM.setSeed(31100L); + GlStateManager.getFloat(2982, MODELVIEW); + GlStateManager.getFloat(2983, PROJECTION); + double d1 = x * x + y * y + z * z; + int i; + + if (d1 > 36864.0D) { + i = 2; + } else if (d1 > 25600.0D) { + i = 4; + } else if (d1 > 16384.0D) { + i = 6; + } else if (d1 > 9216.0D) { + i = 8; + } else if (d1 > 4096.0D) { + i = 10; + } else if (d1 > 1024.0D) { + i = 12; + } else if (d1 > 576.0D) { + i = 14; + } else if (d1 > 256.0D) { + i = 15; + } else { + i = 16; + } + + for (int k = 0; k < i; ++k) { + GlStateManager.pushMatrix(); + float f5 = 2.0F / (float) (18 - k); + + if (k == 0) { + this.bindTexture(END_SKY_TEXTURE); + f5 = 0.15F; + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, + GL_ONE_MINUS_SRC_ALPHA); + } + + if (k >= 1) { + this.bindTexture(END_PORTAL_TEXTURE); + } + + if (k == 1) { + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_ONE, GL_ONE); + } + + GlStateManager.texGen(GlStateManager.TexGen.S, 9216); + GlStateManager.texGen(GlStateManager.TexGen.T, 9216); + GlStateManager.texGen(GlStateManager.TexGen.R, 9216); + GlStateManager.func_179105_a(GlStateManager.TexGen.S, 9474, this.getBuffer(1.0F, 0.0F, 0.0F, 0.0F)); + GlStateManager.func_179105_a(GlStateManager.TexGen.T, 9474, this.getBuffer(0.0F, 1.0F, 0.0F, 0.0F)); + GlStateManager.func_179105_a(GlStateManager.TexGen.R, 9474, this.getBuffer(0.0F, 0.0F, 1.0F, 0.0F)); + GlStateManager.enableTexGen(); + GlStateManager.popMatrix(); + GlStateManager.matrixMode(5890); + GlStateManager.pushMatrix(); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.5F, 0.5F, 0.0F); + GlStateManager.scale(0.5F, 0.5F, 1.0F); + float f1 = (float) (k + 1); + GlStateManager.translate(17.0F / f1, + (2.0F + f1 / 1.5F) * ((float) Minecraft.getSystemTime() % 800000.0F / 800000.0F), 0.0F); + GlStateManager.rotate((f1 * f1 * 4321.0F + f1 * 9.0F) * 2.0F, 0.0F, 0.0F, 1.0F); + GlStateManager.scale(4.5F - f1 / 4.0F, 4.5F - f1 / 4.0F, 1.0F); + GlStateManager.multMatrix(PROJECTION); + GlStateManager.multMatrix(MODELVIEW); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer vertexbuffer = tessellator.getWorldRenderer(); + vertexbuffer.begin(7, DefaultVertexFormats.POSITION_COLOR); + float f2 = (RANDOM.nextFloat() * 0.5F + 0.1F) * f5; + float f3 = (RANDOM.nextFloat() * 0.5F + 0.4F) * f5; + float f4 = (RANDOM.nextFloat() * 0.5F + 0.5F) * f5; + + if (k == 0) { + f2 = f3 = f4 = 1.0F * f5; + } + + if (te.shouldRenderFace(EnumFacing.SOUTH)) { + vertexbuffer.pos(x, y, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y + 1.0D, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x, y + 1.0D, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + } + + if (te.shouldRenderFace(EnumFacing.NORTH)) { + vertexbuffer.pos(x, y + 1.0D, z).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y + 1.0D, z).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y, z).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x, y, z).color(f2, f3, f4, 1.0F).endVertex(); + } + + if (te.shouldRenderFace(EnumFacing.EAST)) { + vertexbuffer.pos(x + 1.0D, y + 1.0D, z).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y + 1.0D, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y, z).color(f2, f3, f4, 1.0F).endVertex(); + } + + if (te.shouldRenderFace(EnumFacing.WEST)) { + vertexbuffer.pos(x, y, z).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x, y, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x, y + 1.0D, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x, y + 1.0D, z).color(f2, f3, f4, 1.0F).endVertex(); + } + + if (te.shouldRenderFace(EnumFacing.DOWN)) { + vertexbuffer.pos(x, y, z).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y, z).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x, y, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + } + + if (te.shouldRenderFace(EnumFacing.UP)) { + vertexbuffer.pos(x, y + 1.0D, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y + 1.0D, z + 1.0D).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x + 1.0D, y + 1.0D, z).color(f2, f3, f4, 1.0F).endVertex(); + vertexbuffer.pos(x, y + 1.0D, z).color(f2, f3, f4, 1.0F).endVertex(); + } + + tessellator.draw(); + GlStateManager.popMatrix(); + GlStateManager.matrixMode(5888); + this.bindTexture(END_SKY_TEXTURE); + } + + GlStateManager.disableBlend(); + GlStateManager.disableTexGen(); + GlStateManager.enableLighting(); + GlStateManager.enableFog(); + } + + private FloatBuffer getBuffer(float p_188193_1_, float p_188193_2_, float p_188193_3_, float p_188193_4_) { + this.buffer.clear(); + this.buffer.put(p_188193_1_).put(p_188193_2_).put(p_188193_3_).put(p_188193_4_); + this.buffer.flip(); + return this.buffer; + } + + public boolean isGlobalRenderer(TileEntityEndGateway te) { + return te.isSpawning() || te.isCoolingDown(); + } +} diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java index 3a21d28..18ef775 100644 --- a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java @@ -17,6 +17,7 @@ import net.minecraft.tileentity.TileEntityBanner; import net.minecraft.tileentity.TileEntityBeacon; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.tileentity.TileEntityEnchantmentTable; +import net.minecraft.tileentity.TileEntityEndGateway; import net.minecraft.tileentity.TileEntityEndPortal; import net.minecraft.tileentity.TileEntityEnderChest; import net.minecraft.tileentity.TileEntityMobSpawner; @@ -81,6 +82,7 @@ public class TileEntityRendererDispatcher { this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer()); + this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); diff --git a/src/main/java/net/minecraft/entity/passive/EntitySheep.java b/src/main/java/net/minecraft/entity/passive/EntitySheep.java index 3136b47..33750f5 100644 --- a/src/main/java/net/minecraft/entity/passive/EntitySheep.java +++ b/src/main/java/net/minecraft/entity/passive/EntitySheep.java @@ -79,7 +79,7 @@ public class EntitySheep extends EntityAnimal { private int sheepTimer; private EntityAIEatGrass entityAIEatGrass = new EntityAIEatGrass(this); - public static float[] func_175513_a(EnumDyeColor dyeColor) { + public static float[] getDyeRgb(EnumDyeColor dyeColor) { return (float[]) DYE_TO_RGB.get(dyeColor); } diff --git a/src/main/java/net/minecraft/entity/player/InventoryPlayer.java b/src/main/java/net/minecraft/entity/player/InventoryPlayer.java index 1301f37..a5b6ad5 100644 --- a/src/main/java/net/minecraft/entity/player/InventoryPlayer.java +++ b/src/main/java/net/minecraft/entity/player/InventoryPlayer.java @@ -1,5 +1,6 @@ package net.minecraft.entity.player; +import java.util.Arrays; import java.util.concurrent.Callable; import javax.annotation.Nullable; @@ -55,14 +56,14 @@ public class InventoryPlayer implements IInventory { * An array of 36 item stacks indicating the main player * inventory (including the visible bar). */ - public ItemStack[] mainInventory = new ItemStack[36]; + public final ItemStack[] mainInventory = new ItemStack[36]; /** * + * An array of 4 item stacks containing the currently worn armor * pieces. */ - public ItemStack[] armorInventory = new ItemStack[4]; - public ItemStack[] offHandInventory = new ItemStack[1]; + public final ItemStack[] armorInventory = new ItemStack[4]; + public final ItemStack[] offHandInventory = new ItemStack[1]; private final ItemStack[][] allInventories; @@ -76,6 +77,17 @@ public class InventoryPlayer implements IInventory { this.player = playerIn; } + private boolean canMergeStacks(@Nullable ItemStack stack1, ItemStack stack2) { + return stack1 != null && this.stackEqualExact(stack1, stack2) && stack1.isStackable() + && stack1.stackSize < stack1.getMaxStackSize() && stack1.stackSize < this.getInventoryStackLimit(); + } + + private boolean stackEqualExact(ItemStack stack1, ItemStack stack2) { + return stack1.getItem() == stack2.getItem() + && (!stack1.getHasSubtypes() || stack1.getMetadata() == stack2.getMetadata()) + && ItemStack.areItemStackTagsEqual(stack1, stack2); + } + /** * + * Returns the item stack currently held by the player. @@ -118,19 +130,19 @@ public class InventoryPlayer implements IInventory { * stores an itemstack in the users inventory */ private int storeItemStack(ItemStack itemStackIn) { - for (int i = 0; i < this.mainInventory.length; ++i) { - if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemStackIn.getItem() - && this.mainInventory[i].isStackable() - && this.mainInventory[i].stackSize < this.mainInventory[i].getMaxStackSize() - && this.mainInventory[i].stackSize < this.getInventoryStackLimit() - && (!this.mainInventory[i].getHasSubtypes() - || this.mainInventory[i].getMetadata() == itemStackIn.getMetadata()) - && ItemStack.areItemStackTagsEqual(this.mainInventory[i], itemStackIn)) { - return i; + if (this.canMergeStacks(this.getStackInSlot(this.currentItem), itemStackIn)) { + return this.currentItem; + } else if (this.canMergeStacks(this.getStackInSlot(40), itemStackIn)) { + return 40; + } else { + for (int i = 0; i < this.mainInventory.length; ++i) { + if (this.canMergeStacks(this.mainInventory[i], itemStackIn)) { + return i; + } } - } - return -1; + return -1; + } } /** @@ -293,35 +305,42 @@ public class InventoryPlayer implements IInventory { Item item = itemStackIn.getItem(); int i = itemStackIn.stackSize; int j = this.storeItemStack(itemStackIn); - if (j < 0) { + + if (j == -1) { j = this.getFirstEmptyStack(); } - if (j < 0) { + if (j == -1) { return i; } else { - if (this.mainInventory[j] == null) { - this.mainInventory[j] = new ItemStack(item, 0, itemStackIn.getMetadata()); + ItemStack itemstack = this.getStackInSlot(j); + + if (itemstack == null) { + itemstack = new ItemStack(item, 0, itemStackIn.getMetadata()); + if (itemStackIn.hasTagCompound()) { - this.mainInventory[j].setTagCompound((NBTTagCompound) itemStackIn.getTagCompound().copy()); + itemstack.setTagCompound((NBTTagCompound) itemStackIn.getTagCompound().copy()); } + + this.setInventorySlotContents(j, itemstack); } int k = i; - if (i > this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].stackSize) { - k = this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].stackSize; + + if (i > itemstack.getMaxStackSize() - itemstack.stackSize) { + k = itemstack.getMaxStackSize() - itemstack.stackSize; } - if (k > this.getInventoryStackLimit() - this.mainInventory[j].stackSize) { - k = this.getInventoryStackLimit() - this.mainInventory[j].stackSize; + if (k > this.getInventoryStackLimit() - itemstack.stackSize) { + k = this.getInventoryStackLimit() - itemstack.stackSize; } if (k == 0) { return i; } else { i = i - k; - this.mainInventory[j].stackSize += k; - this.mainInventory[j].animationsToGo = 5; + itemstack.stackSize += k; + itemstack.animationsToGo = 5; return i; } } @@ -548,15 +567,16 @@ public class InventoryPlayer implements IInventory { * Reads from the given tag list and fills the slots in the * inventory with the correct items. */ - public void readFromNBT(NBTTagList parNBTTagList) { - this.mainInventory = new ItemStack[36]; - this.armorInventory = new ItemStack[4]; - this.offHandInventory = new ItemStack[1]; + public void readFromNBT(NBTTagList nbtTagListIn) { + Arrays.fill(this.mainInventory, (Object) null); + Arrays.fill(this.armorInventory, (Object) null); + Arrays.fill(this.offHandInventory, (Object) null); - for (int i = 0; i < parNBTTagList.tagCount(); ++i) { - NBTTagCompound nbttagcompound = parNBTTagList.getCompoundTagAt(i); + for (int i = 0; i < nbtTagListIn.tagCount(); ++i) { + NBTTagCompound nbttagcompound = nbtTagListIn.getCompoundTagAt(i); int j = nbttagcompound.getByte("Slot") & 255; ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound); + if (itemstack != null) { if (j >= 0 && j < this.mainInventory.length) { this.mainInventory[j] = itemstack; @@ -567,7 +587,6 @@ public class InventoryPlayer implements IInventory { } } } - } /** diff --git a/src/main/java/net/minecraft/item/crafting/RecipesArmorDyes.java b/src/main/java/net/minecraft/item/crafting/RecipesArmorDyes.java index 70b46ce..cb3a9e2 100644 --- a/src/main/java/net/minecraft/item/crafting/RecipesArmorDyes.java +++ b/src/main/java/net/minecraft/item/crafting/RecipesArmorDyes.java @@ -111,7 +111,7 @@ public class RecipesArmorDyes implements IRecipe { return null; } - float[] afloat = EntitySheep.func_175513_a(EnumDyeColor.byDyeDamage(itemstack1.getMetadata())); + float[] afloat = EntitySheep.getDyeRgb(EnumDyeColor.byDyeDamage(itemstack1.getMetadata())); int l1 = (int) (afloat[0] * 255.0F); int i2 = (int) (afloat[1] * 255.0F); int j2 = (int) (afloat[2] * 255.0F); diff --git a/src/main/java/net/minecraft/tileentity/TileEntity.java b/src/main/java/net/minecraft/tileentity/TileEntity.java index b1f9ea0..8a6771d 100644 --- a/src/main/java/net/minecraft/tileentity/TileEntity.java +++ b/src/main/java/net/minecraft/tileentity/TileEntity.java @@ -348,5 +348,6 @@ public abstract class TileEntity { addMapping(TileEntityComparator.class, "Comparator"); addMapping(TileEntityFlowerPot.class, "FlowerPot"); addMapping(TileEntityBanner.class, "Banner"); + addMapping(TileEntityEndGateway.class, "EndGateway"); } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityBeacon.java b/src/main/java/net/minecraft/tileentity/TileEntityBeacon.java index acc4c8f..57504dd 100644 --- a/src/main/java/net/minecraft/tileentity/TileEntityBeacon.java +++ b/src/main/java/net/minecraft/tileentity/TileEntityBeacon.java @@ -135,7 +135,7 @@ public class TileEntityBeacon extends TileEntityLockable implements ITickable, I this.beamSegments.clear(); this.isComplete = true; TileEntityBeacon.BeamSegment tileentitybeacon$beamsegment = new TileEntityBeacon.BeamSegment( - EntitySheep.func_175513_a(EnumDyeColor.WHITE)); + EntitySheep.getDyeRgb(EnumDyeColor.WHITE)); this.beamSegments.add(tileentitybeacon$beamsegment); boolean flag = true; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -144,7 +144,7 @@ public class TileEntityBeacon extends TileEntityLockable implements ITickable, I IBlockState iblockstate = this.worldObj.getBlockState(blockpos$mutableblockpos.func_181079_c(j, i1, l)); float[] afloat; if (iblockstate.getBlock() == Blocks.stained_glass) { - afloat = EntitySheep.func_175513_a((EnumDyeColor) iblockstate.getValue(BlockStainedGlass.COLOR)); + afloat = EntitySheep.getDyeRgb((EnumDyeColor) iblockstate.getValue(BlockStainedGlass.COLOR)); } else { if (iblockstate.getBlock() != Blocks.stained_glass_pane) { if (iblockstate.getBlock().getLightOpacity() >= 15 && iblockstate.getBlock() != Blocks.bedrock) { @@ -157,7 +157,7 @@ public class TileEntityBeacon extends TileEntityLockable implements ITickable, I continue; } - afloat = EntitySheep.func_175513_a((EnumDyeColor) iblockstate.getValue(BlockStainedGlassPane.COLOR)); + afloat = EntitySheep.getDyeRgb((EnumDyeColor) iblockstate.getValue(BlockStainedGlassPane.COLOR)); } if (!flag) { diff --git a/src/main/java/net/minecraft/tileentity/TileEntityEndGateway.java b/src/main/java/net/minecraft/tileentity/TileEntityEndGateway.java new file mode 100644 index 0000000..b9c6ad6 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityEndGateway.java @@ -0,0 +1,272 @@ +package net.minecraft.tileentity; + +import java.util.List; + +import javax.annotation.Nullable; + +import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; +import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; +import net.lax1dude.eaglercraft.v1_8.log4j.Logger; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ITickable; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraft.world.WorldProviderEnd; +import net.minecraft.world.chunk.Chunk; + +public class TileEntityEndGateway extends TileEntity implements ITickable { + private static final Logger LOG = LogManager.getLogger(); + private long age = 0L; + private int teleportCooldown = 0; + private BlockPos exitPortal; + private boolean exactTeleport; + + public void func_189515_b(NBTTagCompound p_189515_1_) { + super.writeToNBT(p_189515_1_); + p_189515_1_.setLong("Age", this.age); + + if (this.exitPortal != null) { + p_189515_1_.setTag("ExitPortal", NBTUtil.createPosTag(this.exitPortal)); + } + + if (this.exactTeleport) { + p_189515_1_.setBoolean("ExactTeleport", this.exactTeleport); + } + } + + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + this.age = compound.getLong("Age"); + + if (compound.hasKey("ExitPortal", 10)) { + this.exitPortal = NBTUtil.getPosFromTag(compound.getCompoundTag("ExitPortal")); + } + + this.exactTeleport = compound.getBoolean("ExactTeleport"); + } + + public double getMaxRenderDistanceSquared() { + return 65536.0D; + } + + public void update() { + boolean flag = this.isSpawning(); + boolean flag1 = this.isCoolingDown(); + ++this.age; + + if (flag1) { + --this.teleportCooldown; + } else if (!this.worldObj.isRemote) { + List list = this.worldObj.getEntitiesWithinAABB(Entity.class, + new AxisAlignedBB(this.getPos())); + + if (!list.isEmpty()) { + this.teleportEntity((Entity) list.get(0)); + } + } + + if (flag != this.isSpawning() || flag1 != this.isCoolingDown()) { + this.markDirty(); + } + } + + @Nullable + public S35PacketUpdateTileEntity getDescriptionPacket() { + return new S35PacketUpdateTileEntity(this.pos, 8, this.func_189517_E_()); + } + + public boolean isSpawning() { + return this.age < 200L; + } + + public boolean isCoolingDown() { + return this.teleportCooldown > 0; + } + + public float getSpawnPercent() { + return MathHelper.clamp_float((float) this.age / 200.0F, 0.0F, 1.0F); + } + + public float getCooldownPercent() { + return 1.0F - MathHelper.clamp_float((float) this.teleportCooldown / 20.0F, 0.0F, 1.0F); + } + + public void triggerCooldown() { + if (!this.worldObj.isRemote) { + this.teleportCooldown = 20; + this.worldObj.addBlockEvent(this.getPos(), this.getBlockType(), 1, 0); + this.markDirty(); + } + } + + public boolean receiveClientEvent(int id, int type) { + if (id == 1) { + this.teleportCooldown = 20; + return true; + } else { + return super.receiveClientEvent(id, type); + } + } + + public void teleportEntity(Entity entityIn) { + // TODO: Implement new end + // if (!this.worldObj.isRemote && !this.isCoolingDown()) { + // this.teleportCooldown = 100; + + // if (this.exitPortal == null && this.worldObj.provider instanceof + // WorldProviderEnd) { + // this.findExitPortal(); + // } + + // if (this.exitPortal != null) { + // BlockPos blockpos = this.exactTeleport ? this.exitPortal : + // this.findExitPosition(); + // entityIn.setPositionAndUpdate((double) blockpos.getX() + 0.5D, (double) + // blockpos.getY() + 0.5D, + // (double) blockpos.getZ() + 0.5D); + // } + + // this.triggerCooldown(); + // } + // } + } + + private BlockPos findExitPosition() { + // BlockPos blockpos = findHighestBlock(this.worldObj, this.exitPortal, 5, + // false); + // LOG.debug("Best exit position for portal at " + this.exitPortal + " is " + + // blockpos); + // return blockpos.up(); + return null; + } + + private void findExitPortal() { + // Vec3 vec3d = (new Vec3((double) this.getPos().getX(), 0.0D, (double) + // this.getPos().getZ())).normalize(); + // Vec3 vec3d1 = vec3d.scale(1024.0D); + + // for (int i = 16; getChunk(this.worldObj, vec3d1).getTopFilledSegment() > 0 + // && i-- > 0; vec3d1 = vec3d1.add(vec3d.scale(-16.0D))) { + // LOG.debug("Skipping backwards past nonempty chunk at " + vec3d1); + // } + + // for (int j = 16; getChunk(this.worldObj, vec3d1).getTopFilledSegment() == 0 + // && j-- > 0; vec3d1 = vec3d1.add(vec3d.scale(16.0D))) { + // LOG.debug("Skipping forward past empty chunk at " + vec3d1); + // } + + // LOG.debug("Found chunk at " + vec3d1); + // Chunk chunk = getChunk(this.worldObj, vec3d1); + // this.exitPortal = findSpawnpointInChunk(chunk); + + // if (this.exitPortal == null) { + // this.exitPortal = new BlockPos(vec3d1.xCoord + 0.5D, 75.0D, vec3d1.zCoord + + // 0.5D); + // LOG.debug("Failed to find suitable block, settling on " + this.exitPortal); + // (new WorldGenEndIsland()).generate(this.worldObj, new + // EaglercraftRandom(this.exitPortal.toLong()), + // this.exitPortal); + // } else { + // LOG.debug("Found block at " + this.exitPortal); + // } + + // this.exitPortal = findHighestBlock(this.worldObj, this.exitPortal, 16, true); + // LOG.debug("Creating portal at " + this.exitPortal); + // this.exitPortal = this.exitPortal.up(10); + // this.createExitPortal(this.exitPortal); + // this.markDirty(); + } + + private static BlockPos findHighestBlock(World p_184308_0_, BlockPos p_184308_1_, int p_184308_2_, + boolean p_184308_3_) { + BlockPos blockpos = null; + + for (int i = -p_184308_2_; i <= p_184308_2_; ++i) { + for (int j = -p_184308_2_; j <= p_184308_2_; ++j) { + if (i != 0 || j != 0 || p_184308_3_) { + for (int k = 255; k > (blockpos == null ? 0 : blockpos.getY()); --k) { + BlockPos blockpos1 = new BlockPos(p_184308_1_.getX() + i, k, p_184308_1_.getZ() + j); + IBlockState iblockstate = p_184308_0_.getBlockState(blockpos1); + + if (iblockstate.getBlock().isBlockNormalCube() + && (p_184308_3_ || iblockstate.getBlock() != Blocks.bedrock)) { + blockpos = blockpos1; + break; + } + } + } + } + } + + return blockpos == null ? p_184308_1_ : blockpos; + } + + private static Chunk getChunk(World worldIn, Vec3 vec3) { + return worldIn.getChunkFromChunkCoords(MathHelper.floor_double(vec3.xCoord / 16.0D), + MathHelper.floor_double(vec3.zCoord / 16.0D)); + } + + @Nullable + private static BlockPos findSpawnpointInChunk(Chunk chunkIn) { + BlockPos blockpos = new BlockPos(chunkIn.xPosition * 16, 30, chunkIn.zPosition * 16); + int i = chunkIn.getTopFilledSegment() + 16 - 1; + BlockPos blockpos1 = new BlockPos(chunkIn.xPosition * 16 + 16 - 1, i, chunkIn.zPosition * 16 + 16 - 1); + BlockPos blockpos2 = null; + double d0 = 0.0D; + + for (BlockPos blockpos3 : BlockPos.getAllInBox(blockpos, blockpos1)) { + IBlockState iblockstate = chunkIn.getBlockState(blockpos3); + + if (iblockstate.getBlock() == Blocks.end_stone + && !chunkIn.getBlockState(blockpos3.up(1)).getBlock().isBlockNormalCube() + && !chunkIn.getBlockState(blockpos3.up(2)).getBlock().isBlockNormalCube()) { + double d1 = blockpos3.distanceSqToCenter(0.0D, 0.0D, 0.0D); + + if (blockpos2 == null || d1 < d0) { + blockpos2 = blockpos3; + d0 = d1; + } + } + } + + return blockpos2; + } + + private void createExitPortal(BlockPos posIn) { + // (new WorldGenEndGateway()).generate(this.worldObj, new Random(), posIn); + // TileEntity tileentity = this.worldObj.getTileEntity(posIn); + + // if (tileentity instanceof TileEntityEndGateway) { + // TileEntityEndGateway tileentityendgateway = (TileEntityEndGateway) + // tileentity; + // tileentityendgateway.exitPortal = new BlockPos(this.getPos()); + // tileentityendgateway.markDirty(); + // } else { + // LOG.warn("Couldn\'t save exit portal at " + posIn); + // } + } + + public boolean shouldRenderFace(EnumFacing p_184313_1_) { + return this.getBlockType().getDefaultState().getBlock().shouldSideBeRendered(this.worldObj, this.getPos(), + p_184313_1_); + } + + public int getParticleAmount() { + int i = 0; + + for (EnumFacing enumfacing : EnumFacing.values()) { + i += this.shouldRenderFace(enumfacing) ? 1 : 0; + } + + return i; + } +} diff --git a/src/main/java/net/minecraft/util/AxisAlignedBB.java b/src/main/java/net/minecraft/util/AxisAlignedBB.java index 6e40e79..e33eb14 100644 --- a/src/main/java/net/minecraft/util/AxisAlignedBB.java +++ b/src/main/java/net/minecraft/util/AxisAlignedBB.java @@ -55,6 +55,11 @@ public class AxisAlignedBB { this.maxZ = (double) pos2.getZ(); } + public AxisAlignedBB(BlockPos pos) { + this((double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), (double) (pos.getX() + 1), + (double) (pos.getY() + 1), (double) (pos.getZ() + 1)); + } + /** * + * Adds the coordinates to the bounding box extending it if the @@ -137,6 +142,12 @@ public class AxisAlignedBB { this.maxZ + z); } + public AxisAlignedBB offset(BlockPos pos) { + return new AxisAlignedBB(this.minX + (double) pos.getX(), this.minY + (double) pos.getY(), + this.minZ + (double) pos.getZ(), this.maxX + (double) pos.getX(), this.maxY + (double) pos.getY(), + this.maxZ + (double) pos.getZ()); + } + /** * + * if instance and the argument bounding boxes overlap in the Y diff --git a/src/main/java/net/minecraft/util/MathHelper.java b/src/main/java/net/minecraft/util/MathHelper.java index 76b9863..1cdcdfe 100644 --- a/src/main/java/net/minecraft/util/MathHelper.java +++ b/src/main/java/net/minecraft/util/MathHelper.java @@ -151,6 +151,10 @@ public class MathHelper { return (int) FastMath.floor(value); } + public static double frac(double number) { + return number - Math.floor(number); + } + /** * + * Long version of floor_double diff --git a/src/main/java/net/minecraft/util/Vec3.java b/src/main/java/net/minecraft/util/Vec3.java index c84c006..566dd56 100644 --- a/src/main/java/net/minecraft/util/Vec3.java +++ b/src/main/java/net/minecraft/util/Vec3.java @@ -113,6 +113,10 @@ public class Vec3 { return new Vec3(this.xCoord + x, this.yCoord + y, this.zCoord + z); } + public Vec3 scale(double p_186678_1_) { + return new Vec3(this.xCoord * p_186678_1_, this.yCoord * p_186678_1_, this.zCoord * p_186678_1_); + } + /** * + * Euclidean distance between this and the specified vector, diff --git a/src/main/java/net/minecraft/world/World.java b/src/main/java/net/minecraft/world/World.java index 4c707ff..d77238d 100644 --- a/src/main/java/net/minecraft/world/World.java +++ b/src/main/java/net/minecraft/world/World.java @@ -869,6 +869,12 @@ public abstract class World implements IBlockAccess, ILightingEngineProvider, IL soundIn, volume, pitch); } + public void playSound(BlockPos pos, SoundEvent soundIn, SoundCategory category, float volume, float pitch, + boolean distanceDelay) { + this.playSound((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, soundIn, + category, volume, pitch, distanceDelay); + } + /** * + * Plays sound to all near players except the player reference