1.9 command blocks

This commit is contained in:
HoosierTransfer 2024-07-09 14:57:14 -04:00
parent a863b8a73f
commit af93e51d29
75 changed files with 1637 additions and 354 deletions

View File

@ -3,12 +3,12 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="EaglercraftX 1.8 test directory HTML page" /> <meta name="description" content="EaglercraftL 1.9 test directory HTML page" />
<meta name="keywords" content="eaglercraft, eaglercraftx, minecraft, 1.8, 1.8.8" /> <meta name="keywords" content="eaglercraft, eaglercraftx, minecraft, 1.9, 1.9.4" />
<title>EaglercraftX 1.8</title> <title>EaglercraftL 1.9</title>
<meta property="og:locale" content="en-US" /> <meta property="og:locale" content="en-US" />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:title" content="EaglercraftX 1.8" /> <meta property="og:title" content="EaglercraftL 1.9" />
<meta property="og:description" content="test directory HTML page" /> <meta property="og:description" content="test directory HTML page" />
<link type="image/png" rel="shortcut icon" href="favicon.png" /> <link type="image/png" rel="shortcut icon" href="favicon.png" />
<script type="text/javascript" src="classes.js"></script> <script type="text/javascript" src="classes.js"></script>

View File

@ -26,7 +26,7 @@
- Created the replit - Created the replit
hoosiertransfer: hoosiertransfer:
- Ported 1.9 features to 1.8
- Many memory optimizations - Many memory optimizations
- Bug fixes - Bug fixes
- Faster lighting engine - Faster lighting engine

View File

@ -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 }
}
}

View File

@ -1,5 +1,16 @@
{ {
"variants": { "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 }
} }
} }

View File

@ -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 }
}
}

View File

@ -1322,7 +1322,6 @@ tile.blockEmerald.name=Block of Emerald
tile.blockRedstone.name=Block of Redstone tile.blockRedstone.name=Block of Redstone
tile.tripWire.name=Tripwire tile.tripWire.name=Tripwire
tile.tripWireSource.name=Tripwire Hook tile.tripWireSource.name=Tripwire Hook
tile.commandBlock.name=Command Block
tile.beacon.name=Beacon tile.beacon.name=Beacon
tile.beacon.primary=Primary Power tile.beacon.primary=Primary Power
tile.beacon.secondary=Secondary Power tile.beacon.secondary=Secondary Power
@ -1920,6 +1919,7 @@ stat.minecartOneCm=Distance by Minecart
stat.boatOneCm=Distance by Boat stat.boatOneCm=Distance by Boat
stat.pigOneCm=Distance by Pig stat.pigOneCm=Distance by Pig
stat.horseOneCm=Distance by Horse stat.horseOneCm=Distance by Horse
stat.aviateOneCm=Distance by Elytra
stat.jump=Jumps stat.jump=Jumps
stat.drop=Items Dropped stat.drop=Items Dropped
@ -3183,15 +3183,17 @@ item.banner.straight_cross.white=White Cross
tile.purpurBlock.name=Purpur Block tile.purpurBlock.name=Purpur Block
tile.purpurPillar.name=Purpur Pillar tile.purpurPillar.name=Purpur Pillar
tile.purpurStairs.name=Purpur Stairs tile.stairsPurpur.name=Purpur Stairs
tile.purpurSlab.name=Purpur Slab tile.purpurSlab.name=Purpur Slab
tile.purpurSlab.default.name=Purpur Slab tile.purpurSlab.default.name=Purpur Slab
tile.purpurStairs.name=Purpur Stairs
tile.endRod.name=End Rod tile.endRod.name=End Rod
tile.chorusPlant.name=Chorus Plant tile.chorusPlant.name=Chorus Plant
tile.chorusFlower.name=Chorus Flower tile.chorusFlower.name=Chorus Flower
tile.grassPath.name=Grass Path tile.grassPath.name=Grass Path
tile.endBricks.name=End Stone Bricks 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.chorusFruit.name=Chorus Fruit
item.chorusFruitPopped.name=Popped Chorus Fruit item.chorusFruitPopped.name=Popped Chorus Fruit
@ -3199,3 +3201,23 @@ item.beetroot.name=Beetroot
item.beetroot_seeds.name=Beetroot Seeds item.beetroot_seeds.name=Beetroot Seeds
item.beetroot_soup.name=Beetroot Soup item.beetroot_soup.name=Beetroot Soup
item.elytra.name=Elytra 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

View File

@ -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"
}
}

View File

@ -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"
}
}

View File

@ -1,6 +1,12 @@
{ {
"parent": "block/cube_all", "parent": "block/cube_directional",
"textures": { "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"
} }
} }

View File

@ -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"
}
}

View File

@ -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 }
}
}
]
}

View File

@ -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"
}
}

View File

@ -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"
}
}

View File

@ -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 ]
}
}
}

View File

@ -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 ]
}
}
}

View File

@ -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 ]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

View File

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

View File

@ -366,8 +366,8 @@ public class Block implements ILitBlock {
return true; return true;
} }
public boolean isFullyOpaque(IBlockState state) { public boolean isFullyOpaque(IBlockState state) {
return state.getBlock().getMaterial().isOpaque() && state.getBlock().isFullCube(); return state.getBlock().getMaterial().isOpaque() && state.getBlock().isFullCube();
} }
public boolean isPassable(IBlockAccess var1, BlockPos var2) { public boolean isPassable(IBlockAccess var1, BlockPos var2) {
@ -1234,7 +1234,8 @@ public class Block implements ILitBlock {
registerBlock(6, (String) "sapling", registerBlock(6, (String) "sapling",
(new BlockSapling()).setHardness(0.0F).setStepSound(soundTypeGrass).setUnlocalizedName("sapling")); (new BlockSapling()).setHardness(0.0F).setStepSound(soundTypeGrass).setUnlocalizedName("sapling"));
registerBlock(7, (String) "bedrock", 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)); .setUnlocalizedName("bedrock").disableStats().setCreativeTab(CreativeTabs.tabBlock));
registerBlock(8, (String) "flowing_water", (new BlockDynamicLiquid(Material.water)).setHardness(100.0F) registerBlock(8, (String) "flowing_water", (new BlockDynamicLiquid(Material.water)).setHardness(100.0F)
.setLightOpacity(3).setUnlocalizedName("water").disableStats()); .setLightOpacity(3).setUnlocalizedName("water").disableStats());
@ -1521,7 +1522,7 @@ public class Block implements ILitBlock {
(new BlockStairs( (new BlockStairs(
block1.getDefaultState().withProperty(BlockPlanks.VARIANT, BlockPlanks.EnumType.JUNGLE))) block1.getDefaultState().withProperty(BlockPlanks.VARIANT, BlockPlanks.EnumType.JUNGLE)))
.setUnlocalizedName("stairsWoodJungle")); .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")); .setResistance(6000000.0F).setUnlocalizedName("commandBlock"));
registerBlock(138, (String) "beacon", (new BlockBeacon()).setUnlocalizedName("beacon").setLightLevel(1.0F)); registerBlock(138, (String) "beacon", (new BlockBeacon()).setUnlocalizedName("beacon").setLightLevel(1.0F));
registerBlock(139, (String) "cobblestone_wall", (new BlockWall(block)).setUnlocalizedName("cobbleWall")); registerBlock(139, (String) "cobblestone_wall", (new BlockWall(block)).setUnlocalizedName("cobbleWall"));
@ -1690,6 +1691,14 @@ public class Block implements ILitBlock {
.setUnlocalizedName("grassPath").disableStats(); .setUnlocalizedName("grassPath").disableStats();
registerEaglerBlock(208, "grass_path", grassPath); 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) registerEaglerBlock(212, "frosted_ice", (new BlockFrostedIce()).setHardness(0.5F).setLightOpacity(3)
.setStepSound(soundTypeGlass).setUnlocalizedName("frostedIce"), false); .setStepSound(soundTypeGlass).setUnlocalizedName("frostedIce"), false);

View File

@ -1,21 +1,26 @@
package net.minecraft.block; package net.minecraft.block;
import net.hoosiertransfer.EaglerItems;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState; 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.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.StringUtils;
import net.minecraft.world.World; import net.minecraft.world.World;
/** /**
@ -48,11 +53,19 @@ import net.minecraft.world.World;
* *
*/ */
public class BlockCommandBlock extends BlockContainer { 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() { public BlockCommandBlock() {
super(Material.iron, MapColor.adobeColor); 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 * Returns a new instance of a block's tile entity class. Called
* on placing the block. * on placing the block.
*/ */
public TileEntity createNewTileEntity(World var1, int var2) { public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityCommandBlock(); 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) { public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState iblockstate, Block var4) {
if (!world.isRemote) { if (!world.isRemote) {
boolean flag = world.isBlockPowered(blockpos); TileEntity tileentity = world.getTileEntity(blockpos);
boolean flag1 = ((Boolean) iblockstate.getValue(TRIGGERED)).booleanValue();
if (flag && !flag1) { if (tileentity instanceof TileEntityCommandBlock) {
world.setBlockState(blockpos, iblockstate.withProperty(TRIGGERED, Boolean.valueOf(true)), 4); TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock) tileentity;
world.scheduleUpdate(blockpos, this, this.tickRate(world)); boolean flag = world.isBlockPowered(blockpos);
} else if (!flag && flag1) { boolean flag1 = tileentitycommandblock.isPowered();
world.setBlockState(blockpos, iblockstate.withProperty(TRIGGERED, Boolean.valueOf(false)), 4); 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) { public void updateTick(World worldIn, BlockPos pos, IBlockState state, EaglercraftRandom rand) {
TileEntity tileentity = world.getTileEntity(blockpos); if (!worldIn.isRemote) {
if (tileentity instanceof TileEntityCommandBlock) { TileEntity tileentity = worldIn.getTileEntity(pos);
((TileEntityCommandBlock) tileentity).getCommandBlockLogic().trigger(world);
world.updateComparatorOutputLevel(blockpos, this);
}
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, public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
EnumFacing var5, float var6, float var7, float var8) { EnumFacing var5, float var6, float var7, float var8) {
TileEntity tileentity = world.getTileEntity(blockpos); TileEntity tileentity = world.getTileEntity(blockpos);
return tileentity instanceof TileEntityCommandBlock
? ((TileEntityCommandBlock) tileentity).getCommandBlockLogic().tryOpenEditCommandBlock(entityplayer) if (tileentity instanceof TileEntityCommandBlock) {
: false; if (!entityplayer.capabilities.isCreativeMode) {
return false;
} else {
entityplayer.displayGuiCommandBlock((TileEntityCommandBlock) tileentity);
return true;
}
} else {
return false;
}
} }
public boolean hasComparatorInputOverride() { public boolean hasComparatorInputOverride() {
@ -125,14 +211,27 @@ public class BlockCommandBlock extends BlockContainer {
public void onBlockPlacedBy(World world, BlockPos blockpos, IBlockState var3, EntityLivingBase var4, public void onBlockPlacedBy(World world, BlockPos blockpos, IBlockState var3, EntityLivingBase var4,
ItemStack itemstack) { ItemStack itemstack) {
TileEntity tileentity = world.getTileEntity(blockpos); TileEntity tileentity = world.getTileEntity(blockpos);
if (tileentity instanceof TileEntityCommandBlock) { if (tileentity instanceof TileEntityCommandBlock) {
CommandBlockLogic commandblocklogic = ((TileEntityCommandBlock) tileentity).getCommandBlockLogic(); TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock) tileentity;
CommandBlockBaseLogic commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic();
if (itemstack.hasDisplayName()) { if (itemstack.hasDisplayName()) {
commandblocklogic.setName(itemstack.getDisplayName()); commandblockbaselogic.setName(itemstack.getDisplayName());
} }
if (!world.isRemote) { 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 * Convert the given metadata into a BlockState for this Block
*/ */
public IBlockState getStateFromMeta(int i) { public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(TRIGGERED, Boolean.valueOf((i & 1) > 0)); return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta & 7)).withProperty(CONDITIONAL,
Boolean.valueOf((meta & 8) != 0));
} }
/** /**
* + * +
* Convert the BlockState into the correct metadata value * Convert the BlockState into the correct metadata value
*/ */
public int getMetaFromState(IBlockState iblockstate) { public int getMetaFromState(IBlockState state) {
int i = 0; return ((EnumFacing) state.getValue(FACING)).getIndex()
if (((Boolean) iblockstate.getValue(TRIGGERED)).booleanValue()) { | (((Boolean) state.getValue(CONDITIONAL)).booleanValue() ? 8 : 0);
i |= 1;
}
return i;
} }
protected BlockState createBlockState() { 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, public IBlockState onBlockPlaced(World var1, BlockPos var2, EnumFacing var3, float var4, float var5, float var6,
int var7, EntityLivingBase var8) { 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));
}
}
} }
} }

View File

@ -187,7 +187,7 @@ public class BlockDispenser extends BlockContainer {
public IBlockState onBlockPlaced(World world, BlockPos blockpos, EnumFacing var3, float var4, float var5, public IBlockState onBlockPlaced(World world, BlockPos blockpos, EnumFacing var3, float var4, float var5,
float var6, int var7, EntityLivingBase entitylivingbase) { float var6, int var7, EntityLivingBase entitylivingbase) {
return this.getDefaultState() return this.getDefaultState()
.withProperty(FACING, BlockPistonBase.getFacingFromEntity(world, blockpos, entitylivingbase)) .withProperty(FACING, BlockPistonBase.getFacingFromEntity(blockpos, entitylivingbase))
.withProperty(TRIGGERED, Boolean.valueOf(false)); .withProperty(TRIGGERED, Boolean.valueOf(false));
} }
@ -199,7 +199,7 @@ public class BlockDispenser extends BlockContainer {
public void onBlockPlacedBy(World world, BlockPos blockpos, IBlockState iblockstate, public void onBlockPlacedBy(World world, BlockPos blockpos, IBlockState iblockstate,
EntityLivingBase entitylivingbase, ItemStack itemstack) { EntityLivingBase entitylivingbase, ItemStack itemstack) {
world.setBlockState(blockpos, iblockstate.withProperty(FACING, world.setBlockState(blockpos, iblockstate.withProperty(FACING,
BlockPistonBase.getFacingFromEntity(world, blockpos, entitylivingbase)), 2); BlockPistonBase.getFacingFromEntity(blockpos, entitylivingbase)), 2);
if (itemstack.hasDisplayName()) { if (itemstack.hasDisplayName()) {
TileEntity tileentity = world.getTileEntity(blockpos); TileEntity tileentity = world.getTileEntity(blockpos);
if (tileentity instanceof TileEntityDispenser) { if (tileentity instanceof TileEntityDispenser) {

View File

@ -84,7 +84,7 @@ public class BlockPistonBase extends Block {
public void onBlockPlacedBy(World world, BlockPos blockpos, IBlockState iblockstate, public void onBlockPlacedBy(World world, BlockPos blockpos, IBlockState iblockstate,
EntityLivingBase entitylivingbase, ItemStack var5) { EntityLivingBase entitylivingbase, ItemStack var5) {
world.setBlockState(blockpos, world.setBlockState(blockpos,
iblockstate.withProperty(FACING, getFacingFromEntity(world, blockpos, entitylivingbase)), 2); iblockstate.withProperty(FACING, getFacingFromEntity(blockpos, entitylivingbase)), 2);
if (!world.isRemote) { if (!world.isRemote) {
this.checkForMove(world, blockpos, iblockstate); 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, public IBlockState onBlockPlaced(World world, BlockPos blockpos, EnumFacing var3, float var4, float var5,
float var6, int var7, EntityLivingBase entitylivingbase) { 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)); .withProperty(EXTENDED, Boolean.valueOf(false));
} }
@ -298,20 +298,21 @@ public class BlockPistonBase extends Block {
return i > 5 ? null : EnumFacing.getFront(i); return i > 5 ? null : EnumFacing.getFront(i);
} }
public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn) { public static EnumFacing getFacingFromEntity(BlockPos pos, EntityLivingBase p_185647_1_) {
if (MathHelper.abs((float) entityIn.posX - (float) clickedBlock.getX()) < 2.0F if (MathHelper.abs((float) p_185647_1_.posX - (float) pos.getX()) < 2.0F
&& MathHelper.abs((float) entityIn.posZ - (float) clickedBlock.getZ()) < 2.0F) { && MathHelper.abs((float) p_185647_1_.posZ - (float) pos.getZ()) < 2.0F) {
double d0 = entityIn.posY + (double) entityIn.getEyeHeight(); double d0 = p_185647_1_.posY + (double) p_185647_1_.getEyeHeight();
if (d0 - (double) clickedBlock.getY() > 2.0D) {
if (d0 - (double) pos.getY() > 2.0D) {
return EnumFacing.UP; return EnumFacing.UP;
} }
if ((double) clickedBlock.getY() - d0 > 0.0D) { if ((double) pos.getY() - d0 > 0.0D) {
return EnumFacing.DOWN; 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, public static boolean canPush(Block blockIn, World worldIn, BlockPos pos, EnumFacing direction,

View File

@ -19,11 +19,12 @@ import net.minecraft.client.gui.inventory.GuiBrewingStand;
import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiCrafting; import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.client.gui.inventory.GuiDispenser; 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.GuiEditSign;
import net.minecraft.client.gui.inventory.GuiFurnace; import net.minecraft.client.gui.inventory.GuiFurnace;
import net.minecraft.client.gui.inventory.GuiScreenHorseInventory; import net.minecraft.client.gui.inventory.GuiScreenHorseInventory;
import net.minecraft.client.network.NetHandlerPlayClient; 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.Entity;
import net.minecraft.entity.IMerchant; import net.minecraft.entity.IMerchant;
import net.minecraft.entity.item.EntityItem; 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.potion.Potion;
import net.minecraft.stats.StatBase; import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatFileWriter; import net.minecraft.stats.StatFileWriter;
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.tileentity.TileEntitySign; import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
@ -533,8 +535,19 @@ public class EntityPlayerSP extends AbstractClientPlayer {
this.mc.displayGuiScreen(new GuiEditSign(signTile)); this.mc.displayGuiScreen(new GuiEditSign(signTile));
} }
public void openEditCommandBlock(CommandBlockLogic cmdBlockLogic) { public void displayGuiEditCommandCart(CommandBlockBaseLogic p_184809_1_) {
this.mc.displayGuiScreen(new GuiCommandBlock(cmdBlockLogic)); 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_));
// }
} }
/** /**

View File

@ -3,6 +3,8 @@ package net.minecraft.client.gui;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Lists; 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.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger; import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.network.play.client.C14PacketTabComplete; import net.minecraft.network.play.client.C14PacketTabComplete;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent; import net.minecraft.util.IChatComponent;
import net.minecraft.util.ITabCompleter;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition; 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. * POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
public class GuiChat extends GuiScreen { public class GuiChat extends GuiScreen implements ITabCompleter {
private static final Logger logger = LogManager.getLogger(); private static final Logger logger = LogManager.getLogger();
private String historyBuffer = ""; private String historyBuffer = "";
TabCompleter tabCompleter;
/** /**
* + * +
* keeps position of which chat message you will select when you * 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.setFocused(true);
this.inputField.setText(this.defaultInputFieldText); this.inputField.setText(this.defaultInputFieldText);
this.inputField.setCanLoseFocus(false); 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 * KeyListener.keyTyped(KeyEvent e). Args : character (character
* on the key), keyCode (lwjgl Keyboard key code) * on the key), keyCode (lwjgl Keyboard key code)
*/ */
protected void keyTyped(char parChar1, int parInt1) { protected void keyTyped(char typedChar, int keyCode) {
if (parInt1 == 1 && (this.mc.gameSettings.keyBindClose.getKeyCode() == 0 || this.mc.areKeysLocked())) { this.tabCompleter.resetRequested();
this.mc.displayGuiScreen((GuiScreen) null);
if (keyCode == 15) {
this.tabCompleter.complete();
} else { } else {
this.waitingOnAutocomplete = false; this.tabCompleter.resetDidComplete();
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);
}
} }
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 * input is relative and is applied directly to the
@ -325,34 +278,6 @@ public class GuiChat extends GuiScreen {
super.drawScreen(i, j, f); 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 * Returns true if this GUI should pause the game when it is
@ -365,4 +290,47 @@ public class GuiChat extends GuiScreen {
public boolean blockPTTKey() { public boolean blockPTTKey() {
return true; 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;
}
}
} }

View File

@ -1,14 +1,23 @@
package net.minecraft.client.gui; package net.minecraft.client.gui;
import net.lax1dude.eaglercraft.v1_8.netty.Unpooled; 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.Keyboard;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger; import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.minecraft.client.resources.I18n; 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.PacketBuffer;
import net.minecraft.network.play.client.C17PacketCustomPayload; 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.IChatComponent;
import net.minecraft.util.ITabCompleter;
import net.minecraft.util.TabCompleter;
/** /**
* + * +
@ -39,22 +48,30 @@ import net.minecraft.util.IChatComponent;
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
public class GuiCommandBlock extends GuiScreen { public class GuiCommandBlock extends GuiScreen implements ITabCompleter {
private static final Logger field_146488_a = LogManager.getLogger(); /** Text field containing the command block's command. */
private GuiTextField commandTextField; private GuiTextField commandTextField;
private GuiTextField previousOutputTextField; private GuiTextField previousOutputTextField;
private final CommandBlockLogic localCommandBlock; private final TileEntityCommandBlock commandBlock;
/** "Done" button for the GUI. */
private GuiButton doneBtn; private GuiButton doneBtn;
private GuiButton cancelBtn; private GuiButton cancelBtn;
private GuiButton field_175390_s; private GuiButton outputBtn;
private boolean field_175389_t; 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) { public GuiCommandBlock(TileEntityCommandBlock commandBlockIn) {
this.localCommandBlock = parCommandBlockLogic; this.commandBlock = commandBlockIn;
} }
/** /**
* +
* Called from the main game loop to update the screen. * Called from the main game loop to update the screen.
*/ */
public void updateScreen() { 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
* Adds the buttons (and other controls) to the screen in * the GUI is displayed and when the
* question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand. * window resizes, the buttonList is cleared beforehand.
*/ */
public void initGui() { public void initGui() {
final CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic();
Keyboard.enableRepeatEvents(true); Keyboard.enableRepeatEvents(true);
this.buttonList.clear(); this.buttonList.clear();
this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 4 - 150, this.height / 4 + 120 + 12, 150, 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]))); 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, 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]))); 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 = 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.setFocused(true);
this.commandTextField.setText(this.localCommandBlock.getCommand()); this.previousOutputTextField = new GuiTextField(3, this.fontRendererObj, this.width / 2 - 150, 135, 276, 20);
this.previousOutputTextField = new GuiTextField(3, this.fontRendererObj, this.width / 2 - 150, 150, 276, 20); this.previousOutputTextField.setMaxStringLength(32500);
this.previousOutputTextField.setMaxStringLength(32767);
this.previousOutputTextField.setEnabled(false); this.previousOutputTextField.setEnabled(false);
this.previousOutputTextField.setText("-"); this.previousOutputTextField.setText("-");
this.field_175389_t = this.localCommandBlock.shouldTrackOutput(); this.doneBtn.enabled = false;
this.func_175388_a(); this.outputBtn.enabled = false;
this.doneBtn.enabled = this.commandTextField.getText().trim().length() > 0; 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() { public void onGuiClosed() {
Keyboard.enableRepeatEvents(false); Keyboard.enableRepeatEvents(false);
} }
/** /**
* + * Called by the controls from the buttonList when activated. (Mouse pressed for
* Called by the controls from the buttonList when activated. * buttons)
* (Mouse pressed for buttons)
*/ */
protected void actionPerformed(GuiButton parGuiButton) { protected void actionPerformed(GuiButton button) {
if (parGuiButton.enabled) { if (button.enabled) {
if (parGuiButton.id == 1) { CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic();
this.localCommandBlock.setTrackOutput(this.field_175389_t);
if (button.id == 1) {
commandblockbaselogic.setTrackOutput(this.trackOutput);
this.mc.displayGuiScreen((GuiScreen) null); this.mc.displayGuiScreen((GuiScreen) null);
} else if (parGuiButton.id == 0) { } else if (button.id == 0) {
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeByte(this.localCommandBlock.func_145751_f()); commandblockbaselogic.fillInInfo(packetbuffer);
this.localCommandBlock.func_145757_a(packetbuffer);
packetbuffer.writeString(this.commandTextField.getText()); packetbuffer.writeString(this.commandTextField.getText());
packetbuffer.writeBoolean(this.localCommandBlock.shouldTrackOutput()); packetbuffer.writeBoolean(commandblockbaselogic.shouldTrackOutput());
this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|AdvCdm", packetbuffer)); packetbuffer.writeString(this.commandBlockMode.name());
if (!this.localCommandBlock.shouldTrackOutput()) { packetbuffer.writeBoolean(this.conditional);
this.localCommandBlock.setLastOutput((IChatComponent) null); 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); this.mc.displayGuiScreen((GuiScreen) null);
} else if (parGuiButton.id == 4) { } else if (button.id == 4) {
this.localCommandBlock.setTrackOutput(!this.localCommandBlock.shouldTrackOutput()); commandblockbaselogic.setTrackOutput(!commandblockbaselogic.shouldTrackOutput());
this.func_175388_a(); 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
* Fired when a key is typed (except F11 which toggles full * equivalent of
* screen). This is the equivalent of * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key),
* KeyListener.keyTyped(KeyEvent e). Args : character (character * keyCode (lwjgl Keyboard key code)
* on the key), keyCode (lwjgl Keyboard key code)
*/ */
protected void keyTyped(char parChar1, int parInt1) { protected void keyTyped(char typedChar, int keyCode) {
this.commandTextField.textboxKeyTyped(parChar1, parInt1); this.tabCompleter.resetRequested();
this.previousOutputTextField.textboxKeyTyped(parChar1, parInt1);
this.doneBtn.enabled = this.commandTextField.getText().trim().length() > 0; if (keyCode == 15) {
if (parInt1 != 28 && parInt1 != 156) { this.tabCompleter.complete();
if (parInt1 == 1) { } 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); this.actionPerformed(this.cancelBtn);
} }
} else { } else {
this.actionPerformed(this.doneBtn); 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) { protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(parInt1, parInt2, parInt3); super.mouseClicked(mouseX, mouseY, mouseButton);
this.commandTextField.mouseClicked(parInt1, parInt2, parInt3); this.commandTextField.mouseClicked(mouseX, mouseY, mouseButton);
this.previousOutputTextField.mouseClicked(parInt1, parInt2, parInt3); this.previousOutputTextField.mouseClicked(mouseX, mouseY, mouseButton);
} }
/** /**
* + * Draws the screen and all the components in it.
* Draws the screen and all the components in it. Args : mouseX,
* mouseY, renderPartialTicks
*/ */
public void drawScreen(int i, int j, float f) { public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground(); this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, I18n.format("advMode.setCommand", new Object[0]), this.width / 2, this.drawCenteredString(this.fontRendererObj, I18n.format("advMode.setCommand", new Object[0]), this.width / 2,
20, 16777215); 20, 16777215);
this.drawString(this.fontRendererObj, I18n.format("advMode.command", new Object[0]), this.width / 2 - 150, 37, this.drawString(this.fontRendererObj, I18n.format("advMode.command", new Object[0]), this.width / 2 - 150, 37,
10526880); 10526880);
this.commandTextField.drawTextBox(); this.commandTextField.drawTextBox();
int k = 75; int i = 75;
int l = 0; int j = 0;
this.drawString(this.fontRendererObj, I18n.format("advMode.nearestPlayer", new Object[0]), this.width / 2 - 150, 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, 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, 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, this.drawString(this.fontRendererObj, I18n.format("advMode.allEntities", 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, "", this.width / 2 - 150, k + l++ * this.fontRendererObj.FONT_HEIGHT, this.drawString(this.fontRendererObj, "", this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT,
10526880); 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.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(); this.previousOutputTextField.drawTextBox();
} }
super.drawScreen(i, j, f); super.drawScreen(mouseX, mouseY, partialTicks);
} }
private void func_175388_a() { private void updateCmdOutput() {
if (this.localCommandBlock.shouldTrackOutput()) { CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic();
this.field_175390_s.displayString = "O";
if (this.localCommandBlock.getLastOutput() != null) { if (commandblockbaselogic.shouldTrackOutput()) {
this.previousOutputTextField.setText(this.localCommandBlock.getLastOutput().getUnformattedText()); this.outputBtn.displayString = "O";
if (commandblockbaselogic.getLastOutput() != null) {
this.previousOutputTextField.setText(commandblockbaselogic.getLastOutput().getUnformattedText());
} }
} else { } else {
this.field_175390_s.displayString = "X"; this.outputBtn.displayString = "X";
this.previousOutputTextField.setText("-"); this.previousOutputTextField.setText("-");
} }
} }
public boolean blockPTTKey() { private void updateMode() {
return commandTextField.isFocused(); 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;
} }
} }

View File

@ -265,10 +265,10 @@ public class GuiTextField extends Gui {
* looks backwards. params: N, position * looks backwards. params: N, position
*/ */
public int getNthWordFromPos(int parInt1, int parInt2) { 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; int i = parInt2;
boolean flag = parInt1 < 0; boolean flag = parInt1 < 0;
int j = Math.abs(parInt1); int j = Math.abs(parInt1);

View File

@ -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;
}
}

View File

@ -33,6 +33,7 @@ import net.minecraft.client.audio.GuardianSound;
import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.client.entity.EntityOtherPlayerMP;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiChat; import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiCommandBlock;
import net.minecraft.client.gui.GuiDisconnected; import net.minecraft.client.gui.GuiDisconnected;
import net.minecraft.client.gui.GuiDownloadTerrain; import net.minecraft.client.gui.GuiDownloadTerrain;
import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiMainMenu;
@ -209,6 +210,7 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.IChatComponent; import net.minecraft.util.IChatComponent;
import net.minecraft.util.ITabCompleter;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
import net.minecraft.village.MerchantRecipeList; import net.minecraft.village.MerchantRecipeList;
@ -1169,14 +1171,20 @@ public class NetHandlerPlayClient implements INetHandlerPlayClient {
if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) {
TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos());
int i = packetIn.getTileEntityType(); int i = packetIn.getTileEntityType();
if (i == 1 && tileentity instanceof TileEntityMobSpawner boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock;
|| i == 2 && tileentity instanceof TileEntityCommandBlock
if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag
|| i == 3 && tileentity instanceof TileEntityBeacon || i == 3 && tileentity instanceof TileEntityBeacon
|| i == 4 && tileentity instanceof TileEntitySkull || i == 4 && tileentity instanceof TileEntitySkull
|| i == 5 && tileentity instanceof TileEntityFlowerPot || i == 5 && tileentity instanceof TileEntityFlowerPot
|| i == 6 && tileentity instanceof TileEntityBanner) { || i == 6 && tileentity instanceof TileEntityBanner
|| i == 9 && tileentity instanceof TileEntitySign) {
tileentity.readFromNBT(packetIn.getNbtCompound()); 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 * knows of
*/ */
public void handleTabComplete(S3APacketTabComplete packetIn) { public void handleTabComplete(S3APacketTabComplete packetIn) {
String[] astring = packetIn.func_149630_c(); String[] astring = packetIn.getMatches();
if (this.gameController.currentScreen instanceof GuiChat) { if (this.gameController.currentScreen instanceof ITabCompleter) {
GuiChat guichat = (GuiChat) this.gameController.currentScreen; ((ITabCompleter) this.gameController.currentScreen).setCompletions(astring);
guichat.onAutocompleteResponse(astring);
} }
} }
@ -1838,12 +1845,12 @@ public class NetHandlerPlayClient implements INetHandlerPlayClient {
} }
public void handleCooldown(SPacketCooldown packetIn) { public void handleCooldown(SPacketCooldown packetIn) {
if (packetIn.getTicks() == 0) { if (packetIn.getTicks() == 0) {
this.gameController.thePlayer.getCooldownTracker().removeCooldown(packetIn.getItem()); this.gameController.thePlayer.getCooldownTracker().removeCooldown(packetIn.getItem());
} else { } else {
this.gameController.thePlayer.getCooldownTracker().setCooldown(packetIn.getItem(), packetIn.getTicks()); this.gameController.thePlayer.getCooldownTracker().setCooldown(packetIn.getItem(), packetIn.getTicks());
} }
} }
/** /**
* + * +

View File

@ -3,6 +3,7 @@ package net.minecraft.client.renderer;
import java.util.BitSet; import java.util.BitSet;
import java.util.List; import java.util.List;
import net.hoosiertransfer.Config;
import net.hoosiertransfer.Alfheim.util.ClampUtil; import net.hoosiertransfer.Alfheim.util.ClampUtil;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
@ -67,7 +68,6 @@ public class BlockModelRenderer {
boolean flag = Minecraft.isAmbientOcclusionEnabled() boolean flag = Minecraft.isAmbientOcclusionEnabled()
&& ClampUtil.clampMinFirst(blockStateIn.getLightValue(blockAccessIn, blockPosIn) - 1, 0, 15) == 0 && ClampUtil.clampMinFirst(blockStateIn.getLightValue(blockAccessIn, blockPosIn) - 1, 0, 15) == 0
&& modelIn.isAmbientOcclusion(); && modelIn.isAmbientOcclusion();
try { try {
Block block = blockStateIn.getBlock(); Block block = blockStateIn.getBlock();
return flag return flag

View File

@ -191,8 +191,6 @@ public class BlockModelShapes {
(new StateMap.Builder()).ignore(new IProperty[] { BlockReed.AGE }).build()); (new StateMap.Builder()).ignore(new IProperty[] { BlockReed.AGE }).build());
this.registerBlockWithStateMapper(Blocks.jukebox, this.registerBlockWithStateMapper(Blocks.jukebox,
(new StateMap.Builder()).ignore(new IProperty[] { BlockJukebox.HAS_RECORD }).build()); (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, this.registerBlockWithStateMapper(Blocks.cobblestone_wall,
(new StateMap.Builder()).withName(BlockWall.VARIANT).withSuffix("_wall").build()); (new StateMap.Builder()).withName(BlockWall.VARIANT).withSuffix("_wall").build());
this.registerBlockWithStateMapper(Blocks.double_plant, this.registerBlockWithStateMapper(Blocks.double_plant,

View File

@ -46,7 +46,7 @@ import net.minecraft.util.ResourceLocation;
* *
*/ */
public class RenderDragon extends RenderLiving<EntityDragon> { public class RenderDragon extends RenderLiving<EntityDragon> {
private static final ResourceLocation enderDragonCrystalBeamTextures = new ResourceLocation( public static final ResourceLocation enderDragonCrystalBeamTextures = new ResourceLocation(
"textures/entity/endercrystal/endercrystal_beam.png"); "textures/entity/endercrystal/endercrystal_beam.png");
private static final ResourceLocation enderDragonExplodingTextures = new ResourceLocation( private static final ResourceLocation enderDragonExplodingTextures = new ResourceLocation(
"textures/entity/enderdragon/dragon_exploding.png"); "textures/entity/enderdragon/dragon_exploding.png");
@ -158,7 +158,7 @@ public class RenderDragon extends RenderLiving<EntityDragon> {
* + * +
* Draws the ray from the dragon to it's crystal * 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 parFloat1) {
float f = (float) dragon.healingEnderCrystal.innerRotation + parFloat1; float f = (float) dragon.healingEnderCrystal.innerRotation + parFloat1;
float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F; float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F;
@ -206,6 +206,48 @@ public class RenderDragon extends RenderLiving<EntityDragon> {
GlStateManager.popMatrix(); 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 * Returns the location of an entity's texture. Doesn't seem to

View File

@ -4,8 +4,10 @@ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelEnderCrystal; import net.minecraft.client.model.ModelEnderCrystal;
import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderDragon;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.item.EntityEnderCrystal; import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -42,6 +44,7 @@ public class RenderEnderCrystal extends Render<EntityEnderCrystal> {
private static final ResourceLocation enderCrystalTextures = new ResourceLocation( private static final ResourceLocation enderCrystalTextures = new ResourceLocation(
"textures/entity/endercrystal/endercrystal.png"); "textures/entity/endercrystal/endercrystal.png");
private ModelBase modelEnderCrystal = new ModelEnderCrystal(0.0F, true); private ModelBase modelEnderCrystal = new ModelEnderCrystal(0.0F, true);
private ModelBase modelEnderCrystalNoBase = new ModelEnderCrystal(0.0F, false);
public RenderEnderCrystal(RenderManager renderManagerIn) { public RenderEnderCrystal(RenderManager renderManagerIn) {
super(renderManagerIn); super(renderManagerIn);
@ -58,16 +61,45 @@ public class RenderEnderCrystal extends Render<EntityEnderCrystal> {
* public void func_76986_a(T entity, double d, double d1, * 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 * 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) { public void doRender(EntityEnderCrystal entity, double x, double y, double z, float entityYaw, float partialTicks) {
float f2 = (float) entityendercrystal.innerRotation + f1; float f = (float) entity.innerRotation + partialTicks;
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate((float) d0, (float) d1, (float) d2); GlStateManager.translate((float) x, (float) y, (float) z);
this.bindTexture(enderCrystalTextures); this.bindTexture(enderCrystalTextures);
float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F; float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F;
f3 = f3 * f3 + f3; f1 = f1 * f1 + f1;
this.modelEnderCrystal.render(entityendercrystal, 0.0F, f2 * 3.0F, f3 * 0.2F, 0.0F, 0.0F, 0.0625F);
// 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(); 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);
} }
/** /**

View File

@ -1,7 +1,7 @@
package net.minecraft.command; package net.minecraft.command;
import net.minecraft.command.server.CommandAchievement; 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.CommandBroadcast;
import net.minecraft.command.server.CommandEmote; import net.minecraft.command.server.CommandEmote;
import net.minecraft.command.server.CommandListPlayers; 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"); boolean flag3 = minecraftserver.worldServers[0].getGameRules().getBoolean("sendCommandFeedback");
if (sender instanceof CommandBlockLogic) { if (sender instanceof CommandBlockBaseLogic) {
flag3 = ((CommandBlockLogic) sender).shouldTrackOutput(); flag3 = ((CommandBlockBaseLogic) sender).shouldTrackOutput();
} }
if ((flags & 1) != 1 && flag3 || sender instanceof MinecraftServer) { if ((flags & 1) != 1 && flag3 || sender instanceof MinecraftServer) {

View File

@ -47,7 +47,7 @@ import net.minecraft.world.World;
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
public abstract class CommandBlockLogic implements ICommandSender { public abstract class CommandBlockBaseLogic implements ICommandSender {
/** /**
* + * +
* The formatting for the timestamp on commands run. * The formatting for the timestamp on commands run.
@ -80,6 +80,10 @@ public abstract class CommandBlockLogic implements ICommandSender {
return this.successCount; return this.successCount;
} }
public void setSuccessCount(int successCountIn) {
this.successCount = successCountIn;
}
/** /**
* + * +
* Returns the lastOutput. * Returns the lastOutput.
@ -169,12 +173,12 @@ public abstract class CommandBlockLogic implements ICommandSender {
CrashReportCategory crashreportcategory = crashreport.makeCategory("Command to be executed"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Command to be executed");
crashreportcategory.addCrashSectionCallable("Command", new Callable<String>() { crashreportcategory.addCrashSectionCallable("Command", new Callable<String>() {
public String call() throws Exception { public String call() throws Exception {
return CommandBlockLogic.this.getCommand(); return CommandBlockBaseLogic.this.getCommand();
} }
}); });
crashreportcategory.addCrashSectionCallable("Name", new Callable<String>() { crashreportcategory.addCrashSectionCallable("Name", new Callable<String>() {
public String call() throws Exception { public String call() throws Exception {
return CommandBlockLogic.this.getName(); return CommandBlockBaseLogic.this.getName();
} }
}); });
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
@ -237,9 +241,9 @@ public abstract class CommandBlockLogic implements ICommandSender {
public abstract void updateCommand(); 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) { public void setLastOutput(IChatComponent lastOutputMessage) {
this.lastOutput = lastOutputMessage; this.lastOutput = lastOutputMessage;
@ -258,7 +262,7 @@ public abstract class CommandBlockLogic implements ICommandSender {
return false; return false;
} else { } else {
if (playerIn.getEntityWorld().isRemote) { if (playerIn.getEntityWorld().isRemote) {
playerIn.openEditCommandBlock(this); playerIn.displayGuiEditCommandCart(this);
} }
return true; return true;

View File

@ -10,6 +10,7 @@ import org.apache.commons.lang3.ObjectUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory; import net.minecraft.crash.CrashReportCategory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -148,6 +149,10 @@ public class DataWatcher {
return datawatcher$watchableobject; return datawatcher$watchableobject;
} }
public BlockPos getWatchableObjectBlockPos(int id) {
return (BlockPos) this.getWatchedObject(id).getObject();
}
public Rotations getWatchableObjectRotations(int id) { public Rotations getWatchableObjectRotations(int id) {
return (Rotations) this.getWatchedObject(id).getObject(); return (Rotations) this.getWatchedObject(id).getObject();
} }

View File

@ -2,15 +2,17 @@ package net.minecraft.entity;
import net.lax1dude.eaglercraft.v1_8.netty.ByteBuf; import net.lax1dude.eaglercraft.v1_8.netty.ByteBuf;
import net.minecraft.block.state.IBlockState; 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.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.IChatComponent; import net.minecraft.util.IChatComponent;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
/** /**
* + * +
@ -42,18 +44,18 @@ import net.minecraft.world.World;
* *
*/ */
public class EntityMinecartCommandBlock extends EntityMinecart { public class EntityMinecartCommandBlock extends EntityMinecart {
private final CommandBlockLogic commandBlockLogic = new CommandBlockLogic() { private final CommandBlockBaseLogic commandBlockLogic = new CommandBlockBaseLogic() {
public void updateCommand() { public void updateCommand() {
EntityMinecartCommandBlock.this.getDataWatcher().updateObject(23, this.getCommand()); EntityMinecartCommandBlock.this.getDataWatcher().updateObject(23, this.getCommand());
EntityMinecartCommandBlock.this.getDataWatcher().updateObject(24, EntityMinecartCommandBlock.this.getDataWatcher().updateObject(24,
IChatComponent.Serializer.componentToJson(this.getLastOutput())); IChatComponent.Serializer.componentToJson(this.getLastOutput()));
} }
public int func_145751_f() { public int getCommandBlockType() {
return 1; return 1;
} }
public void func_145757_a(ByteBuf bytebuf) { public void fillInInfo(ByteBuf bytebuf) {
bytebuf.writeInt(EntityMinecartCommandBlock.this.getEntityId()); bytebuf.writeInt(EntityMinecartCommandBlock.this.getEntityId());
} }
@ -74,6 +76,10 @@ public class EntityMinecartCommandBlock extends EntityMinecart {
public Entity getCommandSenderEntity() { public Entity getCommandSenderEntity() {
return EntityMinecartCommandBlock.this; 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(); return Blocks.command_block.getDefaultState();
} }
public CommandBlockLogic getCommandBlockLogic() { public CommandBlockBaseLogic getCommandBlockLogic() {
return this.commandBlockLogic; return this.commandBlockLogic;
} }

View File

@ -1,8 +1,15 @@
package net.minecraft.entity.item; 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.Entity;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@ -40,13 +47,11 @@ import net.minecraft.world.WorldProviderEnd;
*/ */
public class EntityEnderCrystal extends Entity { public class EntityEnderCrystal extends Entity {
public int innerRotation; public int innerRotation;
public int health;
public EntityEnderCrystal(World worldIn) { public EntityEnderCrystal(World worldIn) {
super(worldIn); super(worldIn);
this.preventEntitySpawning = true; this.preventEntitySpawning = true;
this.setSize(2.0F, 2.0F); this.setSize(2.0F, 2.0F);
this.health = 5;
this.innerRotation = this.rand.nextInt(100000); this.innerRotation = this.rand.nextInt(100000);
} }
@ -66,7 +71,9 @@ public class EntityEnderCrystal extends Entity {
} }
protected void entityInit() { 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.prevPosY = this.posY;
this.prevPosZ = this.posZ; this.prevPosZ = this.posZ;
++this.innerRotation; ++this.innerRotation;
this.dataWatcher.updateObject(8, Integer.valueOf(this.health)); if (!this.worldObj.isRemote) {
int i = MathHelper.floor_double(this.posX); BlockPos blockpos = new BlockPos(this);
int j = MathHelper.floor_double(this.posY);
int k = MathHelper.floor_double(this.posZ); if (this.worldObj.provider instanceof WorldProviderEnd
if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlockState(blockpos).getBlock() != Blocks.fire) {
&& this.worldObj.getBlockState(new BlockPos(i, j, k)).getBlock() != Blocks.fire) { this.worldObj.setBlockState(blockpos, Blocks.fire.getDefaultState());
this.worldObj.setBlockState(new BlockPos(i, j, k), Blocks.fire.getDefaultState()); }
} }
} }
@ -94,7 +101,12 @@ public class EntityEnderCrystal extends Entity {
* (abstract) Protected helper method to write subclass entity * (abstract) Protected helper method to write subclass entity
* data to NBT. * 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 * (abstract) Protected helper method to read subclass entity
* data from NBT. * 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. * Called when the entity is attacked.
*/ */
public boolean attackEntityFrom(DamageSource damagesource, float var2) { public boolean attackEntityFrom(DamageSource source, float amount) {
if (this.isEntityInvulnerable(damagesource)) { if (this.isEntityInvulnerable(source)) {
return false;
} else if (source.getEntity() instanceof EntityDragon) {
return false; return false;
} else { } else {
if (!this.isDead && !this.worldObj.isRemote) { if (!this.isDead && !this.worldObj.isRemote) {
this.health = 0; this.setDead();
if (this.health <= 0) {
this.setDead(); if (!this.worldObj.isRemote) {
if (!this.worldObj.isRemote) { this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 6.0F, true);
this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 6.0F, true); this.onCrystalDestroyed(source);
}
} }
} }
return true; return true;
} }
} }
public void onKillCommand() {
this.onCrystalDestroyed(DamageSource.generic);
super.onKillCommand();
}
private void onCrystalDestroyed(DamageSource source) {
}
public void setBeamTarget(@Nullable BlockPos beamTarget) {
Optional<BlockPos> 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;
}
} }

View File

@ -16,7 +16,7 @@ import net.minecraft.block.BlockDirectional;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.command.ICommandSender; 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.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityList;
@ -65,6 +65,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.stats.AchievementList; import net.minecraft.stats.AchievementList;
import net.minecraft.stats.StatBase; import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatList; import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.tileentity.TileEntitySign; import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
@ -1081,7 +1082,10 @@ public abstract class EntityPlayer extends EntityLivingBase implements ICommandS
public void openEditSign(TileEntitySign var1) { 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) { public void displayVillagerTradeGui(IMerchant var1) {

View File

@ -77,6 +77,7 @@ import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatList; import net.minecraft.stats.StatList;
import net.minecraft.stats.StatisticsFile; import net.minecraft.stats.StatisticsFile;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.tileentity.TileEntitySign; import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentTranslation; 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)); .sendPacket(new S42PacketCombatEvent(this.getCombatTracker(), S42PacketCombatEvent.Event.END_COMBAT));
} }
protected CooldownTracker createCooldownTracker() protected CooldownTracker createCooldownTracker() {
{ return new CooldownTrackerServer(this);
return new CooldownTrackerServer(this); }
}
/** /**
* + * +
@ -613,6 +613,7 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
private void sendTileEntityUpdate(TileEntity parTileEntity) { private void sendTileEntityUpdate(TileEntity parTileEntity) {
if (parTileEntity != null) { if (parTileEntity != null) {
Packet packet = parTileEntity.getDescriptionPacket(); Packet packet = parTileEntity.getDescriptionPacket();
if (packet != null) { if (packet != null) {
this.playerNetServerHandler.sendPacket(packet); 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 * Sends the contents of an inventory slot to the client-side
@ -1220,11 +1228,10 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
return null; return null;
} }
public void swingItem() public void swingItem() {
{ super.swingItem();
super.swingItem(); this.resetCooldown();
this.resetCooldown(); }
}
public void setElytraFlying() { public void setElytraFlying() {
this.setFlag(7, true); this.setFlag(7, true);

View File

@ -1127,6 +1127,9 @@ public class Item {
registerItem(423, (String) "mutton", (new ItemFood(2, 0.3F, true)).setUnlocalizedName("muttonRaw")); 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(424, (String) "cooked_mutton", (new ItemFood(6, 0.8F, true)).setUnlocalizedName("muttonCooked"));
registerItem(425, (String) "banner", (new ItemBanner()).setUnlocalizedName("banner")); 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(427, (String) "spruce_door", (new ItemDoor(Blocks.spruce_door)).setUnlocalizedName("doorSpruce"));
registerItem(428, (String) "birch_door", (new ItemDoor(Blocks.birch_door)).setUnlocalizedName("doorBirch")); registerItem(428, (String) "birch_door", (new ItemDoor(Blocks.birch_door)).setUnlocalizedName("doorBirch"));
registerItem(429, (String) "jungle_door", (new ItemDoor(Blocks.jungle_door)).setUnlocalizedName("doorJungle")); registerItem(429, (String) "jungle_door", (new ItemDoor(Blocks.jungle_door)).setUnlocalizedName("doorJungle"));

View File

@ -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<Entity> 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;
}
}

View File

@ -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.GameProfile;
import net.lax1dude.eaglercraft.v1_8.mojang.authlib.Property; import net.lax1dude.eaglercraft.v1_8.mojang.authlib.Property;
import net.minecraft.util.BlockPos;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
/** /**
@ -175,4 +176,22 @@ public final class NBTUtil {
return parNBTBase.equals(parNBTBase2); 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;
}
} }

View File

@ -12,8 +12,10 @@ import java.util.Set;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerMinecraftServer; import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerMinecraftServer;
import net.minecraft.block.BlockCommandBlock;
import net.minecraft.block.material.Material; 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.CrashReport;
import net.minecraft.crash.CrashReportCategory; import net.minecraft.crash.CrashReportCategory;
import net.minecraft.entity.Entity; 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.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerBeacon; import net.minecraft.inventory.ContainerBeacon;
@ -1210,7 +1213,7 @@ public class NetHandlerPlayServer implements INetHandlerPlayServer, ITickable {
} catch (Exception exception2) { } catch (Exception exception2) {
logger.error("Couldn\'t select trade", 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()) { if (!this.serverController.isCommandBlockEnabled()) {
this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notEnabled", new Object[0])); this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notEnabled", new Object[0]));
} else if (this.playerEntity.canCommandSenderUseCommand(2, "") } else if (this.playerEntity.canCommandSenderUseCommand(2, "")
@ -1219,7 +1222,7 @@ public class NetHandlerPlayServer implements INetHandlerPlayServer, ITickable {
try { try {
byte b0 = packetbuffer.readByte(); byte b0 = packetbuffer.readByte();
CommandBlockLogic commandblocklogic = null; CommandBlockBaseLogic commandblocklogic = null;
if (b0 == 0) { if (b0 == 0) {
TileEntity tileentity = this.playerEntity.worldObj.getTileEntity( TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(
new BlockPos(packetbuffer.readInt(), packetbuffer.readInt(), packetbuffer.readInt())); new BlockPos(packetbuffer.readInt(), packetbuffer.readInt(), packetbuffer.readInt()));
@ -1252,6 +1255,90 @@ public class NetHandlerPlayServer implements INetHandlerPlayServer, ITickable {
} else { } else {
this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notAllowed", new Object[0])); 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())) { } else if ("MC|Beacon".equals(c17packetcustompayload.getChannelName())) {
if (this.playerEntity.openContainer instanceof ContainerBeacon) { if (this.playerEntity.openContainer instanceof ContainerBeacon) {
try { try {

View File

@ -2,6 +2,8 @@ package net.minecraft.network.play.client;
import java.io.IOException; import java.io.IOException;
import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
@ -41,17 +43,15 @@ import net.minecraft.util.BlockPos;
public class C14PacketTabComplete implements Packet<INetHandlerPlayServer> { public class C14PacketTabComplete implements Packet<INetHandlerPlayServer> {
private String message; private String message;
private BlockPos targetBlock; private BlockPos targetBlock;
private boolean hasTargetBlock;
public C14PacketTabComplete() { public C14PacketTabComplete() {
} }
public C14PacketTabComplete(String msg) { public C14PacketTabComplete(String msg, @Nullable BlockPos target, boolean hasTargetBlock) {
this(msg, (BlockPos) null);
}
public C14PacketTabComplete(String msg, BlockPos target) {
this.message = msg; this.message = msg;
this.targetBlock = target; this.targetBlock = target;
this.hasTargetBlock = hasTargetBlock;
} }
/** /**
@ -60,6 +60,7 @@ public class C14PacketTabComplete implements Packet<INetHandlerPlayServer> {
*/ */
public void readPacketData(PacketBuffer parPacketBuffer) throws IOException { public void readPacketData(PacketBuffer parPacketBuffer) throws IOException {
this.message = parPacketBuffer.readStringFromBuffer(32767); this.message = parPacketBuffer.readStringFromBuffer(32767);
this.hasTargetBlock = parPacketBuffer.readBoolean();
boolean flag = parPacketBuffer.readBoolean(); boolean flag = parPacketBuffer.readBoolean();
if (flag) { if (flag) {
this.targetBlock = parPacketBuffer.readBlockPos(); this.targetBlock = parPacketBuffer.readBlockPos();
@ -73,6 +74,7 @@ public class C14PacketTabComplete implements Packet<INetHandlerPlayServer> {
*/ */
public void writePacketData(PacketBuffer parPacketBuffer) throws IOException { public void writePacketData(PacketBuffer parPacketBuffer) throws IOException {
parPacketBuffer.writeString(StringUtils.substring(this.message, 0, 32767)); parPacketBuffer.writeString(StringUtils.substring(this.message, 0, 32767));
parPacketBuffer.writeBoolean(this.hasTargetBlock);
boolean flag = this.targetBlock != null; boolean flag = this.targetBlock != null;
parPacketBuffer.writeBoolean(flag); parPacketBuffer.writeBoolean(flag);
if (flag) { if (flag) {

View File

@ -79,7 +79,7 @@ public class S3APacketTabComplete implements Packet<INetHandlerPlayClient> {
inethandlerplayclient.handleTabComplete(this); inethandlerplayclient.handleTabComplete(this);
} }
public String[] func_149630_c() { public String[] getMatches() {
return this.matches; return this.matches;
} }
} }

View File

@ -1,15 +1,22 @@
package net.minecraft.tileentity; package net.minecraft.tileentity;
import net.hoosiertransfer.EaglerItems;
import net.lax1dude.eaglercraft.v1_8.netty.ByteBuf; 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.CommandResultStats;
import net.minecraft.command.server.CommandBlockLogic; import net.minecraft.command.server.CommandBlockBaseLogic;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
/** /**
* + * +
@ -41,7 +48,11 @@ import net.minecraft.world.World;
* *
*/ */
public class TileEntityCommandBlock extends TileEntity { 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() { public BlockPos getPosition() {
return TileEntityCommandBlock.this.pos; return TileEntityCommandBlock.this.pos;
} }
@ -65,11 +76,11 @@ public class TileEntityCommandBlock extends TileEntity {
TileEntityCommandBlock.this.getWorld().markBlockForUpdate(TileEntityCommandBlock.this.pos); TileEntityCommandBlock.this.getWorld().markBlockForUpdate(TileEntityCommandBlock.this.pos);
} }
public int func_145751_f() { public int getCommandBlockType() {
return 0; 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.getX());
bytebuf.writeInt(TileEntityCommandBlock.this.pos.getY()); bytebuf.writeInt(TileEntityCommandBlock.this.pos.getY());
bytebuf.writeInt(TileEntityCommandBlock.this.pos.getZ()); bytebuf.writeInt(TileEntityCommandBlock.this.pos.getZ());
@ -78,16 +89,26 @@ public class TileEntityCommandBlock extends TileEntity {
public Entity getCommandSenderEntity() { public Entity getCommandSenderEntity() {
return null; return null;
} }
public MinecraftServer getServer() {
return ((WorldServer) TileEntityCommandBlock.this.getWorld()).getMinecraftServer();
}
}; };
public void writeToNBT(NBTTagCompound nbttagcompound) { public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound); super.writeToNBT(nbttagcompound);
this.commandBlockLogic.writeDataToNBT(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) { public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound); super.readFromNBT(nbttagcompound);
this.commandBlockLogic.readDataFromNBT(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. * synchronise the text to be displayed.
*/ */
public Packet getDescriptionPacket() { public Packet getDescriptionPacket() {
NBTTagCompound nbttagcompound = new NBTTagCompound(); if (this.isSendToClient()) {
this.writeToNBT(nbttagcompound); this.setSendToClient(false);
return new S35PacketUpdateTileEntity(this.pos, 2, nbttagcompound);
NBTTagCompound nbttagcompound = new NBTTagCompound();
this.writeToNBT(nbttagcompound);
return new S35PacketUpdateTileEntity(this.pos, 2, nbttagcompound);
} else {
return null;
}
} }
public boolean func_183000_F() { public boolean func_183000_F() {
return true; return true;
} }
public CommandBlockLogic getCommandBlockLogic() { public CommandBlockBaseLogic getCommandBlockLogic() {
return this.commandBlockLogic; return this.commandBlockLogic;
} }
public CommandResultStats getCommandResultStats() { public CommandResultStats getCommandResultStats() {
return this.commandBlockLogic.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;
}
} }

View File

@ -465,6 +465,10 @@ public class BlockPos extends Vec3i {
super(x_, y_, z_); super(x_, y_, z_);
} }
public MutableBlockPos(BlockPos pos) {
this(pos.getX(), pos.getY(), pos.getZ());
}
public int getX() { public int getX() {
return this.x; return this.x;
} }

View File

@ -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);
}

View File

@ -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<String> completions = Lists.<String>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;
}
}

View File

@ -1352,6 +1352,10 @@ public abstract class World implements IBlockAccess, ILightingEngineProvider, IL
return f1 * f1 * 0.5F; return f1 * f1 * 0.5F;
} }
public boolean isUpdateScheduled(BlockPos pos, Block blk) {
return true;
}
public void scheduleUpdate(BlockPos pos, Block blockIn, int delay) { 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) { public static boolean doesBlockHaveSolidTopSurface(IBlockAccess blockAccess, BlockPos pos) {
IBlockState iblockstate = blockAccess.getBlockState(pos); IBlockState iblockstate = blockAccess.getBlockState(pos);
Block block = iblockstate.getBlock(); Block block = iblockstate.getBlock();
if (block instanceof BlockPistonExtension && iblockstate.getValue(BlockPistonExtension.FACING) == EnumFacing.UP) return true; if (block instanceof BlockPistonExtension && iblockstate.getValue(BlockPistonExtension.FACING) == EnumFacing.UP)
if (block instanceof BlockPistonBase && (!((Boolean)iblockstate.getValue(BlockPistonBase.EXTENDED)).booleanValue() || iblockstate.getValue(BlockPistonBase.FACING) == EnumFacing.DOWN)) return true; 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 return block.getMaterial().isOpaque() && block.isFullCube() ? true
: (block instanceof BlockStairs ? iblockstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP : (block instanceof BlockStairs ? iblockstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP
: (block instanceof BlockSlab : (block instanceof BlockSlab

View File

@ -444,6 +444,14 @@ public class WorldServer extends World implements IThreadListener {
return this.pendingTickListEntriesThisTick.contains(nextticklistentry); 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) { public void scheduleUpdate(BlockPos blockpos, Block block, int i) {
this.updateBlockTick(blockpos, block, i, 0); this.updateBlockTick(blockpos, block, i, 0);
} }