diff --git a/javascript/index.html b/javascript/index.html index 694b43c..5d283e9 100644 --- a/javascript/index.html +++ b/javascript/index.html @@ -3,12 +3,12 @@ - - - EaglercraftX 1.8 + + + EaglercraftL 1.9 - + diff --git a/resources/resources/assets/eagler/CREDITS.txt b/resources/resources/assets/eagler/CREDITS.txt index 7003da2..fdc0906 100644 --- a/resources/resources/assets/eagler/CREDITS.txt +++ b/resources/resources/assets/eagler/CREDITS.txt @@ -26,7 +26,7 @@ - Created the replit hoosiertransfer: - + - Ported 1.9 features to 1.8 - Many memory optimizations - Bug fixes - Faster lighting engine diff --git a/resources/resources/assets/minecraft/blockstates/chain_command_block.json b/resources/resources/assets/minecraft/blockstates/chain_command_block.json new file mode 100644 index 0000000..3561265 --- /dev/null +++ b/resources/resources/assets/minecraft/blockstates/chain_command_block.json @@ -0,0 +1,16 @@ +{ + "variants": { + "conditional=false,facing=down": { "model": "chain_command_block", "x": 90 }, + "conditional=false,facing=up": { "model": "chain_command_block", "x": 270 }, + "conditional=false,facing=north": { "model": "chain_command_block" }, + "conditional=false,facing=south": { "model": "chain_command_block", "y": 180 }, + "conditional=false,facing=west": { "model": "chain_command_block", "y": 270 }, + "conditional=false,facing=east": { "model": "chain_command_block", "y": 90 }, + "conditional=true,facing=down": { "model": "chain_command_block_conditional", "x": 90 }, + "conditional=true,facing=up": { "model": "chain_command_block_conditional", "x": 270 }, + "conditional=true,facing=north": { "model": "chain_command_block_conditional" }, + "conditional=true,facing=south": { "model": "chain_command_block_conditional", "y": 180 }, + "conditional=true,facing=west": { "model": "chain_command_block_conditional", "y": 270 }, + "conditional=true,facing=east": { "model": "chain_command_block_conditional", "y": 90 } + } +} diff --git a/resources/resources/assets/minecraft/blockstates/command_block.json b/resources/resources/assets/minecraft/blockstates/command_block.json index 3becb01..2145125 100644 --- a/resources/resources/assets/minecraft/blockstates/command_block.json +++ b/resources/resources/assets/minecraft/blockstates/command_block.json @@ -1,5 +1,16 @@ { "variants": { - "normal": { "model": "command_block" } + "conditional=false,facing=down": { "model": "command_block", "x": 90 }, + "conditional=false,facing=up": { "model": "command_block", "x": 270 }, + "conditional=false,facing=north": { "model": "command_block" }, + "conditional=false,facing=south": { "model": "command_block", "y": 180 }, + "conditional=false,facing=west": { "model": "command_block", "y": 270 }, + "conditional=false,facing=east": { "model": "command_block", "y": 90 }, + "conditional=true,facing=down": { "model": "command_block_conditional", "x": 90 }, + "conditional=true,facing=up": { "model": "command_block_conditional", "x": 270 }, + "conditional=true,facing=north": { "model": "command_block_conditional" }, + "conditional=true,facing=south": { "model": "command_block_conditional", "y": 180 }, + "conditional=true,facing=west": { "model": "command_block_conditional", "y": 270 }, + "conditional=true,facing=east": { "model": "command_block_conditional", "y": 90 } } } diff --git a/resources/resources/assets/minecraft/blockstates/repeating_command_block.json b/resources/resources/assets/minecraft/blockstates/repeating_command_block.json new file mode 100644 index 0000000..ba9da59 --- /dev/null +++ b/resources/resources/assets/minecraft/blockstates/repeating_command_block.json @@ -0,0 +1,16 @@ +{ + "variants": { + "conditional=false,facing=down": { "model": "repeating_command_block", "x": 90 }, + "conditional=false,facing=up": { "model": "repeating_command_block", "x": 270 }, + "conditional=false,facing=north": { "model": "repeating_command_block" }, + "conditional=false,facing=south": { "model": "repeating_command_block", "y": 180 }, + "conditional=false,facing=west": { "model": "repeating_command_block", "y": 270 }, + "conditional=false,facing=east": { "model": "repeating_command_block", "y": 90 }, + "conditional=true,facing=down": { "model": "repeating_command_block_conditional", "x": 90 }, + "conditional=true,facing=up": { "model": "repeating_command_block_conditional", "x": 270 }, + "conditional=true,facing=north": { "model": "repeating_command_block_conditional" }, + "conditional=true,facing=south": { "model": "repeating_command_block_conditional", "y": 180 }, + "conditional=true,facing=west": { "model": "repeating_command_block_conditional", "y": 270 }, + "conditional=true,facing=east": { "model": "repeating_command_block_conditional", "y": 90 } + } +} diff --git a/resources/resources/assets/minecraft/lang/en_US.lang b/resources/resources/assets/minecraft/lang/en_US.lang index fcdda89..4cc102a 100644 --- a/resources/resources/assets/minecraft/lang/en_US.lang +++ b/resources/resources/assets/minecraft/lang/en_US.lang @@ -1322,7 +1322,6 @@ tile.blockEmerald.name=Block of Emerald tile.blockRedstone.name=Block of Redstone tile.tripWire.name=Tripwire tile.tripWireSource.name=Tripwire Hook -tile.commandBlock.name=Command Block tile.beacon.name=Beacon tile.beacon.primary=Primary Power tile.beacon.secondary=Secondary Power @@ -1920,6 +1919,7 @@ stat.minecartOneCm=Distance by Minecart stat.boatOneCm=Distance by Boat stat.pigOneCm=Distance by Pig stat.horseOneCm=Distance by Horse +stat.aviateOneCm=Distance by Elytra stat.jump=Jumps stat.drop=Items Dropped @@ -3183,19 +3183,41 @@ item.banner.straight_cross.white=White Cross tile.purpurBlock.name=Purpur Block tile.purpurPillar.name=Purpur Pillar -tile.purpurStairs.name=Purpur Stairs +tile.stairsPurpur.name=Purpur Stairs tile.purpurSlab.name=Purpur Slab tile.purpurSlab.default.name=Purpur Slab -tile.purpurStairs.name=Purpur Stairs tile.endRod.name=End Rod tile.chorusPlant.name=Chorus Plant tile.chorusFlower.name=Chorus Flower tile.grassPath.name=Grass Path tile.endBricks.name=End Stone Bricks +tile.commandBlock.name=Command Block +tile.repeatingCommandBlock.name=Repeating Command Block +tile.chainCommandBlock.name=Chain Command Block item.chorusFruit.name=Chorus Fruit item.chorusFruitPopped.name=Popped Chorus Fruit item.beetroot.name=Beetroot item.beetroot_seeds.name=Beetroot Seeds item.beetroot_soup.name=Beetroot Soup -item.elytra.name=Elytra \ No newline at end of file +item.elytra.name=Elytra +item.end_crystal.name=End Crystal + +advMode.setCommand=Set Console Command for Block +advMode.setCommand.success=Command set: %s +advMode.command=Console Command +advMode.nearestPlayer=Use "@p" to target nearest player +advMode.randomPlayer=Use "@r" to target random player +advMode.allPlayers=Use "@a" to target all players +advMode.allEntities=Use "@e" to target all entities +advMode.previousOutput=Previous Output +advMode.mode.sequence=Chain +advMode.mode.auto=Repeat +advMode.mode.redstone=Impulse +advMode.mode.conditional=Conditional +advMode.mode.unconditional=Unconditional +advMode.mode.redstoneTriggered=Needs Redstone +advMode.mode.autoexec.bat=Always Active + +advMode.notEnabled=Command blocks are not enabled on this server +advMode.notAllowed=Must be an opped player in creative mode \ No newline at end of file diff --git a/resources/resources/assets/minecraft/models/block/chain_command_block.json b/resources/resources/assets/minecraft/models/block/chain_command_block.json new file mode 100644 index 0000000..67b0b0b --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chain_command_block.json @@ -0,0 +1,12 @@ +{ + "parent": "block/cube_directional", + "textures": { + "particle": "blocks/chain_command_block_back", + "down": "blocks/chain_command_block_side", + "up": "blocks/chain_command_block_side", + "north": "blocks/chain_command_block_front", + "east": "blocks/chain_command_block_side", + "south": "blocks/chain_command_block_back", + "west": "blocks/chain_command_block_side" + } +} diff --git a/resources/resources/assets/minecraft/models/block/chain_command_block_conditional.json b/resources/resources/assets/minecraft/models/block/chain_command_block_conditional.json new file mode 100644 index 0000000..0488df2 --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/chain_command_block_conditional.json @@ -0,0 +1,12 @@ +{ + "parent": "block/cube_directional", + "textures": { + "particle": "blocks/chain_command_block_back", + "down": "blocks/chain_command_block_conditional", + "up": "blocks/chain_command_block_conditional", + "north": "blocks/chain_command_block_front", + "east": "blocks/chain_command_block_conditional", + "south": "blocks/chain_command_block_back", + "west": "blocks/chain_command_block_conditional" + } +} diff --git a/resources/resources/assets/minecraft/models/block/command_block.json b/resources/resources/assets/minecraft/models/block/command_block.json index 7eae209..a375547 100644 --- a/resources/resources/assets/minecraft/models/block/command_block.json +++ b/resources/resources/assets/minecraft/models/block/command_block.json @@ -1,6 +1,12 @@ { - "parent": "block/cube_all", + "parent": "block/cube_directional", "textures": { - "all": "blocks/command_block" + "particle": "blocks/command_block_back", + "down": "blocks/command_block_side", + "up": "blocks/command_block_side", + "north": "blocks/command_block_front", + "east": "blocks/command_block_side", + "south": "blocks/command_block_back", + "west": "blocks/command_block_side" } } diff --git a/resources/resources/assets/minecraft/models/block/command_block_conditional.json b/resources/resources/assets/minecraft/models/block/command_block_conditional.json new file mode 100644 index 0000000..1639f2e --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/command_block_conditional.json @@ -0,0 +1,12 @@ +{ + "parent": "block/cube_directional", + "textures": { + "particle": "blocks/command_block_back", + "down": "blocks/command_block_conditional", + "up": "blocks/command_block_conditional", + "north": "blocks/command_block_front", + "east": "blocks/command_block_conditional", + "south": "blocks/command_block_back", + "west": "blocks/command_block_conditional" + } +} diff --git a/resources/resources/assets/minecraft/models/block/cube_directional.json b/resources/resources/assets/minecraft/models/block/cube_directional.json new file mode 100644 index 0000000..4f28de1 --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/cube_directional.json @@ -0,0 +1,15 @@ +{ + "elements": [ + { "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "texture": "#down", "cullface": "down", "rotation": 180 }, + "up": { "texture": "#up", "cullface": "up" }, + "north": { "texture": "#north", "cullface": "north" }, + "south": { "texture": "#south", "cullface": "south" }, + "west": { "texture": "#west", "cullface": "west", "rotation": 270 }, + "east": { "texture": "#east", "cullface": "east", "rotation": 90 } + } + } + ] +} diff --git a/resources/resources/assets/minecraft/models/block/repeating_command_block.json b/resources/resources/assets/minecraft/models/block/repeating_command_block.json new file mode 100644 index 0000000..5ea677e --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/repeating_command_block.json @@ -0,0 +1,12 @@ +{ + "parent": "block/cube_directional", + "textures": { + "particle": "blocks/repeating_command_block_back", + "down": "blocks/repeating_command_block_side", + "up": "blocks/repeating_command_block_side", + "north": "blocks/repeating_command_block_front", + "east": "blocks/repeating_command_block_side", + "south": "blocks/repeating_command_block_back", + "west": "blocks/repeating_command_block_side" + } +} diff --git a/resources/resources/assets/minecraft/models/block/repeating_command_block_conditional.json b/resources/resources/assets/minecraft/models/block/repeating_command_block_conditional.json new file mode 100644 index 0000000..4d1f6dd --- /dev/null +++ b/resources/resources/assets/minecraft/models/block/repeating_command_block_conditional.json @@ -0,0 +1,12 @@ +{ + "parent": "block/cube_directional", + "textures": { + "particle": "blocks/repeating_command_block_back", + "down": "blocks/repeating_command_block_conditional", + "up": "blocks/repeating_command_block_conditional", + "north": "blocks/repeating_command_block_front", + "east": "blocks/repeating_command_block_conditional", + "south": "blocks/repeating_command_block_back", + "west": "blocks/repeating_command_block_conditional" + } +} diff --git a/resources/resources/assets/minecraft/models/item/chain_command_block.json b/resources/resources/assets/minecraft/models/item/chain_command_block.json new file mode 100644 index 0000000..eea6e6e --- /dev/null +++ b/resources/resources/assets/minecraft/models/item/chain_command_block.json @@ -0,0 +1,10 @@ +{ + "parent": "block/chain_command_block", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} diff --git a/resources/resources/assets/minecraft/models/item/end_crystal.json b/resources/resources/assets/minecraft/models/item/end_crystal.json new file mode 100644 index 0000000..64f9dbd --- /dev/null +++ b/resources/resources/assets/minecraft/models/item/end_crystal.json @@ -0,0 +1,18 @@ +{ + "parent": "builtin/generated", + "textures": { + "layer0": "items/end_crystal" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} diff --git a/resources/resources/assets/minecraft/models/item/repeating_command_block.json b/resources/resources/assets/minecraft/models/item/repeating_command_block.json new file mode 100644 index 0000000..8e1f6b5 --- /dev/null +++ b/resources/resources/assets/minecraft/models/item/repeating_command_block.json @@ -0,0 +1,10 @@ +{ + "parent": "block/repeating_command_block", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/chain_command_block_back.png b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_back.png new file mode 100644 index 0000000..9b75681 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_back.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_back.png.mcmeta similarity index 100% rename from resources/resources/assets/minecraft/textures/blocks/command_block.png.mcmeta rename to resources/resources/assets/minecraft/textures/blocks/chain_command_block_back.png.mcmeta diff --git a/resources/resources/assets/minecraft/textures/blocks/chain_command_block_conditional.png b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_conditional.png new file mode 100644 index 0000000..2fdbccc Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_conditional.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/chain_command_block_conditional.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_conditional.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_conditional.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/chain_command_block_front.png b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_front.png new file mode 100644 index 0000000..ae2fb4f Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_front.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/chain_command_block_front.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_front.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/chain_command_block_side.png b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_side.png new file mode 100644 index 0000000..53958f2 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_side.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/chain_command_block_side.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_side.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/chain_command_block_side.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block.png b/resources/resources/assets/minecraft/textures/blocks/command_block.png deleted file mode 100644 index 3860089..0000000 Binary files a/resources/resources/assets/minecraft/textures/blocks/command_block.png and /dev/null differ diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block_back.png b/resources/resources/assets/minecraft/textures/blocks/command_block_back.png new file mode 100644 index 0000000..5b8daac Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/command_block_back.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block_back.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/command_block_back.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/command_block_back.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block_conditional.png b/resources/resources/assets/minecraft/textures/blocks/command_block_conditional.png new file mode 100644 index 0000000..fc12d69 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/command_block_conditional.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block_conditional.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/command_block_conditional.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/command_block_conditional.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block_front.png b/resources/resources/assets/minecraft/textures/blocks/command_block_front.png new file mode 100644 index 0000000..ed408e5 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/command_block_front.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block_front.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/command_block_front.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/command_block_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block_side.png b/resources/resources/assets/minecraft/textures/blocks/command_block_side.png new file mode 100644 index 0000000..0c4ec83 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/command_block_side.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/command_block_side.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/command_block_side.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/command_block_side.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_back.png b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_back.png new file mode 100644 index 0000000..6ae0009 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_back.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_back.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_back.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_back.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_conditional.png b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_conditional.png new file mode 100644 index 0000000..e625cfe Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_conditional.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_conditional.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_conditional.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_conditional.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_front.png b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_front.png new file mode 100644 index 0000000..c26b9a3 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_front.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_front.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_front.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_front.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_side.png b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_side.png new file mode 100644 index 0000000..6db7828 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_side.png differ diff --git a/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_side.png.mcmeta b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_side.png.mcmeta new file mode 100644 index 0000000..4894b53 --- /dev/null +++ b/resources/resources/assets/minecraft/textures/blocks/repeating_command_block_side.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 10 + } +} diff --git a/resources/resources/assets/minecraft/textures/items/end_crystal.png b/resources/resources/assets/minecraft/textures/items/end_crystal.png new file mode 100644 index 0000000..b1d0d14 Binary files /dev/null and b/resources/resources/assets/minecraft/textures/items/end_crystal.png differ diff --git a/src/main/java/net/minecraft/block/Block.java b/src/main/java/net/minecraft/block/Block.java index 88d52d6..f95e143 100644 --- a/src/main/java/net/minecraft/block/Block.java +++ b/src/main/java/net/minecraft/block/Block.java @@ -366,8 +366,8 @@ public class Block implements ILitBlock { return true; } - public boolean isFullyOpaque(IBlockState state) { - return state.getBlock().getMaterial().isOpaque() && state.getBlock().isFullCube(); + public boolean isFullyOpaque(IBlockState state) { + return state.getBlock().getMaterial().isOpaque() && state.getBlock().isFullCube(); } public boolean isPassable(IBlockAccess var1, BlockPos var2) { @@ -1234,7 +1234,8 @@ public class Block implements ILitBlock { registerBlock(6, (String) "sapling", (new BlockSapling()).setHardness(0.0F).setStepSound(soundTypeGrass).setUnlocalizedName("sapling")); registerBlock(7, (String) "bedrock", - (new BlockEmptyDrops(Material.rock)).setBlockUnbreakable().setResistance(6000000.0F).setStepSound(soundTypePiston) + (new BlockEmptyDrops(Material.rock)).setBlockUnbreakable().setResistance(6000000.0F) + .setStepSound(soundTypePiston) .setUnlocalizedName("bedrock").disableStats().setCreativeTab(CreativeTabs.tabBlock)); registerBlock(8, (String) "flowing_water", (new BlockDynamicLiquid(Material.water)).setHardness(100.0F) .setLightOpacity(3).setUnlocalizedName("water").disableStats()); @@ -1521,7 +1522,7 @@ public class Block implements ILitBlock { (new BlockStairs( block1.getDefaultState().withProperty(BlockPlanks.VARIANT, BlockPlanks.EnumType.JUNGLE))) .setUnlocalizedName("stairsWoodJungle")); - registerBlock(137, (String) "command_block", (new BlockCommandBlock()).setBlockUnbreakable() + registerBlock(137, (String) "command_block", (new BlockCommandBlock(MapColor.brownColor)).setBlockUnbreakable() .setResistance(6000000.0F).setUnlocalizedName("commandBlock")); registerBlock(138, (String) "beacon", (new BlockBeacon()).setUnlocalizedName("beacon").setLightLevel(1.0F)); registerBlock(139, (String) "cobblestone_wall", (new BlockWall(block)).setUnlocalizedName("cobbleWall")); @@ -1690,6 +1691,14 @@ public class Block implements ILitBlock { .setUnlocalizedName("grassPath").disableStats(); registerEaglerBlock(208, "grass_path", grassPath); + registerEaglerBlock(210, "repeating_command_block", + (new BlockCommandBlock(MapColor.purpleColor)).setBlockUnbreakable() + .setResistance(6000000.0F).setUnlocalizedName("repeatingCommandBlock")); + + registerEaglerBlock(211, "chain_command_block", + (new BlockCommandBlock(MapColor.greenColor)).setBlockUnbreakable() + .setResistance(6000000.0F).setUnlocalizedName("chainCommandBlock")); + registerEaglerBlock(212, "frosted_ice", (new BlockFrostedIce()).setHardness(0.5F).setLightOpacity(3) .setStepSound(soundTypeGlass).setUnlocalizedName("frostedIce"), false); diff --git a/src/main/java/net/minecraft/block/BlockCommandBlock.java b/src/main/java/net/minecraft/block/BlockCommandBlock.java index 4e1326d..20c2b7d 100644 --- a/src/main/java/net/minecraft/block/BlockCommandBlock.java +++ b/src/main/java/net/minecraft/block/BlockCommandBlock.java @@ -1,21 +1,26 @@ package net.minecraft.block; +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.properties.IProperty; import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; -import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.command.server.CommandBlockBaseLogic; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.StringUtils; import net.minecraft.world.World; /** @@ -48,11 +53,19 @@ import net.minecraft.world.World; * */ public class BlockCommandBlock extends BlockContainer { - public static final PropertyBool TRIGGERED = PropertyBool.create("triggered"); + public static final PropertyDirection FACING = PropertyDirection.create("facing"); + public static final PropertyBool CONDITIONAL = PropertyBool.create("conditional"); public BlockCommandBlock() { super(Material.iron, MapColor.adobeColor); - this.setDefaultState(this.blockState.getBaseState().withProperty(TRIGGERED, Boolean.valueOf(false))); + this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH) + .withProperty(CONDITIONAL, Boolean.valueOf(false))); + } + + public BlockCommandBlock(MapColor color) { + super(Material.iron, color); + this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH) + .withProperty(CONDITIONAL, Boolean.valueOf(false))); } /** @@ -60,8 +73,10 @@ public class BlockCommandBlock extends BlockContainer { * Returns a new instance of a block's tile entity class. Called * on placing the block. */ - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileEntityCommandBlock(); + public TileEntity createNewTileEntity(World worldIn, int meta) { + TileEntityCommandBlock tileentitycommandblock = new TileEntityCommandBlock(); + tileentitycommandblock.setAuto(this == EaglerItems.getEaglerBlock("chain_command_block")); + return tileentitycommandblock; } /** @@ -70,24 +85,87 @@ public class BlockCommandBlock extends BlockContainer { */ public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState iblockstate, Block var4) { if (!world.isRemote) { - boolean flag = world.isBlockPowered(blockpos); - boolean flag1 = ((Boolean) iblockstate.getValue(TRIGGERED)).booleanValue(); - if (flag && !flag1) { - world.setBlockState(blockpos, iblockstate.withProperty(TRIGGERED, Boolean.valueOf(true)), 4); - world.scheduleUpdate(blockpos, this, this.tickRate(world)); - } else if (!flag && flag1) { - world.setBlockState(blockpos, iblockstate.withProperty(TRIGGERED, Boolean.valueOf(false)), 4); + TileEntity tileentity = world.getTileEntity(blockpos); + + if (tileentity instanceof TileEntityCommandBlock) { + TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock) tileentity; + boolean flag = world.isBlockPowered(blockpos); + boolean flag1 = tileentitycommandblock.isPowered(); + boolean flag2 = tileentitycommandblock.isAuto(); + + if (flag && !flag1) { + tileentitycommandblock.setPowered(true); + + if (tileentitycommandblock.getMode() != TileEntityCommandBlock.Mode.SEQUENCE && !flag2) { + boolean flag3 = !tileentitycommandblock.isConditional() + || this.isNextToSuccessfulCommandBlock(world, blockpos, iblockstate); + tileentitycommandblock.setConditionMet(flag3); + world.scheduleUpdate(blockpos, this, this.tickRate(world)); + + if (flag3) { + this.propagateUpdate(world, blockpos); + } + } + } else if (!flag && flag1) { + tileentitycommandblock.setPowered(false); + } } } } - public void updateTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom var4) { - TileEntity tileentity = world.getTileEntity(blockpos); - if (tileentity instanceof TileEntityCommandBlock) { - ((TileEntityCommandBlock) tileentity).getCommandBlockLogic().trigger(world); - world.updateComparatorOutputLevel(blockpos, this); - } + public void updateTick(World worldIn, BlockPos pos, IBlockState state, EaglercraftRandom rand) { + if (!worldIn.isRemote) { + TileEntity tileentity = worldIn.getTileEntity(pos); + if (tileentity instanceof TileEntityCommandBlock) { + TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock) tileentity; + CommandBlockBaseLogic commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic(); + boolean flag = !StringUtils.isNullOrEmpty(commandblockbaselogic.getCommand()); + TileEntityCommandBlock.Mode tileentitycommandblock$mode = tileentitycommandblock.getMode(); + boolean flag1 = !tileentitycommandblock.isConditional() + || this.isNextToSuccessfulCommandBlock(worldIn, pos, state); + boolean flag2 = tileentitycommandblock.isConditionMet(); + boolean flag3 = false; + + if (tileentitycommandblock$mode != TileEntityCommandBlock.Mode.SEQUENCE && flag2 && flag) { + commandblockbaselogic.trigger(worldIn); + flag3 = true; + } + + if (tileentitycommandblock.isPowered() || tileentitycommandblock.isAuto()) { + if (tileentitycommandblock$mode == TileEntityCommandBlock.Mode.SEQUENCE && flag1 && flag) { + commandblockbaselogic.trigger(worldIn); + flag3 = true; + } + + if (tileentitycommandblock$mode == TileEntityCommandBlock.Mode.AUTO) { + worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); + + if (flag1) { + this.propagateUpdate(worldIn, pos); + } + } + } + + if (!flag3) { + commandblockbaselogic.setSuccessCount(0); + } + + tileentitycommandblock.setConditionMet(flag1); + worldIn.updateComparatorOutputLevel(pos, this); + } + } + } + + /** + * Checks whether the command block at a given position is adjacent to another + * one that executed successfully. + */ + public boolean isNextToSuccessfulCommandBlock(World worldIn, BlockPos pos, IBlockState state) { + EnumFacing enumfacing = (EnumFacing) state.getValue(FACING); + TileEntity tileentity = worldIn.getTileEntity(pos.offset(enumfacing.getOpposite())); + return tileentity instanceof TileEntityCommandBlock + && ((TileEntityCommandBlock) tileentity).getCommandBlockLogic().getSuccessCount() > 0; } /** @@ -101,9 +179,17 @@ public class BlockCommandBlock extends BlockContainer { public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer, EnumFacing var5, float var6, float var7, float var8) { TileEntity tileentity = world.getTileEntity(blockpos); - return tileentity instanceof TileEntityCommandBlock - ? ((TileEntityCommandBlock) tileentity).getCommandBlockLogic().tryOpenEditCommandBlock(entityplayer) - : false; + + if (tileentity instanceof TileEntityCommandBlock) { + if (!entityplayer.capabilities.isCreativeMode) { + return false; + } else { + entityplayer.displayGuiCommandBlock((TileEntityCommandBlock) tileentity); + return true; + } + } else { + return false; + } } public boolean hasComparatorInputOverride() { @@ -125,14 +211,27 @@ public class BlockCommandBlock extends BlockContainer { public void onBlockPlacedBy(World world, BlockPos blockpos, IBlockState var3, EntityLivingBase var4, ItemStack itemstack) { TileEntity tileentity = world.getTileEntity(blockpos); + if (tileentity instanceof TileEntityCommandBlock) { - CommandBlockLogic commandblocklogic = ((TileEntityCommandBlock) tileentity).getCommandBlockLogic(); + TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock) tileentity; + CommandBlockBaseLogic commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic(); + if (itemstack.hasDisplayName()) { - commandblocklogic.setName(itemstack.getDisplayName()); + commandblockbaselogic.setName(itemstack.getDisplayName()); } if (!world.isRemote) { - commandblocklogic.setTrackOutput(world.getGameRules().getBoolean("sendCommandFeedback")); + NBTTagCompound nbttagcompound = itemstack.getTagCompound(); + + if (nbttagcompound == null || !nbttagcompound.hasKey("BlockEntityTag", 10)) { + commandblockbaselogic.setTrackOutput(world.getGameRules().getBoolean("sendCommandFeedback")); + tileentitycommandblock.setAuto(this == EaglerItems.getEaglerBlock("chain_command_block")); + } + + if (tileentitycommandblock.getMode() == TileEntityCommandBlock.Mode.SEQUENCE) { + boolean flag = world.isBlockPowered(blockpos); + tileentitycommandblock.setPowered(flag); + } } } } @@ -158,25 +257,22 @@ public class BlockCommandBlock extends BlockContainer { * + * Convert the given metadata into a BlockState for this Block */ - public IBlockState getStateFromMeta(int i) { - return this.getDefaultState().withProperty(TRIGGERED, Boolean.valueOf((i & 1) > 0)); + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta & 7)).withProperty(CONDITIONAL, + Boolean.valueOf((meta & 8) != 0)); } /** * + * Convert the BlockState into the correct metadata value */ - public int getMetaFromState(IBlockState iblockstate) { - int i = 0; - if (((Boolean) iblockstate.getValue(TRIGGERED)).booleanValue()) { - i |= 1; - } - - return i; + public int getMetaFromState(IBlockState state) { + return ((EnumFacing) state.getValue(FACING)).getIndex() + | (((Boolean) state.getValue(CONDITIONAL)).booleanValue() ? 8 : 0); } protected BlockState createBlockState() { - return new BlockState(this, new IProperty[] { TRIGGERED }); + return new BlockState(this, new IProperty[] { FACING, CONDITIONAL }); } /** @@ -186,6 +282,38 @@ public class BlockCommandBlock extends BlockContainer { */ public IBlockState onBlockPlaced(World var1, BlockPos var2, EnumFacing var3, float var4, float var5, float var6, int var7, EntityLivingBase var8) { - return this.getDefaultState().withProperty(TRIGGERED, Boolean.valueOf(false)); + return this.getDefaultState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(var2, var8)) + .withProperty(CONDITIONAL, Boolean.valueOf(false)); + } + + public void propagateUpdate(World worldIn, BlockPos pos) { + IBlockState iblockstate = worldIn.getBlockState(pos); + + if (iblockstate.getBlock() == Blocks.command_block + || iblockstate.getBlock() == EaglerItems.getEaglerBlock("repeating_command_block")) { + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(pos); + blockpos$mutableblockpos.move((EnumFacing) iblockstate.getValue(FACING)); + + for (TileEntity tileentity = worldIn.getTileEntity( + blockpos$mutableblockpos); tileentity instanceof TileEntityCommandBlock; tileentity = worldIn + .getTileEntity(blockpos$mutableblockpos)) { + TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock) tileentity; + + if (tileentitycommandblock.getMode() != TileEntityCommandBlock.Mode.SEQUENCE) { + break; + } + + IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos); + Block block = iblockstate1.getBlock(); + + if (block != EaglerItems.getEaglerBlock("chain_command_block") + || worldIn.isUpdateScheduled(blockpos$mutableblockpos, block)) { + break; + } + + worldIn.scheduleUpdate(new BlockPos(blockpos$mutableblockpos), block, this.tickRate(worldIn)); + blockpos$mutableblockpos.move((EnumFacing) iblockstate1.getValue(FACING)); + } + } } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDispenser.java b/src/main/java/net/minecraft/block/BlockDispenser.java index 6179c66..ff64d9e 100644 --- a/src/main/java/net/minecraft/block/BlockDispenser.java +++ b/src/main/java/net/minecraft/block/BlockDispenser.java @@ -187,7 +187,7 @@ public class BlockDispenser extends BlockContainer { public IBlockState onBlockPlaced(World world, BlockPos blockpos, EnumFacing var3, float var4, float var5, float var6, int var7, EntityLivingBase entitylivingbase) { return this.getDefaultState() - .withProperty(FACING, BlockPistonBase.getFacingFromEntity(world, blockpos, entitylivingbase)) + .withProperty(FACING, BlockPistonBase.getFacingFromEntity(blockpos, entitylivingbase)) .withProperty(TRIGGERED, Boolean.valueOf(false)); } @@ -199,7 +199,7 @@ public class BlockDispenser extends BlockContainer { public void onBlockPlacedBy(World world, BlockPos blockpos, IBlockState iblockstate, EntityLivingBase entitylivingbase, ItemStack itemstack) { world.setBlockState(blockpos, iblockstate.withProperty(FACING, - BlockPistonBase.getFacingFromEntity(world, blockpos, entitylivingbase)), 2); + BlockPistonBase.getFacingFromEntity(blockpos, entitylivingbase)), 2); if (itemstack.hasDisplayName()) { TileEntity tileentity = world.getTileEntity(blockpos); if (tileentity instanceof TileEntityDispenser) { diff --git a/src/main/java/net/minecraft/block/BlockPistonBase.java b/src/main/java/net/minecraft/block/BlockPistonBase.java index 3db3f79..df6d74c 100644 --- a/src/main/java/net/minecraft/block/BlockPistonBase.java +++ b/src/main/java/net/minecraft/block/BlockPistonBase.java @@ -84,7 +84,7 @@ public class BlockPistonBase extends Block { public void onBlockPlacedBy(World world, BlockPos blockpos, IBlockState iblockstate, EntityLivingBase entitylivingbase, ItemStack var5) { world.setBlockState(blockpos, - iblockstate.withProperty(FACING, getFacingFromEntity(world, blockpos, entitylivingbase)), 2); + iblockstate.withProperty(FACING, getFacingFromEntity(blockpos, entitylivingbase)), 2); if (!world.isRemote) { this.checkForMove(world, blockpos, iblockstate); } @@ -116,7 +116,7 @@ public class BlockPistonBase extends Block { */ public IBlockState onBlockPlaced(World world, BlockPos blockpos, EnumFacing var3, float var4, float var5, float var6, int var7, EntityLivingBase entitylivingbase) { - return this.getDefaultState().withProperty(FACING, getFacingFromEntity(world, blockpos, entitylivingbase)) + return this.getDefaultState().withProperty(FACING, getFacingFromEntity(blockpos, entitylivingbase)) .withProperty(EXTENDED, Boolean.valueOf(false)); } @@ -298,20 +298,21 @@ public class BlockPistonBase extends Block { return i > 5 ? null : EnumFacing.getFront(i); } - public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn) { - if (MathHelper.abs((float) entityIn.posX - (float) clickedBlock.getX()) < 2.0F - && MathHelper.abs((float) entityIn.posZ - (float) clickedBlock.getZ()) < 2.0F) { - double d0 = entityIn.posY + (double) entityIn.getEyeHeight(); - if (d0 - (double) clickedBlock.getY() > 2.0D) { + public static EnumFacing getFacingFromEntity(BlockPos pos, EntityLivingBase p_185647_1_) { + if (MathHelper.abs((float) p_185647_1_.posX - (float) pos.getX()) < 2.0F + && MathHelper.abs((float) p_185647_1_.posZ - (float) pos.getZ()) < 2.0F) { + double d0 = p_185647_1_.posY + (double) p_185647_1_.getEyeHeight(); + + if (d0 - (double) pos.getY() > 2.0D) { return EnumFacing.UP; } - if ((double) clickedBlock.getY() - d0 > 0.0D) { + if ((double) pos.getY() - d0 > 0.0D) { return EnumFacing.DOWN; } } - return entityIn.getHorizontalFacing().getOpposite(); + return p_185647_1_.getHorizontalFacing().getOpposite(); } public static boolean canPush(Block blockIn, World worldIn, BlockPos pos, EnumFacing direction, diff --git a/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java b/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java index 9041b89..a2ff7df 100644 --- a/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java +++ b/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java @@ -19,11 +19,12 @@ import net.minecraft.client.gui.inventory.GuiBrewingStand; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiCrafting; import net.minecraft.client.gui.inventory.GuiDispenser; +import net.minecraft.client.gui.inventory.GuiEditCommandBlockMinecart; import net.minecraft.client.gui.inventory.GuiEditSign; import net.minecraft.client.gui.inventory.GuiFurnace; import net.minecraft.client.gui.inventory.GuiScreenHorseInventory; import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.command.server.CommandBlockBaseLogic; import net.minecraft.entity.Entity; import net.minecraft.entity.IMerchant; import net.minecraft.entity.item.EntityItem; @@ -46,6 +47,7 @@ import net.minecraft.network.play.client.C16PacketClientStatus; import net.minecraft.potion.Potion; import net.minecraft.stats.StatBase; import net.minecraft.stats.StatFileWriter; +import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; @@ -533,8 +535,19 @@ public class EntityPlayerSP extends AbstractClientPlayer { this.mc.displayGuiScreen(new GuiEditSign(signTile)); } - public void openEditCommandBlock(CommandBlockLogic cmdBlockLogic) { - this.mc.displayGuiScreen(new GuiCommandBlock(cmdBlockLogic)); + public void displayGuiEditCommandCart(CommandBlockBaseLogic p_184809_1_) { + if (this.canCommandSenderUseCommand(2, "")) { + this.mc.displayGuiScreen(new GuiEditCommandBlockMinecart(p_184809_1_)); + } + } + + public void displayGuiCommandBlock(TileEntityCommandBlock p_184824_1_) { + // System.out.println("displayGuiCommandBlock"); + // everyone can use command blocks :( + // if (this.canCommandSenderUseCommand(2, "")) { + this.mc.displayGuiScreen(new GuiCommandBlock(p_184824_1_)); + // } + } /** diff --git a/src/main/java/net/minecraft/client/gui/GuiChat.java b/src/main/java/net/minecraft/client/gui/GuiChat.java index 5d9b820..8f3d0eb 100644 --- a/src/main/java/net/minecraft/client/gui/GuiChat.java +++ b/src/main/java/net/minecraft/client/gui/GuiChat.java @@ -3,6 +3,8 @@ package net.minecraft.client.gui; import java.io.IOException; import java.util.List; +import javax.annotation.Nullable; + import org.apache.commons.lang3.StringUtils; import com.google.common.collect.Lists; @@ -12,13 +14,17 @@ import net.lax1dude.eaglercraft.v1_8.Mouse; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.Logger; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; +import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; import net.minecraft.network.play.client.C14PacketTabComplete; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; +import net.minecraft.util.ITabCompleter; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.TabCompleter; +import net.minecraft.util.MovingObjectPosition.MovingObjectType; /** * + @@ -49,9 +55,11 @@ import net.minecraft.util.MovingObjectPosition; * POSSIBILITY OF SUCH DAMAGE. * */ -public class GuiChat extends GuiScreen { +public class GuiChat extends GuiScreen implements ITabCompleter { private static final Logger logger = LogManager.getLogger(); private String historyBuffer = ""; + + TabCompleter tabCompleter; /** * + * keeps position of which chat message you will select when you @@ -98,6 +106,7 @@ public class GuiChat extends GuiScreen { this.inputField.setFocused(true); this.inputField.setText(this.defaultInputFieldText); this.inputField.setCanLoseFocus(false); + this.tabCompleter = new GuiChat.ChatTabCompleter(this.inputField); } /** @@ -125,39 +134,38 @@ public class GuiChat extends GuiScreen { * KeyListener.keyTyped(KeyEvent e). Args : character (character * on the key), keyCode (lwjgl Keyboard key code) */ - protected void keyTyped(char parChar1, int parInt1) { - if (parInt1 == 1 && (this.mc.gameSettings.keyBindClose.getKeyCode() == 0 || this.mc.areKeysLocked())) { - this.mc.displayGuiScreen((GuiScreen) null); + protected void keyTyped(char typedChar, int keyCode) { + this.tabCompleter.resetRequested(); + + if (keyCode == 15) { + this.tabCompleter.complete(); } else { - this.waitingOnAutocomplete = false; - if (parInt1 == 15) { - this.autocompletePlayerNames(); - } else { - this.playerNamesFound = false; - } - - if (parInt1 != 28 && parInt1 != 156) { - if (parInt1 == 200) { - this.getSentHistory(-1); - } else if (parInt1 == 208) { - this.getSentHistory(1); - } else if (parInt1 == 201) { - this.mc.ingameGUI.getChatGUI().scroll(this.mc.ingameGUI.getChatGUI().getLineCount() - 1); - } else if (parInt1 == 209) { - this.mc.ingameGUI.getChatGUI().scroll(-this.mc.ingameGUI.getChatGUI().getLineCount() + 1); - } else { - this.inputField.textboxKeyTyped(parChar1, parInt1); - } - } else { - String s = this.inputField.getText().trim(); - if (s.length() > 0) { - this.sendChatMessage(s); - } - - this.mc.displayGuiScreen((GuiScreen) null); - } + this.tabCompleter.resetDidComplete(); } + if (keyCode == 1) { + this.mc.displayGuiScreen((GuiScreen) null); + } else if (keyCode != 28 && keyCode != 156) { + if (keyCode == 200) { + this.getSentHistory(-1); + } else if (keyCode == 208) { + this.getSentHistory(1); + } else if (keyCode == 201) { + this.mc.ingameGUI.getChatGUI().scroll(this.mc.ingameGUI.getChatGUI().getLineCount() - 1); + } else if (keyCode == 209) { + this.mc.ingameGUI.getChatGUI().scroll(-this.mc.ingameGUI.getChatGUI().getLineCount() + 1); + } else { + this.inputField.textboxKeyTyped(typedChar, keyCode); + } + } else { + String s = this.inputField.getText().trim(); + + if (!s.isEmpty()) { + this.sendChatMessage(s); + } + + this.mc.displayGuiScreen((GuiScreen) null); + } } /** @@ -221,61 +229,6 @@ public class GuiChat extends GuiScreen { } - public void autocompletePlayerNames() { - if (this.playerNamesFound) { - this.inputField - .deleteFromCursor(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false) - - this.inputField.getCursorPosition()); - if (this.autocompleteIndex >= this.foundPlayerNames.size()) { - this.autocompleteIndex = 0; - } - } else { - int i = this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false); - this.foundPlayerNames.clear(); - this.autocompleteIndex = 0; - String s = this.inputField.getText().substring(i).toLowerCase(); - String s1 = this.inputField.getText().substring(0, this.inputField.getCursorPosition()); - this.sendAutocompleteRequest(s1, s); - if (this.foundPlayerNames.isEmpty()) { - return; - } - - this.playerNamesFound = true; - this.inputField.deleteFromCursor(i - this.inputField.getCursorPosition()); - } - - int l = this.foundPlayerNames.size(); - if (l > 1) { - StringBuilder stringbuilder = new StringBuilder(); - - for (int i = 0; i < l; ++i) { - if (stringbuilder.length() > 0) { - stringbuilder.append(", "); - } - - stringbuilder.append(this.foundPlayerNames.get(i)); - } - - this.mc.ingameGUI.getChatGUI() - .printChatMessageWithOptionalDeletion(new ChatComponentText(stringbuilder.toString()), 1); - } - - this.inputField.writeText((String) this.foundPlayerNames.get(this.autocompleteIndex++)); - } - - private void sendAutocompleteRequest(String parString1, String parString2) { - if (parString1.length() >= 1) { - BlockPos blockpos = null; - if (this.mc.objectMouseOver != null - && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - blockpos = this.mc.objectMouseOver.getBlockPos(); - } - - this.mc.thePlayer.sendQueue.addToSendQueue(new C14PacketTabComplete(parString1, blockpos)); - this.waitingOnAutocomplete = true; - } - } - /** * + * input is relative and is applied directly to the @@ -325,34 +278,6 @@ public class GuiChat extends GuiScreen { super.drawScreen(i, j, f); } - public void onAutocompleteResponse(String[] parArrayOfString) { - if (this.waitingOnAutocomplete) { - this.playerNamesFound = false; - this.foundPlayerNames.clear(); - - for (int i = 0; i < parArrayOfString.length; ++i) { - String s = parArrayOfString[i]; - if (s.length() > 0) { - this.foundPlayerNames.add(s); - } - } - - String s1 = this.inputField.getText() - .substring(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false)); - String s2 = StringUtils.getCommonPrefix(parArrayOfString); - if (s2.length() > 0 && !s1.equalsIgnoreCase(s2)) { - this.inputField - .deleteFromCursor(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false) - - this.inputField.getCursorPosition()); - this.inputField.writeText(s2); - } else if (this.foundPlayerNames.size() > 0) { - this.playerNamesFound = true; - this.autocompletePlayerNames(); - } - } - - } - /** * + * Returns true if this GUI should pause the game when it is @@ -365,4 +290,47 @@ public class GuiChat extends GuiScreen { public boolean blockPTTKey() { return true; } + + public void setCompletions(String... newCompletions) { + this.tabCompleter.setCompletions(newCompletions); + } + + public static class ChatTabCompleter extends TabCompleter { + private Minecraft clientInstance = Minecraft.getMinecraft(); + + public ChatTabCompleter(GuiTextField p_i46749_1_) { + super(p_i46749_1_, false); + } + + public void complete() { + super.complete(); + + if (this.completions.size() > 1) { + StringBuilder stringbuilder = new StringBuilder(); + + for (String s : this.completions) { + if (stringbuilder.length() > 0) { + stringbuilder.append(", "); + } + + stringbuilder.append(s); + } + + this.clientInstance.ingameGUI.getChatGUI() + .printChatMessageWithOptionalDeletion(new ChatComponentText(stringbuilder.toString()), 1); + } + } + + @Nullable + public BlockPos getTargetBlockPos() { + BlockPos blockpos = null; + + if (this.clientInstance.objectMouseOver != null + && this.clientInstance.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + blockpos = this.clientInstance.objectMouseOver.getBlockPos(); + } + + return blockpos; + } + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiCommandBlock.java b/src/main/java/net/minecraft/client/gui/GuiCommandBlock.java index f71a021..6947712 100644 --- a/src/main/java/net/minecraft/client/gui/GuiCommandBlock.java +++ b/src/main/java/net/minecraft/client/gui/GuiCommandBlock.java @@ -1,14 +1,23 @@ package net.minecraft.client.gui; import net.lax1dude.eaglercraft.v1_8.netty.Unpooled; + +import java.io.IOException; + +import javax.annotation.Nullable; + import net.lax1dude.eaglercraft.v1_8.Keyboard; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.Logger; import net.minecraft.client.resources.I18n; -import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.command.server.CommandBlockBaseLogic; import net.minecraft.network.PacketBuffer; import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.tileentity.TileEntityCommandBlock; +import net.minecraft.util.BlockPos; import net.minecraft.util.IChatComponent; +import net.minecraft.util.ITabCompleter; +import net.minecraft.util.TabCompleter; /** * + @@ -39,22 +48,30 @@ import net.minecraft.util.IChatComponent; * POSSIBILITY OF SUCH DAMAGE. * */ -public class GuiCommandBlock extends GuiScreen { - private static final Logger field_146488_a = LogManager.getLogger(); +public class GuiCommandBlock extends GuiScreen implements ITabCompleter { + /** Text field containing the command block's command. */ private GuiTextField commandTextField; private GuiTextField previousOutputTextField; - private final CommandBlockLogic localCommandBlock; + private final TileEntityCommandBlock commandBlock; + + /** "Done" button for the GUI. */ private GuiButton doneBtn; private GuiButton cancelBtn; - private GuiButton field_175390_s; - private boolean field_175389_t; + private GuiButton outputBtn; + private GuiButton modeBtn; + private GuiButton conditionalBtn; + private GuiButton autoExecBtn; + private boolean trackOutput; + private TileEntityCommandBlock.Mode commandBlockMode = TileEntityCommandBlock.Mode.REDSTONE; + private TabCompleter tabCompleter; + private boolean conditional; + private boolean automatic; - public GuiCommandBlock(CommandBlockLogic parCommandBlockLogic) { - this.localCommandBlock = parCommandBlockLogic; + public GuiCommandBlock(TileEntityCommandBlock commandBlockIn) { + this.commandBlock = commandBlockIn; } /** - * + * Called from the main game loop to update the screen. */ public void updateScreen() { @@ -62,151 +79,250 @@ public class GuiCommandBlock extends GuiScreen { } /** - * + - * Adds the buttons (and other controls) to the screen in - * question. Called when the GUI is displayed and when the + * Adds the buttons (and other controls) to the screen in question. Called when + * the GUI is displayed and when the * window resizes, the buttonList is cleared beforehand. */ public void initGui() { + final CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic(); Keyboard.enableRepeatEvents(true); this.buttonList.clear(); this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 4 - 150, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.done", new Object[0]))); this.buttonList.add(this.cancelBtn = new GuiButton(1, this.width / 2 + 4, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.cancel", new Object[0]))); - this.buttonList.add(this.field_175390_s = new GuiButton(4, this.width / 2 + 150 - 20, 150, 20, 20, "O")); + this.buttonList.add(this.outputBtn = new GuiButton(4, this.width / 2 + 150 - 20, 135, 20, 20, "O")); + this.buttonList.add(this.modeBtn = new GuiButton(5, this.width / 2 - 50 - 100 - 4, 165, 100, 20, + I18n.format("advMode.mode.sequence", new Object[0]))); + this.buttonList.add(this.conditionalBtn = new GuiButton(6, this.width / 2 - 50, 165, 100, 20, + I18n.format("advMode.mode.unconditional", new Object[0]))); + this.buttonList.add(this.autoExecBtn = new GuiButton(7, this.width / 2 + 50 + 4, 165, 100, 20, + I18n.format("advMode.mode.redstoneTriggered", new Object[0]))); this.commandTextField = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 150, 50, 300, 20); - this.commandTextField.setMaxStringLength(32767); + this.commandTextField.setMaxStringLength(32500); this.commandTextField.setFocused(true); - this.commandTextField.setText(this.localCommandBlock.getCommand()); - this.previousOutputTextField = new GuiTextField(3, this.fontRendererObj, this.width / 2 - 150, 150, 276, 20); - this.previousOutputTextField.setMaxStringLength(32767); + this.previousOutputTextField = new GuiTextField(3, this.fontRendererObj, this.width / 2 - 150, 135, 276, 20); + this.previousOutputTextField.setMaxStringLength(32500); this.previousOutputTextField.setEnabled(false); this.previousOutputTextField.setText("-"); - this.field_175389_t = this.localCommandBlock.shouldTrackOutput(); - this.func_175388_a(); - this.doneBtn.enabled = this.commandTextField.getText().trim().length() > 0; + this.doneBtn.enabled = false; + this.outputBtn.enabled = false; + this.modeBtn.enabled = false; + this.conditionalBtn.enabled = false; + this.autoExecBtn.enabled = false; + this.tabCompleter = new TabCompleter(this.commandTextField, true) { + @Nullable + public BlockPos getTargetBlockPos() { + return commandblockbaselogic.getPosition(); + } + }; + } + + public void updateGui() { + CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic(); + this.commandTextField.setText(commandblockbaselogic.getCommand()); + this.trackOutput = commandblockbaselogic.shouldTrackOutput(); + this.commandBlockMode = this.commandBlock.getMode(); + this.conditional = this.commandBlock.isConditional(); + this.automatic = this.commandBlock.isAuto(); + this.updateCmdOutput(); + this.updateMode(); + this.updateConditional(); + this.updateAutoExec(); + this.doneBtn.enabled = true; + this.outputBtn.enabled = true; + this.modeBtn.enabled = true; + this.conditionalBtn.enabled = true; + this.autoExecBtn.enabled = true; } /** - * + - * Called when the screen is unloaded. Used to disable keyboard - * repeat events + * Called when the screen is unloaded. Used to disable keyboard repeat events */ public void onGuiClosed() { Keyboard.enableRepeatEvents(false); } /** - * + - * Called by the controls from the buttonList when activated. - * (Mouse pressed for buttons) + * Called by the controls from the buttonList when activated. (Mouse pressed for + * buttons) */ - protected void actionPerformed(GuiButton parGuiButton) { - if (parGuiButton.enabled) { - if (parGuiButton.id == 1) { - this.localCommandBlock.setTrackOutput(this.field_175389_t); + protected void actionPerformed(GuiButton button) { + if (button.enabled) { + CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic(); + + if (button.id == 1) { + commandblockbaselogic.setTrackOutput(this.trackOutput); this.mc.displayGuiScreen((GuiScreen) null); - } else if (parGuiButton.id == 0) { + } else if (button.id == 0) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); - packetbuffer.writeByte(this.localCommandBlock.func_145751_f()); - this.localCommandBlock.func_145757_a(packetbuffer); + commandblockbaselogic.fillInInfo(packetbuffer); packetbuffer.writeString(this.commandTextField.getText()); - packetbuffer.writeBoolean(this.localCommandBlock.shouldTrackOutput()); - this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|AdvCdm", packetbuffer)); - if (!this.localCommandBlock.shouldTrackOutput()) { - this.localCommandBlock.setLastOutput((IChatComponent) null); + packetbuffer.writeBoolean(commandblockbaselogic.shouldTrackOutput()); + packetbuffer.writeString(this.commandBlockMode.name()); + packetbuffer.writeBoolean(this.conditional); + packetbuffer.writeBoolean(this.automatic); + this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|AutoCmd", packetbuffer)); + + if (!commandblockbaselogic.shouldTrackOutput()) { + commandblockbaselogic.setLastOutput((IChatComponent) null); } this.mc.displayGuiScreen((GuiScreen) null); - } else if (parGuiButton.id == 4) { - this.localCommandBlock.setTrackOutput(!this.localCommandBlock.shouldTrackOutput()); - this.func_175388_a(); + } else if (button.id == 4) { + commandblockbaselogic.setTrackOutput(!commandblockbaselogic.shouldTrackOutput()); + this.updateCmdOutput(); + } else if (button.id == 5) { + this.nextMode(); + this.updateMode(); + } else if (button.id == 6) { + this.conditional = !this.conditional; + this.updateConditional(); + } else if (button.id == 7) { + this.automatic = !this.automatic; + this.updateAutoExec(); } - } } /** - * + - * Fired when a key is typed (except F11 which toggles full - * screen). This is the equivalent of - * KeyListener.keyTyped(KeyEvent e). Args : character (character - * on the key), keyCode (lwjgl Keyboard key code) + * Fired when a key is typed (except F11 which toggles full screen). This is the + * equivalent of + * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), + * keyCode (lwjgl Keyboard key code) */ - protected void keyTyped(char parChar1, int parInt1) { - this.commandTextField.textboxKeyTyped(parChar1, parInt1); - this.previousOutputTextField.textboxKeyTyped(parChar1, parInt1); - this.doneBtn.enabled = this.commandTextField.getText().trim().length() > 0; - if (parInt1 != 28 && parInt1 != 156) { - if (parInt1 == 1) { + protected void keyTyped(char typedChar, int keyCode) { + this.tabCompleter.resetRequested(); + + if (keyCode == 15) { + this.tabCompleter.complete(); + } else { + this.tabCompleter.resetDidComplete(); + } + + this.commandTextField.textboxKeyTyped(typedChar, keyCode); + this.previousOutputTextField.textboxKeyTyped(typedChar, keyCode); + + if (keyCode != 28 && keyCode != 156) { + if (keyCode == 1) { this.actionPerformed(this.cancelBtn); } } else { this.actionPerformed(this.doneBtn); } - } /** - * + - * Called when the mouse is clicked. Args : mouseX, mouseY, - * clickedButton + * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton */ - protected void mouseClicked(int parInt1, int parInt2, int parInt3) { - super.mouseClicked(parInt1, parInt2, parInt3); - this.commandTextField.mouseClicked(parInt1, parInt2, parInt3); - this.previousOutputTextField.mouseClicked(parInt1, parInt2, parInt3); + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { + super.mouseClicked(mouseX, mouseY, mouseButton); + this.commandTextField.mouseClicked(mouseX, mouseY, mouseButton); + this.previousOutputTextField.mouseClicked(mouseX, mouseY, mouseButton); } /** - * + - * Draws the screen and all the components in it. Args : mouseX, - * mouseY, renderPartialTicks + * Draws the screen and all the components in it. */ - public void drawScreen(int i, int j, float f) { + public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); this.drawCenteredString(this.fontRendererObj, I18n.format("advMode.setCommand", new Object[0]), this.width / 2, 20, 16777215); this.drawString(this.fontRendererObj, I18n.format("advMode.command", new Object[0]), this.width / 2 - 150, 37, 10526880); this.commandTextField.drawTextBox(); - int k = 75; - int l = 0; + int i = 75; + int j = 0; this.drawString(this.fontRendererObj, I18n.format("advMode.nearestPlayer", new Object[0]), this.width / 2 - 150, - k + l++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880); this.drawString(this.fontRendererObj, I18n.format("advMode.randomPlayer", new Object[0]), this.width / 2 - 150, - k + l++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880); this.drawString(this.fontRendererObj, I18n.format("advMode.allPlayers", new Object[0]), this.width / 2 - 150, - k + l++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880); this.drawString(this.fontRendererObj, I18n.format("advMode.allEntities", new Object[0]), this.width / 2 - 150, - k + l++ * this.fontRendererObj.FONT_HEIGHT, 10526880); - this.drawString(this.fontRendererObj, "", this.width / 2 - 150, k + l++ * this.fontRendererObj.FONT_HEIGHT, + i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + this.drawString(this.fontRendererObj, "", this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880); - if (this.previousOutputTextField.getText().length() > 0) { - k = k + l * this.fontRendererObj.FONT_HEIGHT + 16; + + if (!this.previousOutputTextField.getText().isEmpty()) { + i = i + j * this.fontRendererObj.FONT_HEIGHT + 1; this.drawString(this.fontRendererObj, I18n.format("advMode.previousOutput", new Object[0]), - this.width / 2 - 150, k, 10526880); + this.width / 2 - 150, i, 10526880); this.previousOutputTextField.drawTextBox(); } - super.drawScreen(i, j, f); + super.drawScreen(mouseX, mouseY, partialTicks); } - private void func_175388_a() { - if (this.localCommandBlock.shouldTrackOutput()) { - this.field_175390_s.displayString = "O"; - if (this.localCommandBlock.getLastOutput() != null) { - this.previousOutputTextField.setText(this.localCommandBlock.getLastOutput().getUnformattedText()); + private void updateCmdOutput() { + CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic(); + + if (commandblockbaselogic.shouldTrackOutput()) { + this.outputBtn.displayString = "O"; + + if (commandblockbaselogic.getLastOutput() != null) { + this.previousOutputTextField.setText(commandblockbaselogic.getLastOutput().getUnformattedText()); } } else { - this.field_175390_s.displayString = "X"; + this.outputBtn.displayString = "X"; this.previousOutputTextField.setText("-"); } - } - public boolean blockPTTKey() { - return commandTextField.isFocused(); + private void updateMode() { + switch (this.commandBlockMode) { + case SEQUENCE: + this.modeBtn.displayString = I18n.format("advMode.mode.sequence", new Object[0]); + break; + + case AUTO: + this.modeBtn.displayString = I18n.format("advMode.mode.auto", new Object[0]); + break; + + case REDSTONE: + this.modeBtn.displayString = I18n.format("advMode.mode.redstone", new Object[0]); + } + } + + private void nextMode() { + switch (this.commandBlockMode) { + case SEQUENCE: + this.commandBlockMode = TileEntityCommandBlock.Mode.AUTO; + break; + + case AUTO: + this.commandBlockMode = TileEntityCommandBlock.Mode.REDSTONE; + break; + + case REDSTONE: + this.commandBlockMode = TileEntityCommandBlock.Mode.SEQUENCE; + } + } + + private void updateConditional() { + if (this.conditional) { + this.conditionalBtn.displayString = I18n.format("advMode.mode.conditional", new Object[0]); + } else { + this.conditionalBtn.displayString = I18n.format("advMode.mode.unconditional", new Object[0]); + } + } + + private void updateAutoExec() { + if (this.automatic) { + this.autoExecBtn.displayString = I18n.format("advMode.mode.autoexec.bat", new Object[0]); + } else { + this.autoExecBtn.displayString = I18n.format("advMode.mode.redstoneTriggered", new Object[0]); + } + } + + /** + * Sets the list of tab completions, as long as they were previously requested. + */ + public void setCompletions(String... newCompletions) { + this.tabCompleter.setCompletions(newCompletions); + } + + public boolean doesGuiPauseGame() { + return false; } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiTextField.java b/src/main/java/net/minecraft/client/gui/GuiTextField.java index a63498a..215cfbe 100644 --- a/src/main/java/net/minecraft/client/gui/GuiTextField.java +++ b/src/main/java/net/minecraft/client/gui/GuiTextField.java @@ -265,10 +265,10 @@ public class GuiTextField extends Gui { * looks backwards. params: N, position */ public int getNthWordFromPos(int parInt1, int parInt2) { - return this.func_146197_a(parInt1, parInt2, true); + return this.getNthWordFromPosWS(parInt1, parInt2, true); } - public int func_146197_a(int parInt1, int parInt2, boolean parFlag) { + public int getNthWordFromPosWS(int parInt1, int parInt2, boolean parFlag) { int i = parInt2; boolean flag = parInt1 < 0; int j = Math.abs(parInt1); diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiEditCommandBlockMinecart.java b/src/main/java/net/minecraft/client/gui/inventory/GuiEditCommandBlockMinecart.java new file mode 100644 index 0000000..c772378 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiEditCommandBlockMinecart.java @@ -0,0 +1,204 @@ +package net.minecraft.client.gui.inventory; + +import java.io.IOException; + +import javax.annotation.Nullable; + +import net.lax1dude.eaglercraft.v1_8.Keyboard; +import net.lax1dude.eaglercraft.v1_8.netty.Unpooled; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.resources.I18n; +import net.minecraft.command.server.CommandBlockBaseLogic; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.util.BlockPos; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.ITabCompleter; +import net.minecraft.util.StatCollector; +import net.minecraft.util.TabCompleter; + +public class GuiEditCommandBlockMinecart extends GuiScreen implements ITabCompleter { + private GuiTextField commandField; + private GuiTextField previousEdit; + private final CommandBlockBaseLogic commandBlockLogic; + private GuiButton doneButton; + private GuiButton cancelButton; + private GuiButton outputButton; + private boolean trackOutput; + private TabCompleter tabCompleter; + + public GuiEditCommandBlockMinecart(CommandBlockBaseLogic p_i46595_1_) { + this.commandBlockLogic = p_i46595_1_; + } + + /** + * Called from the main game loop to update the screen. + */ + public void updateScreen() { + this.commandField.updateCursorCounter(); + } + + /** + * Adds the buttons (and other controls) to the screen in question. Called when + * the GUI is displayed and when the + * window resizes, the buttonList is cleared beforehand. + */ + public void initGui() { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(this.doneButton = new GuiButton(0, this.width / 2 - 4 - 150, this.height / 4 + 120 + 12, + 150, 20, StatCollector.translateToLocalFormatted("gui.done", new Object[0]))); + this.buttonList.add(this.cancelButton = new GuiButton(1, this.width / 2 + 4, this.height / 4 + 120 + 12, 150, + 20, I18n.format("gui.cancel", new Object[0]))); + this.buttonList.add(this.outputButton = new GuiButton(4, this.width / 2 + 150 - 20, 150, 20, 20, "O")); + this.commandField = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 150, 50, 300, 20); + this.commandField.setMaxStringLength(32500); + this.commandField.setFocused(true); + this.commandField.setText(this.commandBlockLogic.getCommand()); + this.previousEdit = new GuiTextField(3, this.fontRendererObj, this.width / 2 - 150, 150, 276, 20); + this.previousEdit.setMaxStringLength(32500); + this.previousEdit.setEnabled(false); + this.previousEdit.setText("-"); + this.trackOutput = this.commandBlockLogic.shouldTrackOutput(); + this.updateCommandOutput(); + this.doneButton.enabled = !this.commandField.getText().trim().isEmpty(); + this.tabCompleter = new TabCompleter(this.commandField, true) { + @Nullable + public BlockPos getTargetBlockPos() { + return GuiEditCommandBlockMinecart.this.commandBlockLogic.getPosition(); + } + }; + } + + /** + * Called when the screen is unloaded. Used to disable keyboard repeat events + */ + public void onGuiClosed() { + Keyboard.enableRepeatEvents(false); + } + + /** + * Called by the controls from the buttonList when activated. (Mouse pressed for + * buttons) + */ + protected void actionPerformed(GuiButton button) { + if (button.enabled) { + if (button.id == 1) { + this.commandBlockLogic.setTrackOutput(this.trackOutput); + this.mc.displayGuiScreen((GuiScreen) null); + } else if (button.id == 0) { + PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); + packetbuffer.writeByte(this.commandBlockLogic.getCommandBlockType()); + this.commandBlockLogic.fillInInfo(packetbuffer); + packetbuffer.writeString(this.commandField.getText()); + packetbuffer.writeBoolean(this.commandBlockLogic.shouldTrackOutput()); + this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|AdvCmd", packetbuffer)); + + if (!this.commandBlockLogic.shouldTrackOutput()) { + this.commandBlockLogic.setLastOutput((IChatComponent) null); + } + + this.mc.displayGuiScreen((GuiScreen) null); + } else if (button.id == 4) { + this.commandBlockLogic.setTrackOutput(!this.commandBlockLogic.shouldTrackOutput()); + this.updateCommandOutput(); + } + } + } + + /** + * Fired when a key is typed (except F11 which toggles full screen). This is the + * equivalent of + * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), + * keyCode (lwjgl Keyboard key code) + */ + protected void keyTyped(char typedChar, int keyCode) { + this.tabCompleter.resetRequested(); + + if (keyCode == 15) { + this.tabCompleter.complete(); + } else { + this.tabCompleter.resetDidComplete(); + } + + this.commandField.textboxKeyTyped(typedChar, keyCode); + this.previousEdit.textboxKeyTyped(typedChar, keyCode); + this.doneButton.enabled = !this.commandField.getText().trim().isEmpty(); + + if (keyCode != 28 && keyCode != 156) { + if (keyCode == 1) { + this.actionPerformed(this.cancelButton); + } + } else { + this.actionPerformed(this.doneButton); + } + } + + /** + * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton + */ + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { + super.mouseClicked(mouseX, mouseY, mouseButton); + this.commandField.mouseClicked(mouseX, mouseY, mouseButton); + this.previousEdit.mouseClicked(mouseX, mouseY, mouseButton); + } + + /** + * Draws the screen and all the components in it. + */ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("advMode.setCommand", new Object[0]), this.width / 2, + 20, 16777215); + this.drawString(this.fontRendererObj, I18n.format("advMode.command", new Object[0]), this.width / 2 - 150, 37, + 10526880); + this.commandField.drawTextBox(); + int i = 75; + int j = 0; + this.drawString(this.fontRendererObj, I18n.format("advMode.nearestPlayer", new Object[0]), this.width / 2 - 150, + i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + this.drawString(this.fontRendererObj, I18n.format("advMode.randomPlayer", new Object[0]), this.width / 2 - 150, + i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + this.drawString(this.fontRendererObj, I18n.format("advMode.allPlayers", new Object[0]), this.width / 2 - 150, + i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + this.drawString(this.fontRendererObj, I18n.format("advMode.allEntities", new Object[0]), this.width / 2 - 150, + i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + this.drawString(this.fontRendererObj, "", this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, + 10526880); + + if (!this.previousEdit.getText().isEmpty()) { + i = i + j * this.fontRendererObj.FONT_HEIGHT + 16; + this.drawString(this.fontRendererObj, I18n.format("advMode.previousOutput", new Object[0]), + this.width / 2 - 150, i, 10526880); + this.previousEdit.drawTextBox(); + } + + super.drawScreen(mouseX, mouseY, partialTicks); + } + + private void updateCommandOutput() { + if (this.commandBlockLogic.shouldTrackOutput()) { + this.outputButton.displayString = "O"; + + if (this.commandBlockLogic.getLastOutput() != null) { + this.previousEdit.setText(this.commandBlockLogic.getLastOutput().getUnformattedText()); + } + } else { + this.outputButton.displayString = "X"; + this.previousEdit.setText("-"); + } + } + + /** + * Sets the list of tab completions, as long as they were previously requested. + */ + public void setCompletions(String... newCompletions) { + this.tabCompleter.setCompletions(newCompletions); + } + + public boolean doesGuiPauseGame() { + return false; + } +} diff --git a/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java b/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java index 749f266..458eec5 100644 --- a/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java +++ b/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java @@ -33,6 +33,7 @@ import net.minecraft.client.audio.GuardianSound; import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.GuiCommandBlock; import net.minecraft.client.gui.GuiDisconnected; import net.minecraft.client.gui.GuiDownloadTerrain; import net.minecraft.client.gui.GuiMainMenu; @@ -209,6 +210,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.IChatComponent; +import net.minecraft.util.ITabCompleter; import net.minecraft.util.MathHelper; import net.minecraft.util.StringUtils; import net.minecraft.village.MerchantRecipeList; @@ -1169,14 +1171,20 @@ public class NetHandlerPlayClient implements INetHandlerPlayClient { if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); int i = packetIn.getTileEntityType(); - if (i == 1 && tileentity instanceof TileEntityMobSpawner - || i == 2 && tileentity instanceof TileEntityCommandBlock + boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock; + + if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot - || i == 6 && tileentity instanceof TileEntityBanner) { + || i == 6 && tileentity instanceof TileEntityBanner + || i == 9 && tileentity instanceof TileEntitySign) { tileentity.readFromNBT(packetIn.getNbtCompound()); } + + if (flag && this.gameController.currentScreen instanceof GuiCommandBlock) { + ((GuiCommandBlock) this.gameController.currentScreen).updateGui(); + } } } @@ -1491,10 +1499,9 @@ public class NetHandlerPlayClient implements INetHandlerPlayClient { * knows of */ public void handleTabComplete(S3APacketTabComplete packetIn) { - String[] astring = packetIn.func_149630_c(); - if (this.gameController.currentScreen instanceof GuiChat) { - GuiChat guichat = (GuiChat) this.gameController.currentScreen; - guichat.onAutocompleteResponse(astring); + String[] astring = packetIn.getMatches(); + if (this.gameController.currentScreen instanceof ITabCompleter) { + ((ITabCompleter) this.gameController.currentScreen).setCompletions(astring); } } @@ -1838,12 +1845,12 @@ public class NetHandlerPlayClient implements INetHandlerPlayClient { } public void handleCooldown(SPacketCooldown packetIn) { - if (packetIn.getTicks() == 0) { - this.gameController.thePlayer.getCooldownTracker().removeCooldown(packetIn.getItem()); - } else { - this.gameController.thePlayer.getCooldownTracker().setCooldown(packetIn.getItem(), packetIn.getTicks()); - } - } + if (packetIn.getTicks() == 0) { + this.gameController.thePlayer.getCooldownTracker().removeCooldown(packetIn.getItem()); + } else { + this.gameController.thePlayer.getCooldownTracker().setCooldown(packetIn.getItem(), packetIn.getTicks()); + } + } /** * + diff --git a/src/main/java/net/minecraft/client/renderer/BlockModelRenderer.java b/src/main/java/net/minecraft/client/renderer/BlockModelRenderer.java index 6202ad0..2607a92 100644 --- a/src/main/java/net/minecraft/client/renderer/BlockModelRenderer.java +++ b/src/main/java/net/minecraft/client/renderer/BlockModelRenderer.java @@ -3,6 +3,7 @@ package net.minecraft.client.renderer; import java.util.BitSet; import java.util.List; +import net.hoosiertransfer.Config; import net.hoosiertransfer.Alfheim.util.ClampUtil; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; @@ -67,7 +68,6 @@ public class BlockModelRenderer { boolean flag = Minecraft.isAmbientOcclusionEnabled() && ClampUtil.clampMinFirst(blockStateIn.getLightValue(blockAccessIn, blockPosIn) - 1, 0, 15) == 0 && modelIn.isAmbientOcclusion(); - try { Block block = blockStateIn.getBlock(); return flag diff --git a/src/main/java/net/minecraft/client/renderer/BlockModelShapes.java b/src/main/java/net/minecraft/client/renderer/BlockModelShapes.java index 0f08504..5217fb3 100644 --- a/src/main/java/net/minecraft/client/renderer/BlockModelShapes.java +++ b/src/main/java/net/minecraft/client/renderer/BlockModelShapes.java @@ -191,8 +191,6 @@ public class BlockModelShapes { (new StateMap.Builder()).ignore(new IProperty[] { BlockReed.AGE }).build()); this.registerBlockWithStateMapper(Blocks.jukebox, (new StateMap.Builder()).ignore(new IProperty[] { BlockJukebox.HAS_RECORD }).build()); - this.registerBlockWithStateMapper(Blocks.command_block, - (new StateMap.Builder()).ignore(new IProperty[] { BlockCommandBlock.TRIGGERED }).build()); this.registerBlockWithStateMapper(Blocks.cobblestone_wall, (new StateMap.Builder()).withName(BlockWall.VARIANT).withSuffix("_wall").build()); this.registerBlockWithStateMapper(Blocks.double_plant, diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderDragon.java b/src/main/java/net/minecraft/client/renderer/entity/RenderDragon.java index 2d619c8..8d9d7aa 100644 --- a/src/main/java/net/minecraft/client/renderer/entity/RenderDragon.java +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderDragon.java @@ -46,7 +46,7 @@ import net.minecraft.util.ResourceLocation; * */ public class RenderDragon extends RenderLiving { - private static final ResourceLocation enderDragonCrystalBeamTextures = new ResourceLocation( + public static final ResourceLocation enderDragonCrystalBeamTextures = new ResourceLocation( "textures/entity/endercrystal/endercrystal_beam.png"); private static final ResourceLocation enderDragonExplodingTextures = new ResourceLocation( "textures/entity/enderdragon/dragon_exploding.png"); @@ -158,7 +158,7 @@ public class RenderDragon extends RenderLiving { * + * Draws the ray from the dragon to it's crystal */ - protected void drawRechargeRay(EntityDragon dragon, double parDouble1, double parDouble2, double parDouble3, + public void drawRechargeRay(EntityDragon dragon, double parDouble1, double parDouble2, double parDouble3, float parFloat1) { float f = (float) dragon.healingEnderCrystal.innerRotation + parFloat1; float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F; @@ -206,6 +206,48 @@ public class RenderDragon extends RenderLiving { GlStateManager.popMatrix(); } + public static void renderCrystalBeams(double p_188325_0_, double p_188325_2_, double p_188325_4_, float p_188325_6_, + double p_188325_7_, double p_188325_9_, double p_188325_11_, int p_188325_13_, double p_188325_14_, + double p_188325_16_, double p_188325_18_) { + float f = (float) (p_188325_14_ - p_188325_7_); + float f1 = (float) (p_188325_16_ - 1.0D - p_188325_9_); + float f2 = (float) (p_188325_18_ - p_188325_11_); + float f3 = MathHelper.sqrt_float(f * f + f2 * f2); + float f4 = MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2); + GlStateManager.pushMatrix(); + GlStateManager.translate((float) p_188325_0_, (float) p_188325_2_ + 2.0F, (float) p_188325_4_); + GlStateManager.rotate((float) (-Math.atan2((double) f2, (double) f)) * (180F / (float) Math.PI) - 90.0F, 0.0F, + 1.0F, 0.0F); + GlStateManager.rotate((float) (-Math.atan2((double) f3, (double) f1)) * (180F / (float) Math.PI) - 90.0F, 1.0F, + 0.0F, 0.0F); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer vertexbuffer = tessellator.getWorldRenderer(); + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableCull(); + GlStateManager.shadeModel(7425); + float f5 = 0.0F - ((float) p_188325_13_ + p_188325_6_) * 0.01F; + float f6 = MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2) / 32.0F + - ((float) p_188325_13_ + p_188325_6_) * 0.01F; + vertexbuffer.begin(5, DefaultVertexFormats.POSITION_TEX_COLOR); + int i = 8; + + for (int j = 0; j <= 8; ++j) { + float f7 = MathHelper.sin((float) (j % 8) * ((float) Math.PI * 2F) / 8.0F) * 0.75F; + float f8 = MathHelper.cos((float) (j % 8) * ((float) Math.PI * 2F) / 8.0F) * 0.75F; + float f9 = (float) (j % 8) / 8.0F; + vertexbuffer.pos((double) (f7 * 0.2F), (double) (f8 * 0.2F), 0.0D).tex((double) f9, (double) f5) + .color(0, 0, 0, 255).endVertex(); + vertexbuffer.pos((double) f7, (double) f8, (double) f4).tex((double) f9, (double) f6) + .color(255, 255, 255, 255).endVertex(); + } + + tessellator.draw(); + GlStateManager.enableCull(); + GlStateManager.shadeModel(7424); + RenderHelper.enableStandardItemLighting(); + GlStateManager.popMatrix(); + } + /** * + * Returns the location of an entity's texture. Doesn't seem to diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/RenderEnderCrystal.java b/src/main/java/net/minecraft/client/renderer/tileentity/RenderEnderCrystal.java index 8a42777..6c23b51 100644 --- a/src/main/java/net/minecraft/client/renderer/tileentity/RenderEnderCrystal.java +++ b/src/main/java/net/minecraft/client/renderer/tileentity/RenderEnderCrystal.java @@ -4,8 +4,10 @@ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelEnderCrystal; import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderDragon; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; @@ -42,6 +44,7 @@ public class RenderEnderCrystal extends Render { private static final ResourceLocation enderCrystalTextures = new ResourceLocation( "textures/entity/endercrystal/endercrystal.png"); private ModelBase modelEnderCrystal = new ModelEnderCrystal(0.0F, true); + private ModelBase modelEnderCrystalNoBase = new ModelEnderCrystal(0.0F, false); public RenderEnderCrystal(RenderManager renderManagerIn) { super(renderManagerIn); @@ -58,16 +61,45 @@ public class RenderEnderCrystal extends Render { * public void func_76986_a(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doe */ - public void doRender(EntityEnderCrystal entityendercrystal, double d0, double d1, double d2, float f, float f1) { - float f2 = (float) entityendercrystal.innerRotation + f1; + public void doRender(EntityEnderCrystal entity, double x, double y, double z, float entityYaw, float partialTicks) { + float f = (float) entity.innerRotation + partialTicks; GlStateManager.pushMatrix(); - GlStateManager.translate((float) d0, (float) d1, (float) d2); + GlStateManager.translate((float) x, (float) y, (float) z); this.bindTexture(enderCrystalTextures); - float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F; - f3 = f3 * f3 + f3; - this.modelEnderCrystal.render(entityendercrystal, 0.0F, f2 * 3.0F, f3 * 0.2F, 0.0F, 0.0F, 0.0625F); + float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F; + f1 = f1 * f1 + f1; + + // if (this.renderOutlines) { + // GlStateManager.enableColorMaterial(); + // GlStateManager.enableOutlineMode(this.getTeamColor(entity)); + // } + + if (entity.shouldShowBottom()) { + this.modelEnderCrystal.render(entity, 0.0F, f * 3.0F, f1 * 0.2F, 0.0F, 0.0F, 0.0625F); + } else { + this.modelEnderCrystalNoBase.render(entity, 0.0F, f * 3.0F, f1 * 0.2F, 0.0F, 0.0F, 0.0625F); + } + + // if (this.renderOutlines) { + // GlStateManager.disableOutlineMode(); + // GlStateManager.disableColorMaterial(); + // } + GlStateManager.popMatrix(); - super.doRender(entityendercrystal, d0, d1, d2, f, f1); + // TODO: Uncomment this when new ender dragon fight is implemented + // BlockPos blockpos = entity.getBeamTarget(); + // if (blockpos != null) { + // this.bindTexture(RenderDragon.enderDragonCrystalBeamTextures); + // float f2 = (float) blockpos.getX() + 0.5F; + // float f3 = (float) blockpos.getY() + 0.5F; + // float f4 = (float) blockpos.getZ() + 0.5F; + // RenderDragon.renderCrystalBeams(x, y - 1.2999999523162842D + (double) (f1 * + // 0.4F), z, partialTicks, + // entity.posX, entity.posY, entity.posZ, entity.innerRotation, (double) f2, + // (double) f3, (double) f4); + // } + + super.doRender(entity, x, y, z, entityYaw, partialTicks); } /** diff --git a/src/main/java/net/minecraft/command/ServerCommandManager.java b/src/main/java/net/minecraft/command/ServerCommandManager.java index 509dfef..88e87f7 100644 --- a/src/main/java/net/minecraft/command/ServerCommandManager.java +++ b/src/main/java/net/minecraft/command/ServerCommandManager.java @@ -1,7 +1,7 @@ package net.minecraft.command; import net.minecraft.command.server.CommandAchievement; -import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.command.server.CommandBlockBaseLogic; import net.minecraft.command.server.CommandBroadcast; import net.minecraft.command.server.CommandEmote; import net.minecraft.command.server.CommandListPlayers; @@ -138,8 +138,8 @@ public class ServerCommandManager extends CommandHandler implements IAdminComman } boolean flag3 = minecraftserver.worldServers[0].getGameRules().getBoolean("sendCommandFeedback"); - if (sender instanceof CommandBlockLogic) { - flag3 = ((CommandBlockLogic) sender).shouldTrackOutput(); + if (sender instanceof CommandBlockBaseLogic) { + flag3 = ((CommandBlockBaseLogic) sender).shouldTrackOutput(); } if ((flags & 1) != 1 && flag3 || sender instanceof MinecraftServer) { diff --git a/src/main/java/net/minecraft/command/server/CommandBlockLogic.java b/src/main/java/net/minecraft/command/server/CommandBlockBaseLogic.java similarity index 94% rename from src/main/java/net/minecraft/command/server/CommandBlockLogic.java rename to src/main/java/net/minecraft/command/server/CommandBlockBaseLogic.java index 6a671d9..a7b64f1 100644 --- a/src/main/java/net/minecraft/command/server/CommandBlockLogic.java +++ b/src/main/java/net/minecraft/command/server/CommandBlockBaseLogic.java @@ -47,7 +47,7 @@ import net.minecraft.world.World; * POSSIBILITY OF SUCH DAMAGE. * */ -public abstract class CommandBlockLogic implements ICommandSender { +public abstract class CommandBlockBaseLogic implements ICommandSender { /** * + * The formatting for the timestamp on commands run. @@ -80,6 +80,10 @@ public abstract class CommandBlockLogic implements ICommandSender { return this.successCount; } + public void setSuccessCount(int successCountIn) { + this.successCount = successCountIn; + } + /** * + * Returns the lastOutput. @@ -169,12 +173,12 @@ public abstract class CommandBlockLogic implements ICommandSender { CrashReportCategory crashreportcategory = crashreport.makeCategory("Command to be executed"); crashreportcategory.addCrashSectionCallable("Command", new Callable() { public String call() throws Exception { - return CommandBlockLogic.this.getCommand(); + return CommandBlockBaseLogic.this.getCommand(); } }); crashreportcategory.addCrashSectionCallable("Name", new Callable() { public String call() throws Exception { - return CommandBlockLogic.this.getName(); + return CommandBlockBaseLogic.this.getName(); } }); throw new ReportedException(crashreport); @@ -237,9 +241,9 @@ public abstract class CommandBlockLogic implements ICommandSender { public abstract void updateCommand(); - public abstract int func_145751_f(); + public abstract int getCommandBlockType(); - public abstract void func_145757_a(ByteBuf var1); + public abstract void fillInInfo(ByteBuf var1); public void setLastOutput(IChatComponent lastOutputMessage) { this.lastOutput = lastOutputMessage; @@ -258,7 +262,7 @@ public abstract class CommandBlockLogic implements ICommandSender { return false; } else { if (playerIn.getEntityWorld().isRemote) { - playerIn.openEditCommandBlock(this); + playerIn.displayGuiEditCommandCart(this); } return true; diff --git a/src/main/java/net/minecraft/entity/DataWatcher.java b/src/main/java/net/minecraft/entity/DataWatcher.java index 3453bb9..56fc8a3 100644 --- a/src/main/java/net/minecraft/entity/DataWatcher.java +++ b/src/main/java/net/minecraft/entity/DataWatcher.java @@ -10,6 +10,7 @@ import org.apache.commons.lang3.ObjectUtils; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import net.minecraft.block.Block; import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.item.ItemStack; @@ -148,6 +149,10 @@ public class DataWatcher { return datawatcher$watchableobject; } + public BlockPos getWatchableObjectBlockPos(int id) { + return (BlockPos) this.getWatchedObject(id).getObject(); + } + public Rotations getWatchableObjectRotations(int id) { return (Rotations) this.getWatchedObject(id).getObject(); } diff --git a/src/main/java/net/minecraft/entity/EntityMinecartCommandBlock.java b/src/main/java/net/minecraft/entity/EntityMinecartCommandBlock.java index d0150c2..090d5f5 100644 --- a/src/main/java/net/minecraft/entity/EntityMinecartCommandBlock.java +++ b/src/main/java/net/minecraft/entity/EntityMinecartCommandBlock.java @@ -2,15 +2,17 @@ package net.minecraft.entity; import net.lax1dude.eaglercraft.v1_8.netty.ByteBuf; import net.minecraft.block.state.IBlockState; -import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.command.server.CommandBlockBaseLogic; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.BlockPos; import net.minecraft.util.IChatComponent; import net.minecraft.util.Vec3; import net.minecraft.world.World; +import net.minecraft.world.WorldServer; /** * + @@ -42,18 +44,18 @@ import net.minecraft.world.World; * */ public class EntityMinecartCommandBlock extends EntityMinecart { - private final CommandBlockLogic commandBlockLogic = new CommandBlockLogic() { + private final CommandBlockBaseLogic commandBlockLogic = new CommandBlockBaseLogic() { public void updateCommand() { EntityMinecartCommandBlock.this.getDataWatcher().updateObject(23, this.getCommand()); EntityMinecartCommandBlock.this.getDataWatcher().updateObject(24, IChatComponent.Serializer.componentToJson(this.getLastOutput())); } - public int func_145751_f() { + public int getCommandBlockType() { return 1; } - public void func_145757_a(ByteBuf bytebuf) { + public void fillInInfo(ByteBuf bytebuf) { bytebuf.writeInt(EntityMinecartCommandBlock.this.getEntityId()); } @@ -74,6 +76,10 @@ public class EntityMinecartCommandBlock extends EntityMinecart { public Entity getCommandSenderEntity() { return EntityMinecartCommandBlock.this; } + + public MinecraftServer getServer() { + return ((WorldServer) EntityMinecartCommandBlock.this.worldObj).getMinecraftServer(); + } }; /** * + @@ -126,7 +132,7 @@ public class EntityMinecartCommandBlock extends EntityMinecart { return Blocks.command_block.getDefaultState(); } - public CommandBlockLogic getCommandBlockLogic() { + public CommandBlockBaseLogic getCommandBlockLogic() { return this.commandBlockLogic; } diff --git a/src/main/java/net/minecraft/entity/item/EntityEnderCrystal.java b/src/main/java/net/minecraft/entity/item/EntityEnderCrystal.java index d0fe5c6..74f8604 100644 --- a/src/main/java/net/minecraft/entity/item/EntityEnderCrystal.java +++ b/src/main/java/net/minecraft/entity/item/EntityEnderCrystal.java @@ -1,8 +1,15 @@ package net.minecraft.entity.item; +import javax.annotation.Nullable; + +import com.google.common.base.Optional; + +import net.minecraft.block.Block; import net.minecraft.entity.Entity; +import net.minecraft.entity.boss.EntityDragon; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; @@ -40,13 +47,11 @@ import net.minecraft.world.WorldProviderEnd; */ public class EntityEnderCrystal extends Entity { public int innerRotation; - public int health; public EntityEnderCrystal(World worldIn) { super(worldIn); this.preventEntitySpawning = true; this.setSize(2.0F, 2.0F); - this.health = 5; this.innerRotation = this.rand.nextInt(100000); } @@ -66,7 +71,9 @@ public class EntityEnderCrystal extends Entity { } protected void entityInit() { - this.dataWatcher.addObject(8, Integer.valueOf(this.health)); + this.dataWatcher.addObject(30, Byte.valueOf((byte) 0)); + this.dataWatcher.addObject(31, BlockPos.ORIGIN); + this.dataWatcher.addObject(6, Byte.valueOf((byte) 1)); } /** @@ -78,13 +85,13 @@ public class EntityEnderCrystal extends Entity { this.prevPosY = this.posY; this.prevPosZ = this.posZ; ++this.innerRotation; - this.dataWatcher.updateObject(8, Integer.valueOf(this.health)); - int i = MathHelper.floor_double(this.posX); - int j = MathHelper.floor_double(this.posY); - int k = MathHelper.floor_double(this.posZ); - if (this.worldObj.provider instanceof WorldProviderEnd - && this.worldObj.getBlockState(new BlockPos(i, j, k)).getBlock() != Blocks.fire) { - this.worldObj.setBlockState(new BlockPos(i, j, k), Blocks.fire.getDefaultState()); + if (!this.worldObj.isRemote) { + BlockPos blockpos = new BlockPos(this); + + if (this.worldObj.provider instanceof WorldProviderEnd + && this.worldObj.getBlockState(blockpos).getBlock() != Blocks.fire) { + this.worldObj.setBlockState(blockpos, Blocks.fire.getDefaultState()); + } } } @@ -94,7 +101,12 @@ public class EntityEnderCrystal extends Entity { * (abstract) Protected helper method to write subclass entity * data to NBT. */ - protected void writeEntityToNBT(NBTTagCompound var1) { + protected void writeEntityToNBT(NBTTagCompound compound) { + if (this.getBeamTarget() != null) { + compound.setTag("BeamTarget", NBTUtil.createPosTag(this.getBeamTarget())); + } + + compound.setBoolean("ShowBottom", this.shouldShowBottom()); } /** @@ -102,7 +114,14 @@ public class EntityEnderCrystal extends Entity { * (abstract) Protected helper method to read subclass entity * data from NBT. */ - protected void readEntityFromNBT(NBTTagCompound var1) { + protected void readEntityFromNBT(NBTTagCompound compound) { + if (compound.hasKey("BeamTarget", 10)) { + this.setBeamTarget(NBTUtil.getPosFromTag(compound.getCompoundTag("BeamTarget"))); + } + + if (compound.hasKey("ShowBottom", 1)) { + this.setShowBottom(compound.getBoolean("ShowBottom")); + } } /** @@ -118,21 +137,58 @@ public class EntityEnderCrystal extends Entity { * + * Called when the entity is attacked. */ - public boolean attackEntityFrom(DamageSource damagesource, float var2) { - if (this.isEntityInvulnerable(damagesource)) { + public boolean attackEntityFrom(DamageSource source, float amount) { + if (this.isEntityInvulnerable(source)) { + return false; + } else if (source.getEntity() instanceof EntityDragon) { return false; } else { if (!this.isDead && !this.worldObj.isRemote) { - this.health = 0; - if (this.health <= 0) { - this.setDead(); - if (!this.worldObj.isRemote) { - this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 6.0F, true); - } + this.setDead(); + + if (!this.worldObj.isRemote) { + this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 6.0F, true); + this.onCrystalDestroyed(source); } } return true; } } + + public void onKillCommand() { + this.onCrystalDestroyed(DamageSource.generic); + super.onKillCommand(); + } + + private void onCrystalDestroyed(DamageSource source) { + + } + + public void setBeamTarget(@Nullable BlockPos beamTarget) { + Optional optional = Optional.fromNullable(beamTarget); + this.dataWatcher.updateObject(30, Byte.valueOf((byte) (optional.isPresent() ? 1 : 0))); + this.dataWatcher.updateObject(31, optional.isPresent() ? beamTarget : BlockPos.ORIGIN); + } + + @Nullable + public BlockPos getBeamTarget() { + boolean isPresent = this.dataWatcher.getWatchableObjectByte(30) == 1; + return isPresent ? (BlockPos) this.dataWatcher.getWatchableObjectBlockPos(31) : null; + } + + public void setShowBottom(boolean showBottom) { + this.dataWatcher.updateObject(6, Byte.valueOf((byte) (showBottom ? 1 : 0))); + } + + public boolean shouldShowBottom() { + return this.dataWatcher.getWatchableObjectByte(6) == 1; + } + + /** + * Checks if the entity is in range to render. + */ + public boolean isInRangeToRenderDist(double distance) { + return super.isInRangeToRenderDist(distance) || this.getBeamTarget() != null; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/player/EntityPlayer.java b/src/main/java/net/minecraft/entity/player/EntityPlayer.java index eeafc6d..acc049e 100644 --- a/src/main/java/net/minecraft/entity/player/EntityPlayer.java +++ b/src/main/java/net/minecraft/entity/player/EntityPlayer.java @@ -16,7 +16,7 @@ import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.command.ICommandSender; -import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.command.server.CommandBlockBaseLogic; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; @@ -65,6 +65,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.stats.AchievementList; import net.minecraft.stats.StatBase; import net.minecraft.stats.StatList; +import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; @@ -1081,7 +1082,10 @@ public abstract class EntityPlayer extends EntityLivingBase implements ICommandS public void openEditSign(TileEntitySign var1) { } - public void openEditCommandBlock(CommandBlockLogic var1) { + public void displayGuiEditCommandCart(CommandBlockBaseLogic p_184809_1_) { + } + + public void displayGuiCommandBlock(TileEntityCommandBlock p_184824_1_) { } public void displayVillagerTradeGui(IMerchant var1) { diff --git a/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java b/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java index 3171224..cf078a9 100644 --- a/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java +++ b/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java @@ -77,6 +77,7 @@ import net.minecraft.stats.StatBase; import net.minecraft.stats.StatList; import net.minecraft.stats.StatisticsFile; import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentTranslation; @@ -290,10 +291,9 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting { .sendPacket(new S42PacketCombatEvent(this.getCombatTracker(), S42PacketCombatEvent.Event.END_COMBAT)); } - protected CooldownTracker createCooldownTracker() - { - return new CooldownTrackerServer(this); - } + protected CooldownTracker createCooldownTracker() { + return new CooldownTrackerServer(this); + } /** * + @@ -613,6 +613,7 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting { private void sendTileEntityUpdate(TileEntity parTileEntity) { if (parTileEntity != null) { Packet packet = parTileEntity.getDescriptionPacket(); + if (packet != null) { this.playerNetServerHandler.sendPacket(packet); } @@ -812,6 +813,13 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting { } + public void displayGuiCommandBlock(TileEntityCommandBlock p_184824_1_) { + // if (this.canCommandSenderUseCommand(2, "")) { + p_184824_1_.setSendToClient(true); + this.sendTileEntityUpdate(p_184824_1_); + // } + } + /** * + * Sends the contents of an inventory slot to the client-side @@ -1220,11 +1228,10 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting { return null; } - public void swingItem() - { - super.swingItem(); - this.resetCooldown(); - } + public void swingItem() { + super.swingItem(); + this.resetCooldown(); + } public void setElytraFlying() { this.setFlag(7, true); diff --git a/src/main/java/net/minecraft/item/Item.java b/src/main/java/net/minecraft/item/Item.java index 644f370..c9837ce 100644 --- a/src/main/java/net/minecraft/item/Item.java +++ b/src/main/java/net/minecraft/item/Item.java @@ -1127,6 +1127,9 @@ public class Item { registerItem(423, (String) "mutton", (new ItemFood(2, 0.3F, true)).setUnlocalizedName("muttonRaw")); registerItem(424, (String) "cooked_mutton", (new ItemFood(6, 0.8F, true)).setUnlocalizedName("muttonCooked")); registerItem(425, (String) "banner", (new ItemBanner()).setUnlocalizedName("banner")); + + registerEaglerItem(426, "end_crystal", new ItemEndCrystal()); + registerItem(427, (String) "spruce_door", (new ItemDoor(Blocks.spruce_door)).setUnlocalizedName("doorSpruce")); registerItem(428, (String) "birch_door", (new ItemDoor(Blocks.birch_door)).setUnlocalizedName("doorBirch")); registerItem(429, (String) "jungle_door", (new ItemDoor(Blocks.jungle_door)).setUnlocalizedName("doorJungle")); diff --git a/src/main/java/net/minecraft/item/ItemEndCrystal.java b/src/main/java/net/minecraft/item/ItemEndCrystal.java new file mode 100644 index 0000000..c43ee23 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemEndCrystal.java @@ -0,0 +1,77 @@ +package net.minecraft.item; + +import java.util.List; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +public class ItemEndCrystal extends Item { + public ItemEndCrystal() { + this.setUnlocalizedName("end_crystal"); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, + EnumFacing facing, float var6, float var7, float var8) { + IBlockState iblockstate = worldIn.getBlockState(pos); + + if (iblockstate.getBlock() != Blocks.obsidian && iblockstate.getBlock() != Blocks.bedrock) { + return false; + } else { + BlockPos blockpos = pos.up(); + + if (!playerIn.canPlayerEdit(blockpos, facing, stack)) { + return false; + } else { + BlockPos blockpos1 = blockpos.up(); + boolean flag = !worldIn.isAirBlock(blockpos) + && !worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos); + flag = flag | (!worldIn.isAirBlock(blockpos1) + && !worldIn.getBlockState(blockpos1).getBlock().isReplaceable(worldIn, blockpos1)); + + if (flag) { + return false; + } else { + double d0 = (double) blockpos.getX(); + double d1 = (double) blockpos.getY(); + double d2 = (double) blockpos.getZ(); + List list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity) null, + new AxisAlignedBB(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); + + if (!list.isEmpty()) { + return false; + } else { + if (!worldIn.isRemote) { + EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(worldIn, + (double) ((float) pos.getX() + 0.5F), (double) (pos.getY() + 1), + (double) ((float) pos.getZ() + 0.5F)); + entityendercrystal.setShowBottom(false); + worldIn.spawnEntityInWorld(entityendercrystal); + // TODO: Uncomment this when new ender dragon fight is implemented + // if (worldIn.provider instanceof WorldProviderEnd) { + // DragonFightManager dragonfightmanager = ((WorldProviderEnd) worldIn.provider) + // .getDragonFightManager(); + // dragonfightmanager.respawnDragon(); + // } + } + + --stack.stackSize; + return true; + } + } + } + } + } + + public boolean hasEffect(ItemStack stack) { + return true; + } +} diff --git a/src/main/java/net/minecraft/nbt/NBTUtil.java b/src/main/java/net/minecraft/nbt/NBTUtil.java index 9e612ff..3848d1d 100644 --- a/src/main/java/net/minecraft/nbt/NBTUtil.java +++ b/src/main/java/net/minecraft/nbt/NBTUtil.java @@ -7,6 +7,7 @@ import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID; import net.lax1dude.eaglercraft.v1_8.mojang.authlib.GameProfile; import net.lax1dude.eaglercraft.v1_8.mojang.authlib.Property; +import net.minecraft.util.BlockPos; import net.minecraft.util.StringUtils; /** @@ -175,4 +176,22 @@ public final class NBTUtil { return parNBTBase.equals(parNBTBase2); } } + + /** + * Creates a BlockPos object from the data stored in the passed NBTTagCompound. + */ + public static BlockPos getPosFromTag(NBTTagCompound tag) { + return new BlockPos(tag.getInteger("X"), tag.getInteger("Y"), tag.getInteger("Z")); + } + + /** + * Creates a new NBTTagCompound from a BlockPos. + */ + public static NBTTagCompound createPosTag(BlockPos pos) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("X", pos.getX()); + nbttagcompound.setInteger("Y", pos.getY()); + nbttagcompound.setInteger("Z", pos.getZ()); + return nbttagcompound; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/NetHandlerPlayServer.java b/src/main/java/net/minecraft/network/NetHandlerPlayServer.java index 6df74dd..a67a46f 100644 --- a/src/main/java/net/minecraft/network/NetHandlerPlayServer.java +++ b/src/main/java/net/minecraft/network/NetHandlerPlayServer.java @@ -12,8 +12,10 @@ import java.util.Set; import java.util.concurrent.Callable; import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerMinecraftServer; +import net.minecraft.block.BlockCommandBlock; import net.minecraft.block.material.Material; -import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.block.state.IBlockState; +import net.minecraft.command.server.CommandBlockBaseLogic; import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.entity.Entity; @@ -25,6 +27,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerBeacon; @@ -1210,7 +1213,7 @@ public class NetHandlerPlayServer implements INetHandlerPlayServer, ITickable { } catch (Exception exception2) { logger.error("Couldn\'t select trade", exception2); } - } else if ("MC|AdvCdm".equals(c17packetcustompayload.getChannelName())) { + } else if ("MC|AdvCmd".equals(c17packetcustompayload.getChannelName())) { if (!this.serverController.isCommandBlockEnabled()) { this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notEnabled", new Object[0])); } else if (this.playerEntity.canCommandSenderUseCommand(2, "") @@ -1219,7 +1222,7 @@ public class NetHandlerPlayServer implements INetHandlerPlayServer, ITickable { try { byte b0 = packetbuffer.readByte(); - CommandBlockLogic commandblocklogic = null; + CommandBlockBaseLogic commandblocklogic = null; if (b0 == 0) { TileEntity tileentity = this.playerEntity.worldObj.getTileEntity( new BlockPos(packetbuffer.readInt(), packetbuffer.readInt(), packetbuffer.readInt())); @@ -1252,6 +1255,90 @@ public class NetHandlerPlayServer implements INetHandlerPlayServer, ITickable { } else { this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notAllowed", new Object[0])); } + } else if ("MC|AutoCmd".equals(c17packetcustompayload.getChannelName())) { + if (!this.serverController.isCommandBlockEnabled()) { + this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notEnabled", new Object[0])); + return; + } + + if (!this.playerEntity.canCommandSenderUseCommand(2, "") + || !this.playerEntity.capabilities.isCreativeMode) { + this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notAllowed", new Object[0])); + return; + } + + PacketBuffer packetbuffer1 = c17packetcustompayload.getBufferData(); + + try { + CommandBlockBaseLogic commandblockbaselogic1 = null; + TileEntityCommandBlock tileentitycommandblock = null; + BlockPos blockpos1 = new BlockPos(packetbuffer1.readInt(), packetbuffer1.readInt(), + packetbuffer1.readInt()); + TileEntity tileentity2 = this.playerEntity.worldObj.getTileEntity(blockpos1); + + if (tileentity2 instanceof TileEntityCommandBlock) { + tileentitycommandblock = (TileEntityCommandBlock) tileentity2; + commandblockbaselogic1 = tileentitycommandblock.getCommandBlockLogic(); + } + + String s1 = packetbuffer1.readStringFromBuffer(packetbuffer1.readableBytes()); + boolean flag1 = packetbuffer1.readBoolean(); + TileEntityCommandBlock.Mode tileentitycommandblock$mode = TileEntityCommandBlock.Mode + .valueOf(packetbuffer1.readStringFromBuffer(16)); + boolean flag2 = packetbuffer1.readBoolean(); + boolean flag3 = packetbuffer1.readBoolean(); + + if (commandblockbaselogic1 != null) { + EnumFacing enumfacing = (EnumFacing) this.playerEntity.worldObj.getBlockState(blockpos1) + .getValue(BlockCommandBlock.FACING); + + switch (tileentitycommandblock$mode) { + case SEQUENCE: + IBlockState iblockstate3 = EaglerItems.getEaglerBlock("chain_command_block") + .getDefaultState(); + this.playerEntity.worldObj.setBlockState(blockpos1, + iblockstate3.withProperty(BlockCommandBlock.FACING, enumfacing) + .withProperty(BlockCommandBlock.CONDITIONAL, Boolean.valueOf(flag2)), + 2); + break; + + case AUTO: + IBlockState iblockstate2 = EaglerItems.getEaglerBlock("repeating_command_block") + .getDefaultState(); + this.playerEntity.worldObj.setBlockState(blockpos1, + iblockstate2.withProperty(BlockCommandBlock.FACING, enumfacing) + .withProperty(BlockCommandBlock.CONDITIONAL, Boolean.valueOf(flag2)), + 2); + break; + + case REDSTONE: + IBlockState lvt_14_1_ = Blocks.command_block.getDefaultState(); + this.playerEntity.worldObj.setBlockState(blockpos1, + lvt_14_1_.withProperty(BlockCommandBlock.FACING, enumfacing) + .withProperty(BlockCommandBlock.CONDITIONAL, Boolean.valueOf(flag2)), + 2); + } + + tileentity2.validate(); + this.playerEntity.worldObj.setTileEntity(blockpos1, tileentity2); + commandblockbaselogic1.setCommand(s1); + commandblockbaselogic1.setTrackOutput(flag1); + + if (!flag1) { + commandblockbaselogic1.setLastOutput((IChatComponent) null); + } + + tileentitycommandblock.setAuto(flag3); + commandblockbaselogic1.updateCommand(); + + if (!net.minecraft.util.StringUtils.isNullOrEmpty(s1)) { + this.playerEntity.addChatMessage( + new ChatComponentTranslation("advMode.setCommand.success", new Object[] { s1 })); + } + } + } catch (Exception exception3) { + logger.error((String) "Couldn\'t set command block", (Throwable) exception3); + } } else if ("MC|Beacon".equals(c17packetcustompayload.getChannelName())) { if (this.playerEntity.openContainer instanceof ContainerBeacon) { try { diff --git a/src/main/java/net/minecraft/network/play/client/C14PacketTabComplete.java b/src/main/java/net/minecraft/network/play/client/C14PacketTabComplete.java index 7f6a1bf..0d6154f 100644 --- a/src/main/java/net/minecraft/network/play/client/C14PacketTabComplete.java +++ b/src/main/java/net/minecraft/network/play/client/C14PacketTabComplete.java @@ -2,6 +2,8 @@ package net.minecraft.network.play.client; import java.io.IOException; +import javax.annotation.Nullable; + import org.apache.commons.lang3.StringUtils; import net.minecraft.network.Packet; @@ -41,17 +43,15 @@ import net.minecraft.util.BlockPos; public class C14PacketTabComplete implements Packet { private String message; private BlockPos targetBlock; + private boolean hasTargetBlock; public C14PacketTabComplete() { } - public C14PacketTabComplete(String msg) { - this(msg, (BlockPos) null); - } - - public C14PacketTabComplete(String msg, BlockPos target) { + public C14PacketTabComplete(String msg, @Nullable BlockPos target, boolean hasTargetBlock) { this.message = msg; this.targetBlock = target; + this.hasTargetBlock = hasTargetBlock; } /** @@ -60,6 +60,7 @@ public class C14PacketTabComplete implements Packet { */ public void readPacketData(PacketBuffer parPacketBuffer) throws IOException { this.message = parPacketBuffer.readStringFromBuffer(32767); + this.hasTargetBlock = parPacketBuffer.readBoolean(); boolean flag = parPacketBuffer.readBoolean(); if (flag) { this.targetBlock = parPacketBuffer.readBlockPos(); @@ -73,6 +74,7 @@ public class C14PacketTabComplete implements Packet { */ public void writePacketData(PacketBuffer parPacketBuffer) throws IOException { parPacketBuffer.writeString(StringUtils.substring(this.message, 0, 32767)); + parPacketBuffer.writeBoolean(this.hasTargetBlock); boolean flag = this.targetBlock != null; parPacketBuffer.writeBoolean(flag); if (flag) { diff --git a/src/main/java/net/minecraft/network/play/server/S3APacketTabComplete.java b/src/main/java/net/minecraft/network/play/server/S3APacketTabComplete.java index 5ca5b39..5f6446b 100644 --- a/src/main/java/net/minecraft/network/play/server/S3APacketTabComplete.java +++ b/src/main/java/net/minecraft/network/play/server/S3APacketTabComplete.java @@ -79,7 +79,7 @@ public class S3APacketTabComplete implements Packet { inethandlerplayclient.handleTabComplete(this); } - public String[] func_149630_c() { + public String[] getMatches() { return this.matches; } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityCommandBlock.java b/src/main/java/net/minecraft/tileentity/TileEntityCommandBlock.java index 0c2f1ed..68437ae 100644 --- a/src/main/java/net/minecraft/tileentity/TileEntityCommandBlock.java +++ b/src/main/java/net/minecraft/tileentity/TileEntityCommandBlock.java @@ -1,15 +1,22 @@ package net.minecraft.tileentity; +import net.hoosiertransfer.EaglerItems; import net.lax1dude.eaglercraft.v1_8.netty.ByteBuf; +import net.minecraft.block.Block; +import net.minecraft.block.BlockCommandBlock; +import net.minecraft.block.state.IBlockState; import net.minecraft.command.CommandResultStats; -import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.command.server.CommandBlockBaseLogic; import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.BlockPos; import net.minecraft.util.Vec3; import net.minecraft.world.World; +import net.minecraft.world.WorldServer; /** * + @@ -41,7 +48,11 @@ import net.minecraft.world.World; * */ public class TileEntityCommandBlock extends TileEntity { - private final CommandBlockLogic commandBlockLogic = new CommandBlockLogic() { + private boolean powered; + private boolean auto; + private boolean conditionMet; + private boolean sendToClient; + private final CommandBlockBaseLogic commandBlockLogic = new CommandBlockBaseLogic() { public BlockPos getPosition() { return TileEntityCommandBlock.this.pos; } @@ -65,11 +76,11 @@ public class TileEntityCommandBlock extends TileEntity { TileEntityCommandBlock.this.getWorld().markBlockForUpdate(TileEntityCommandBlock.this.pos); } - public int func_145751_f() { + public int getCommandBlockType() { return 0; } - public void func_145757_a(ByteBuf bytebuf) { + public void fillInInfo(ByteBuf bytebuf) { bytebuf.writeInt(TileEntityCommandBlock.this.pos.getX()); bytebuf.writeInt(TileEntityCommandBlock.this.pos.getY()); bytebuf.writeInt(TileEntityCommandBlock.this.pos.getZ()); @@ -78,16 +89,26 @@ public class TileEntityCommandBlock extends TileEntity { public Entity getCommandSenderEntity() { return null; } + + public MinecraftServer getServer() { + return ((WorldServer) TileEntityCommandBlock.this.getWorld()).getMinecraftServer(); + } }; public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); this.commandBlockLogic.writeDataToNBT(nbttagcompound); + nbttagcompound.setBoolean("powered", this.isPowered()); + nbttagcompound.setBoolean("conditionMet", this.isConditionMet()); + nbttagcompound.setBoolean("auto", this.isAuto()); } public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); this.commandBlockLogic.readDataFromNBT(nbttagcompound); + this.setPowered(nbttagcompound.getBoolean("powered")); + this.setConditionMet(nbttagcompound.getBoolean("conditionMet")); + this.setAuto(nbttagcompound.getBoolean("auto")); } /** @@ -98,20 +119,106 @@ public class TileEntityCommandBlock extends TileEntity { * synchronise the text to be displayed. */ public Packet getDescriptionPacket() { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - this.writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(this.pos, 2, nbttagcompound); + if (this.isSendToClient()) { + this.setSendToClient(false); + + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.pos, 2, nbttagcompound); + } else { + return null; + } } public boolean func_183000_F() { return true; } - public CommandBlockLogic getCommandBlockLogic() { + public CommandBlockBaseLogic getCommandBlockLogic() { return this.commandBlockLogic; } public CommandResultStats getCommandResultStats() { return this.commandBlockLogic.getCommandResultStats(); } + + public void setPowered(boolean poweredIn) { + this.powered = poweredIn; + } + + public boolean isPowered() { + return this.powered; + } + + public boolean isAuto() { + return this.auto; + } + + public void setAuto(boolean autoIn) { + boolean flag = this.auto; + this.auto = autoIn; + + if (!flag && autoIn && !this.powered && this.worldObj != null + && this.getMode() != TileEntityCommandBlock.Mode.SEQUENCE) { + Block block = this.getBlockType(); + + if (block instanceof BlockCommandBlock) { + BlockPos blockpos = this.getPos(); + BlockCommandBlock blockcommandblock = (BlockCommandBlock) block; + this.conditionMet = !this.isConditional() || blockcommandblock + .isNextToSuccessfulCommandBlock(this.worldObj, blockpos, this.worldObj.getBlockState(blockpos)); + this.worldObj.scheduleUpdate(blockpos, block, block.tickRate(this.worldObj)); + + if (this.conditionMet) { + blockcommandblock.propagateUpdate(this.worldObj, blockpos); + } + } + } + } + + public boolean isConditionMet() { + return this.conditionMet; + } + + public void setConditionMet(boolean conditionMetIn) { + this.conditionMet = conditionMetIn; + } + + public boolean isSendToClient() { + return this.sendToClient; + } + + public void setSendToClient(boolean p_184252_1_) { + this.sendToClient = p_184252_1_; + } + + public TileEntityCommandBlock.Mode getMode() { + Block block = this.getBlockType(); + return block == Blocks.command_block ? TileEntityCommandBlock.Mode.REDSTONE + : (block == EaglerItems.getEaglerBlock("repeating_command_block") ? TileEntityCommandBlock.Mode.AUTO + : (block == EaglerItems.getEaglerBlock("chain_command_block") + ? TileEntityCommandBlock.Mode.SEQUENCE + : TileEntityCommandBlock.Mode.REDSTONE)); + } + + public boolean isConditional() { + IBlockState iblockstate = this.worldObj.getBlockState(this.getPos()); + return iblockstate.getBlock() instanceof BlockCommandBlock + ? ((Boolean) iblockstate.getValue(BlockCommandBlock.CONDITIONAL)).booleanValue() + : false; + } + + /** + * validates a tile entity + */ + public void validate() { + this.blockType = null; + super.validate(); + } + + public static enum Mode { + SEQUENCE, + AUTO, + REDSTONE; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/BlockPos.java b/src/main/java/net/minecraft/util/BlockPos.java index 359c215..7ae4952 100644 --- a/src/main/java/net/minecraft/util/BlockPos.java +++ b/src/main/java/net/minecraft/util/BlockPos.java @@ -465,6 +465,10 @@ public class BlockPos extends Vec3i { super(x_, y_, z_); } + public MutableBlockPos(BlockPos pos) { + this(pos.getX(), pos.getY(), pos.getZ()); + } + public int getX() { return this.x; } diff --git a/src/main/java/net/minecraft/util/ITabCompleter.java b/src/main/java/net/minecraft/util/ITabCompleter.java new file mode 100644 index 0000000..d560524 --- /dev/null +++ b/src/main/java/net/minecraft/util/ITabCompleter.java @@ -0,0 +1,8 @@ +package net.minecraft.util; + +public interface ITabCompleter { + /** + * Sets the list of tab completions, as long as they were previously requested. + */ + void setCompletions(String... newCompletions); +} diff --git a/src/main/java/net/minecraft/util/TabCompleter.java b/src/main/java/net/minecraft/util/TabCompleter.java new file mode 100644 index 0000000..1e1c5a3 --- /dev/null +++ b/src/main/java/net/minecraft/util/TabCompleter.java @@ -0,0 +1,110 @@ +package net.minecraft.util; + +import com.google.common.collect.Lists; +import java.util.List; +import javax.annotation.Nullable; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.network.play.client.C14PacketTabComplete; +import net.minecraft.util.BlockPos; + +public abstract class TabCompleter { + /** The {@link GuiTextField} that is backing this {@link TabCompleter} */ + protected final GuiTextField textField; + protected final boolean hasTargetBlock; + protected boolean didComplete; + protected boolean requestedCompletions; + protected int completionIdx; + protected List completions = Lists.newArrayList(); + + public TabCompleter(GuiTextField textFieldIn, boolean hasTargetBlockIn) { + this.textField = textFieldIn; + this.hasTargetBlock = hasTargetBlockIn; + } + + /** + * Called when tab key pressed. If it's the first time we tried to complete this + * string, we ask the server for + * completions. When the server responds, this method gets called again (via + * setCompletions). + */ + public void complete() { + if (this.didComplete) { + this.textField + .deleteFromCursor(this.textField.getNthWordFromPosWS(-1, this.textField.getCursorPosition(), false) + - this.textField.getCursorPosition()); + + if (this.completionIdx >= this.completions.size()) { + this.completionIdx = 0; + } + } else { + int i = this.textField.getNthWordFromPosWS(-1, this.textField.getCursorPosition(), false); + this.completions.clear(); + this.completionIdx = 0; + String s = this.textField.getText().substring(0, this.textField.getCursorPosition()); + this.requestCompletions(s); + + if (this.completions.isEmpty()) { + return; + } + + this.didComplete = true; + this.textField.deleteFromCursor(i - this.textField.getCursorPosition()); + } + + this.textField.writeText((String) this.completions.get(this.completionIdx++)); + } + + private void requestCompletions(String prefix) { + if (prefix.length() >= 1) { + Minecraft.getMinecraft().thePlayer.sendQueue + .addToSendQueue(new C14PacketTabComplete(prefix, this.getTargetBlockPos(), this.hasTargetBlock)); + this.requestedCompletions = true; + } + } + + @Nullable + public abstract BlockPos getTargetBlockPos(); + + /** + * Only actually sets completions if they were requested (via + * requestCompletions) + */ + public void setCompletions(String[] newCompl) { + if (this.requestedCompletions) { + this.didComplete = false; + this.completions.clear(); + + for (String s : newCompl) { + if (!s.isEmpty()) { + this.completions.add(s); + } + } + + String s1 = this.textField.getText() + .substring(this.textField.getNthWordFromPosWS(-1, this.textField.getCursorPosition(), false)); + String s2 = org.apache.commons.lang3.StringUtils.getCommonPrefix(newCompl); + + if (!s2.isEmpty() && !s1.equalsIgnoreCase(s2)) { + this.textField.deleteFromCursor( + this.textField.getNthWordFromPosWS(-1, this.textField.getCursorPosition(), false) + - this.textField.getCursorPosition()); + this.textField.writeText(s2); + } else if (!this.completions.isEmpty()) { + this.didComplete = true; + this.complete(); + } + } + } + + /** + * Called when new text is entered, or backspace pressed + */ + public void resetDidComplete() { + this.didComplete = false; + } + + public void resetRequested() { + this.requestedCompletions = false; + } +} diff --git a/src/main/java/net/minecraft/world/World.java b/src/main/java/net/minecraft/world/World.java index ca8607f..9914acd 100644 --- a/src/main/java/net/minecraft/world/World.java +++ b/src/main/java/net/minecraft/world/World.java @@ -1352,6 +1352,10 @@ public abstract class World implements IBlockAccess, ILightingEngineProvider, IL return f1 * f1 * 0.5F; } + public boolean isUpdateScheduled(BlockPos pos, Block blk) { + return true; + } + public void scheduleUpdate(BlockPos pos, Block blockIn, int delay) { } @@ -2048,8 +2052,12 @@ public abstract class World implements IBlockAccess, ILightingEngineProvider, IL public static boolean doesBlockHaveSolidTopSurface(IBlockAccess blockAccess, BlockPos pos) { IBlockState iblockstate = blockAccess.getBlockState(pos); Block block = iblockstate.getBlock(); - if (block instanceof BlockPistonExtension && iblockstate.getValue(BlockPistonExtension.FACING) == EnumFacing.UP) return true; - if (block instanceof BlockPistonBase && (!((Boolean)iblockstate.getValue(BlockPistonBase.EXTENDED)).booleanValue() || iblockstate.getValue(BlockPistonBase.FACING) == EnumFacing.DOWN)) return true; + if (block instanceof BlockPistonExtension && iblockstate.getValue(BlockPistonExtension.FACING) == EnumFacing.UP) + return true; + if (block instanceof BlockPistonBase + && (!((Boolean) iblockstate.getValue(BlockPistonBase.EXTENDED)).booleanValue() + || iblockstate.getValue(BlockPistonBase.FACING) == EnumFacing.DOWN)) + return true; return block.getMaterial().isOpaque() && block.isFullCube() ? true : (block instanceof BlockStairs ? iblockstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP : (block instanceof BlockSlab diff --git a/src/main/java/net/minecraft/world/WorldServer.java b/src/main/java/net/minecraft/world/WorldServer.java index b6e3134..53baab1 100644 --- a/src/main/java/net/minecraft/world/WorldServer.java +++ b/src/main/java/net/minecraft/world/WorldServer.java @@ -444,6 +444,14 @@ public class WorldServer extends World implements IThreadListener { return this.pendingTickListEntriesThisTick.contains(nextticklistentry); } + /** + * Returns true if the identified block is scheduled to be updated. + */ + public boolean isUpdateScheduled(BlockPos pos, Block blk) { + NextTickListEntry nextticklistentry = new NextTickListEntry(pos, blk); + return this.pendingTickListEntriesHashSet.contains(nextticklistentry); + } + public void scheduleUpdate(BlockPos blockpos, Block block, int i) { this.updateBlockTick(blockpos, block, i, 0); }