u23
This commit is contained in:
parent
2ebb5d6da9
commit
401ebe2324
1261 changed files with 12766 additions and 138431 deletions
|
|
@ -12,6 +12,8 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
|
@ -548,7 +550,18 @@ public class Block {
|
|||
* Spawns this Block's drops into the World as EntityItems.
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState iblockstate, float f, int i) {
|
||||
if (!world.isRemote) {
|
||||
int j = this.quantityDroppedWithBonus(i, world.rand);
|
||||
|
||||
for (int k = 0; k < j; ++k) {
|
||||
if (world.rand.nextFloat() <= f) {
|
||||
Item item = this.getItemDropped(iblockstate, world.rand, i);
|
||||
if (item != null) {
|
||||
spawnAsEntity(world, blockpos, new ItemStack(item, 1, this.damageDropped(iblockstate)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
@ -556,7 +569,16 @@ public class Block {
|
|||
* the given position
|
||||
*/
|
||||
public static void spawnAsEntity(World worldIn, BlockPos pos, ItemStack stack) {
|
||||
|
||||
if (!worldIn.isRemote && worldIn.getGameRules().getBoolean("doTileDrops")) {
|
||||
float f = 0.5F;
|
||||
double d0 = (double) (worldIn.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d1 = (double) (worldIn.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d2 = (double) (worldIn.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(worldIn, (double) pos.getX() + d0, (double) pos.getY() + d1,
|
||||
(double) pos.getZ() + d2, stack);
|
||||
entityitem.setDefaultPickupDelay();
|
||||
worldIn.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
@ -564,7 +586,14 @@ public class Block {
|
|||
* orb entities
|
||||
*/
|
||||
protected void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
|
||||
|
||||
if (!worldIn.isRemote) {
|
||||
while (amount > 0) {
|
||||
int i = EntityXPOrb.getXPSplit(amount);
|
||||
amount -= i;
|
||||
worldIn.spawnEntityInWorld(new EntityXPOrb(worldIn, (double) pos.getX() + 0.5D,
|
||||
(double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
|||
|
|
@ -81,6 +81,14 @@ public class BlockAnvil extends BlockFalling {
|
|||
.withProperty(FACING, enumfacing).withProperty(DAMAGE, Integer.valueOf(meta >> 2));
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
|
||||
EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (!worldIn.isRemote) {
|
||||
playerIn.displayGui(new BlockAnvil.Anvil(worldIn, pos));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the metadata of the item this Block can drop. This
|
||||
* method is called when the block gets destroyed. It returns
|
||||
|
|
@ -139,11 +147,6 @@ public class BlockAnvil extends BlockFalling {
|
|||
Integer.valueOf((meta & 15) >> 2));
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
|
||||
EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import net.minecraft.block.material.MapColor;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
@ -117,7 +118,24 @@ public abstract class BlockBasePressurePlate extends Block {
|
|||
}
|
||||
|
||||
public void updateTick(World worldIn, BlockPos pos, IBlockState state, EaglercraftRandom rand) {
|
||||
if (!worldIn.isRemote) {
|
||||
int i = this.getRedstoneStrength(state);
|
||||
if (i > 0) {
|
||||
this.updateState(worldIn, pos, state, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called When an Entity Collided with the Block
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
||||
if (!worldIn.isRemote) {
|
||||
int i = this.getRedstoneStrength(state);
|
||||
if (i == 0) {
|
||||
this.updateState(worldIn, pos, state, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
|||
|
|
@ -6,13 +6,17 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityBeacon;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
|
|
@ -51,6 +55,13 @@ public class BlockBeacon extends BlockContainer {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
if (!world.isRemote) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityBeacon) {
|
||||
entityplayer.displayGUIChest((TileEntityBeacon) tileentity);
|
||||
entityplayer.triggerAchievement(StatList.field_181730_N);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -106,4 +117,27 @@ public class BlockBeacon extends BlockContainer {
|
|||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
public static void updateColorAsync(final World worldIn, final BlockPos glassPos) {
|
||||
Chunk chunk = worldIn.getChunkFromBlockCoords(glassPos);
|
||||
|
||||
for (int i = glassPos.getY() - 1; i >= 0; --i) {
|
||||
final BlockPos blockpos = new BlockPos(glassPos.getX(), i, glassPos.getZ());
|
||||
if (!chunk.canSeeSky(blockpos)) {
|
||||
break;
|
||||
}
|
||||
|
||||
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||
if (iblockstate.getBlock() == Blocks.beacon) {
|
||||
((WorldServer) worldIn).addScheduledTask(new Runnable() {
|
||||
public void run() {
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityBeacon) {
|
||||
((TileEntityBeacon) tileentity).updateBeacon();
|
||||
worldIn.addBlockEvent(blockpos, Blocks.beacon, 1, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,15 +8,19 @@ import net.minecraft.block.properties.PropertyBool;
|
|||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
|
|
@ -55,7 +59,83 @@ public class BlockBed extends BlockDirectional {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
if (iblockstate.getValue(PART) != BlockBed.EnumPartType.HEAD) {
|
||||
blockpos = blockpos.offset((EnumFacing) iblockstate.getValue(FACING));
|
||||
iblockstate = world.getBlockState(blockpos);
|
||||
if (iblockstate.getBlock() != this) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (world.provider.canRespawnHere() && world.getBiomeGenForCoords(blockpos) != BiomeGenBase.hell) {
|
||||
if (MinecraftServer.getServer().worldServers[0].getWorldInfo().getGameRulesInstance()
|
||||
.getBoolean("bedSpawnPoint") && Math.abs(entityplayer.posX - (double) blockpos.getX()) <= 3.0D
|
||||
&& Math.abs(entityplayer.posY - (double) blockpos.getY()) <= 2.0D
|
||||
&& Math.abs(entityplayer.posZ - (double) blockpos.getZ()) <= 3.0D) {
|
||||
BlockPos blockpos1 = BlockBed.getSafeExitLocation(world, blockpos, 0);
|
||||
if (blockpos1 == null) {
|
||||
blockpos1 = blockpos.up();
|
||||
}
|
||||
entityplayer.setSpawnPoint(blockpos1.add(0.5F, 0.1F, 0.5F), false);
|
||||
entityplayer.addChatComponentMessage(new ChatComponentTranslation("tile.bed.setspawn"));
|
||||
if (entityplayer.isSneaking()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (((Boolean) iblockstate.getValue(OCCUPIED)).booleanValue()) {
|
||||
EntityPlayer entityplayer1 = this.getPlayerInBed(world, blockpos);
|
||||
if (entityplayer1 != null) {
|
||||
entityplayer
|
||||
.addChatComponentMessage(new ChatComponentTranslation("tile.bed.occupied", new Object[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
iblockstate = iblockstate.withProperty(OCCUPIED, Boolean.valueOf(false));
|
||||
world.setBlockState(blockpos, iblockstate, 4);
|
||||
}
|
||||
|
||||
EntityPlayer.EnumStatus entityplayer$enumstatus = entityplayer.trySleep(blockpos);
|
||||
if (entityplayer$enumstatus == EntityPlayer.EnumStatus.OK) {
|
||||
iblockstate = iblockstate.withProperty(OCCUPIED, Boolean.valueOf(true));
|
||||
world.setBlockState(blockpos, iblockstate, 4);
|
||||
return true;
|
||||
} else {
|
||||
if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW) {
|
||||
entityplayer
|
||||
.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep", new Object[0]));
|
||||
} else if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_SAFE) {
|
||||
entityplayer
|
||||
.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe", new Object[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
world.setBlockToAir(blockpos);
|
||||
BlockPos blockpos1 = blockpos.offset(((EnumFacing) iblockstate.getValue(FACING)).getOpposite());
|
||||
if (world.getBlockState(blockpos1).getBlock() == this) {
|
||||
world.setBlockToAir(blockpos1);
|
||||
}
|
||||
|
||||
world.newExplosion((Entity) null, (double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 0.5D,
|
||||
(double) blockpos.getZ() + 0.5D, 5.0F, true, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private EntityPlayer getPlayerInBed(World worldIn, BlockPos pos) {
|
||||
for (EntityPlayer entityplayer : worldIn.playerEntities) {
|
||||
if (entityplayer.isPlayerSleeping() && entityplayer.playerLocation.equals(pos)) {
|
||||
return entityplayer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isFullCube() {
|
||||
|
|
@ -85,6 +165,9 @@ public class BlockBed extends BlockDirectional {
|
|||
}
|
||||
} else if (world.getBlockState(blockpos.offset(enumfacing)).getBlock() != this) {
|
||||
world.setBlockToAir(blockpos);
|
||||
if (!world.isRemote) {
|
||||
this.dropBlockAsItem(world, blockpos, iblockstate, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import net.minecraft.inventory.Container;
|
|||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityBrewingStand;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
|
@ -114,6 +115,13 @@ public class BlockBrewingStand extends BlockContainer {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
if (!world.isRemote) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityBrewingStand) {
|
||||
entityplayer.displayGUIChest((TileEntityBrewingStand) tileentity);
|
||||
entityplayer.triggerAchievement(StatList.field_181729_M);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package net.minecraft.block;
|
||||
|
||||
import java.util.List;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
|
|
@ -7,8 +9,10 @@ import net.minecraft.block.properties.PropertyDirection;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
@ -203,6 +207,29 @@ public abstract class BlockButton extends Block {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called randomly when setTickRandomly is set to true (used by
|
||||
* e.g. crops to grow, etc.)
|
||||
*/
|
||||
public void randomTick(World var1, BlockPos var2, IBlockState var3, EaglercraftRandom var4) {
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState iblockstate, EaglercraftRandom var4) {
|
||||
if (!world.isRemote) {
|
||||
if (((Boolean) iblockstate.getValue(POWERED)).booleanValue()) {
|
||||
if (this.wooden) {
|
||||
this.checkForArrows(world, blockpos, iblockstate);
|
||||
} else {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(POWERED, Boolean.valueOf(false)));
|
||||
this.notifyNeighbors(world, blockpos, (EnumFacing) iblockstate.getValue(FACING));
|
||||
world.playSoundEffect((double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 0.5D,
|
||||
(double) blockpos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
|
||||
world.markBlockRangeForRenderUpdate(blockpos, blockpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
|
|
@ -213,6 +240,49 @@ public abstract class BlockButton extends Block {
|
|||
this.setBlockBounds(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called When an Entity Collided with the Block
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World world, BlockPos blockpos, IBlockState iblockstate, Entity var4) {
|
||||
if (!world.isRemote) {
|
||||
if (this.wooden) {
|
||||
if (!((Boolean) iblockstate.getValue(POWERED)).booleanValue()) {
|
||||
this.checkForArrows(world, blockpos, iblockstate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state) {
|
||||
this.updateBlockBounds(state);
|
||||
List list = worldIn.getEntitiesWithinAABB(EntityArrow.class,
|
||||
new AxisAlignedBB((double) pos.getX() + this.minX, (double) pos.getY() + this.minY,
|
||||
(double) pos.getZ() + this.minZ, (double) pos.getX() + this.maxX,
|
||||
(double) pos.getY() + this.maxY, (double) pos.getZ() + this.maxZ));
|
||||
boolean flag = !list.isEmpty();
|
||||
boolean flag1 = ((Boolean) state.getValue(POWERED)).booleanValue();
|
||||
if (flag && !flag1) {
|
||||
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
|
||||
this.notifyNeighbors(worldIn, pos, (EnumFacing) state.getValue(FACING));
|
||||
worldIn.markBlockRangeForRenderUpdate(pos, pos);
|
||||
worldIn.playSoundEffect((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D,
|
||||
"random.click", 0.3F, 0.6F);
|
||||
}
|
||||
|
||||
if (!flag && flag1) {
|
||||
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
|
||||
this.notifyNeighbors(worldIn, pos, (EnumFacing) state.getValue(FACING));
|
||||
worldIn.markBlockRangeForRenderUpdate(pos, pos);
|
||||
worldIn.playSoundEffect((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D,
|
||||
"random.click", 0.3F, 0.5F);
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void notifyNeighbors(World worldIn, BlockPos pos, EnumFacing facing) {
|
||||
worldIn.notifyNeighborsOfStateChange(pos, this);
|
||||
worldIn.notifyNeighborsOfStateChange(pos.offset(facing.getOpposite()), this);
|
||||
|
|
|
|||
|
|
@ -9,9 +9,12 @@ import net.minecraft.block.properties.PropertyEnum;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
|
@ -153,4 +156,18 @@ public class BlockCarpet extends Block {
|
|||
protected BlockState createBlockState() {
|
||||
return new BlockState(this, new IProperty[] { COLOR });
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
if (!world.isRemote && MinecraftServer.getServer().worldServers[0].getWorldInfo().getGameRulesInstance()
|
||||
.getBoolean("clickToSit") && entityplayer.getHeldItem() == null) {
|
||||
EntityArrow arrow = new EntityArrow(world, blockpos.getX() + 0.5D, blockpos.getY() - 0.4375D,
|
||||
blockpos.getZ() + 0.5D);
|
||||
arrow.isChair = true;
|
||||
world.spawnEntityInWorld(arrow);
|
||||
entityplayer.mountEntity(arrow);
|
||||
return true;
|
||||
}
|
||||
return super.onBlockActivated(world, blockpos, var3, entityplayer, var5, var6, var7, var8);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,9 +10,16 @@ import net.minecraft.block.properties.PropertyInteger;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemBanner;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntityBanner;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
@ -86,9 +93,109 @@ public class BlockCauldron extends Block {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called When an Entity Collided with the Block
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World world, BlockPos blockpos, IBlockState iblockstate, Entity entity) {
|
||||
int i = ((Integer) iblockstate.getValue(LEVEL)).intValue();
|
||||
float f = (float) blockpos.getY() + (6.0F + (float) (3 * i)) / 16.0F;
|
||||
if (!world.isRemote && entity.isBurning() && i > 0 && entity.getEntityBoundingBox().minY <= (double) f) {
|
||||
entity.extinguish();
|
||||
this.setWaterLevel(world, blockpos, iblockstate, i - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
if (!world.isRemote) {
|
||||
ItemStack itemstack = entityplayer.inventory.getCurrentItem();
|
||||
if (itemstack == null) {
|
||||
return true;
|
||||
} else {
|
||||
int i = ((Integer) iblockstate.getValue(LEVEL)).intValue();
|
||||
Item item = itemstack.getItem();
|
||||
if (item == Items.water_bucket) {
|
||||
if (i < 3) {
|
||||
if (!entityplayer.capabilities.isCreativeMode) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem,
|
||||
new ItemStack(Items.bucket));
|
||||
}
|
||||
|
||||
entityplayer.triggerAchievement(StatList.field_181725_I);
|
||||
this.setWaterLevel(world, blockpos, iblockstate, 3);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (item == Items.glass_bottle) {
|
||||
if (i > 0) {
|
||||
if (!entityplayer.capabilities.isCreativeMode) {
|
||||
ItemStack itemstack2 = new ItemStack(Items.potionitem, 1, 0);
|
||||
if (!entityplayer.inventory.addItemStackToInventory(itemstack2)) {
|
||||
world.spawnEntityInWorld(new EntityItem(world, (double) blockpos.getX() + 0.5D,
|
||||
(double) blockpos.getY() + 1.5D, (double) blockpos.getZ() + 0.5D, itemstack2));
|
||||
} else if (entityplayer instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) entityplayer).sendContainerToPlayer(entityplayer.inventoryContainer);
|
||||
}
|
||||
|
||||
entityplayer.triggerAchievement(StatList.field_181726_J);
|
||||
--itemstack.stackSize;
|
||||
if (itemstack.stackSize <= 0) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem,
|
||||
(ItemStack) null);
|
||||
}
|
||||
}
|
||||
|
||||
this.setWaterLevel(world, blockpos, iblockstate, i - 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if (i > 0 && item instanceof ItemArmor) {
|
||||
ItemArmor itemarmor = (ItemArmor) item;
|
||||
if (itemarmor.getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER
|
||||
&& itemarmor.hasColor(itemstack)) {
|
||||
itemarmor.removeColor(itemstack);
|
||||
this.setWaterLevel(world, blockpos, iblockstate, i - 1);
|
||||
entityplayer.triggerAchievement(StatList.field_181727_K);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 0 && item instanceof ItemBanner && TileEntityBanner.getPatterns(itemstack) > 0) {
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
itemstack1.stackSize = 1;
|
||||
TileEntityBanner.removeBannerData(itemstack1);
|
||||
if (itemstack.stackSize <= 1 && !entityplayer.capabilities.isCreativeMode) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem,
|
||||
itemstack1);
|
||||
} else {
|
||||
if (!entityplayer.inventory.addItemStackToInventory(itemstack1)) {
|
||||
world.spawnEntityInWorld(new EntityItem(world, (double) blockpos.getX() + 0.5D,
|
||||
(double) blockpos.getY() + 1.5D, (double) blockpos.getZ() + 0.5D, itemstack1));
|
||||
} else if (entityplayer instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) entityplayer).sendContainerToPlayer(entityplayer.inventoryContainer);
|
||||
}
|
||||
|
||||
entityplayer.triggerAchievement(StatList.field_181728_L);
|
||||
if (!entityplayer.capabilities.isCreativeMode) {
|
||||
--itemstack.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (!entityplayer.capabilities.isCreativeMode) {
|
||||
this.setWaterLevel(world, blockpos, iblockstate, i - 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setWaterLevel(World worldIn, BlockPos pos, IBlockState state, int level) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.inventory.InventoryLargeChest;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
|
@ -165,6 +166,75 @@ public class BlockChest extends BlockContainer {
|
|||
}
|
||||
|
||||
public IBlockState checkForSurroundingChests(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if (!worldIn.isRemote) {
|
||||
IBlockState iblockstate = worldIn.getBlockState(pos.north());
|
||||
IBlockState iblockstate1 = worldIn.getBlockState(pos.south());
|
||||
IBlockState iblockstate2 = worldIn.getBlockState(pos.west());
|
||||
IBlockState iblockstate3 = worldIn.getBlockState(pos.east());
|
||||
EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
|
||||
Block block = iblockstate.getBlock();
|
||||
Block block1 = iblockstate1.getBlock();
|
||||
Block block2 = iblockstate2.getBlock();
|
||||
Block block3 = iblockstate3.getBlock();
|
||||
if (block != this && block1 != this) {
|
||||
boolean flag = block.isFullBlock();
|
||||
boolean flag1 = block1.isFullBlock();
|
||||
if (block2 == this || block3 == this) {
|
||||
BlockPos blockpos1 = block2 == this ? pos.west() : pos.east();
|
||||
IBlockState iblockstate6 = worldIn.getBlockState(blockpos1.north());
|
||||
IBlockState iblockstate7 = worldIn.getBlockState(blockpos1.south());
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
EnumFacing enumfacing2;
|
||||
if (block2 == this) {
|
||||
enumfacing2 = (EnumFacing) iblockstate2.getValue(FACING);
|
||||
} else {
|
||||
enumfacing2 = (EnumFacing) iblockstate3.getValue(FACING);
|
||||
}
|
||||
|
||||
if (enumfacing2 == EnumFacing.NORTH) {
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
}
|
||||
|
||||
Block block6 = iblockstate6.getBlock();
|
||||
Block block7 = iblockstate7.getBlock();
|
||||
if ((flag || block6.isFullBlock()) && !flag1 && !block7.isFullBlock()) {
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
}
|
||||
|
||||
if ((flag1 || block7.isFullBlock()) && !flag && !block6.isFullBlock()) {
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BlockPos blockpos = block == this ? pos.north() : pos.south();
|
||||
IBlockState iblockstate4 = worldIn.getBlockState(blockpos.west());
|
||||
IBlockState iblockstate5 = worldIn.getBlockState(blockpos.east());
|
||||
enumfacing = EnumFacing.EAST;
|
||||
EnumFacing enumfacing1;
|
||||
if (block == this) {
|
||||
enumfacing1 = (EnumFacing) iblockstate.getValue(FACING);
|
||||
} else {
|
||||
enumfacing1 = (EnumFacing) iblockstate1.getValue(FACING);
|
||||
}
|
||||
|
||||
if (enumfacing1 == EnumFacing.WEST) {
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
Block block4 = iblockstate4.getBlock();
|
||||
Block block5 = iblockstate5.getBlock();
|
||||
if ((block2.isFullBlock() || block4.isFullBlock()) && !block3.isFullBlock() && !block5.isFullBlock()) {
|
||||
enumfacing = EnumFacing.EAST;
|
||||
}
|
||||
|
||||
if ((block3.isFullBlock() || block5.isFullBlock()) && !block2.isFullBlock() && !block4.isFullBlock()) {
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
}
|
||||
|
||||
state = state.withProperty(FACING, enumfacing);
|
||||
worldIn.setBlockState(pos, state, 3);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
@ -286,7 +356,19 @@ public class BlockChest extends BlockContainer {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
{
|
||||
ILockableContainer ilockablecontainer = this.getLockableContainer(world, blockpos);
|
||||
if (ilockablecontainer != null) {
|
||||
entityplayer.displayGUIChest(ilockablecontainer);
|
||||
if (this.chestType == 0) {
|
||||
entityplayer.triggerAchievement(StatList.field_181723_aa);
|
||||
} else if (this.chestType == 1) {
|
||||
entityplayer.triggerAchievement(StatList.field_181737_U);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public ILockableContainer getLockableContainer(World worldIn, BlockPos pos) {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,22 @@ public class BlockCommandBlock extends BlockContainer {
|
|||
return new TileEntityCommandBlock();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a neighboring block changes.
|
||||
*/
|
||||
public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState iblockstate, Block var4) {
|
||||
if (!world.isRemote) {
|
||||
boolean flag = world.isBlockPowered(blockpos);
|
||||
boolean flag1 = ((Boolean) iblockstate.getValue(TRIGGERED)).booleanValue();
|
||||
if (flag && !flag1) {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
|
||||
world.scheduleUpdate(blockpos, this, this.tickRate(world));
|
||||
} else if (!flag && flag1) {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom var4) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityCommandBlock) {
|
||||
|
|
@ -102,6 +118,9 @@ public class BlockCommandBlock extends BlockContainer {
|
|||
commandblocklogic.setName(itemstack.getDisplayName());
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
commandblocklogic.setTrackOutput(world.getGameRules().getBoolean("sendCommandFeedback"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
|
@ -137,6 +138,25 @@ public class BlockCrops extends BlockBush implements IGrowable {
|
|||
return Items.wheat;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Spawns this Block's drops into the World as EntityItems.
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState iblockstate, float f, int i) {
|
||||
super.dropBlockAsItemWithChance(world, blockpos, iblockstate, f, 0);
|
||||
if (!world.isRemote) {
|
||||
int j = ((Integer) iblockstate.getValue(AGE)).intValue();
|
||||
if (j >= 7) {
|
||||
int k = 3 + i;
|
||||
|
||||
for (int l = 0; l < k; ++l) {
|
||||
if (world.rand.nextInt(15) <= j) {
|
||||
spawnAsEntity(world, blockpos, new ItemStack(this.getSeed(), 1, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -88,6 +88,18 @@ public class BlockDaylightDetector extends BlockContainer {
|
|||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer entityplayer,
|
||||
EnumFacing enumfacing, float f, float f1, float f2) {
|
||||
if (entityplayer.isAllowEdit()) {
|
||||
if (!world.isRemote) {
|
||||
if (this.inverted) {
|
||||
world.setBlockState(blockpos,
|
||||
Blocks.daylight_detector.getDefaultState().withProperty(POWER, iblockstate.getValue(POWER)),
|
||||
4);
|
||||
Blocks.daylight_detector.updatePower(world, blockpos);
|
||||
} else {
|
||||
world.setBlockState(blockpos, Blocks.daylight_detector_inverted.getDefaultState()
|
||||
.withProperty(POWER, iblockstate.getValue(POWER)), 4);
|
||||
Blocks.daylight_detector_inverted.updatePower(world, blockpos);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return super.onBlockActivated(world, blockpos, iblockstate, entityplayer, enumfacing, f, f1, f2);
|
||||
|
|
|
|||
|
|
@ -5,8 +5,13 @@ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
|||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
|
@ -67,4 +72,15 @@ public class BlockDeadBush extends BlockBush {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void harvestBlock(World world, EntityPlayer entityplayer, BlockPos blockpos, IBlockState iblockstate,
|
||||
TileEntity tileentity) {
|
||||
if (!world.isRemote && entityplayer.getCurrentEquippedItem() != null
|
||||
&& entityplayer.getCurrentEquippedItem().getItem() == Items.shears) {
|
||||
entityplayer.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||
spawnAsEntity(world, blockpos, new ItemStack(Blocks.deadbush, 1, 0));
|
||||
} else {
|
||||
super.harvestBlock(world, entityplayer, blockpos, iblockstate, tileentity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -20,8 +20,10 @@ import net.minecraft.inventory.Container;
|
|||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityDispenser;
|
||||
import net.minecraft.tileentity.TileEntityDropper;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.RegistryDefaulted;
|
||||
|
|
@ -68,8 +70,48 @@ public class BlockDispenser extends BlockContainer {
|
|||
return 4;
|
||||
}
|
||||
|
||||
public void onBlockAdded(World world, BlockPos blockpos, IBlockState iblockstate) {
|
||||
super.onBlockAdded(world, blockpos, iblockstate);
|
||||
this.setDefaultDirection(world, blockpos, iblockstate);
|
||||
}
|
||||
|
||||
private void setDefaultDirection(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if (!worldIn.isRemote) {
|
||||
EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
|
||||
boolean flag = worldIn.getBlockState(pos.north()).getBlock().isFullBlock();
|
||||
boolean flag1 = worldIn.getBlockState(pos.south()).getBlock().isFullBlock();
|
||||
if (enumfacing == EnumFacing.NORTH && flag && !flag1) {
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
} else if (enumfacing == EnumFacing.SOUTH && flag1 && !flag) {
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
} else {
|
||||
boolean flag2 = worldIn.getBlockState(pos.west()).getBlock().isFullBlock();
|
||||
boolean flag3 = worldIn.getBlockState(pos.east()).getBlock().isFullBlock();
|
||||
if (enumfacing == EnumFacing.WEST && flag2 && !flag3) {
|
||||
enumfacing = EnumFacing.EAST;
|
||||
} else if (enumfacing == EnumFacing.EAST && flag3 && !flag2) {
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
}
|
||||
|
||||
worldIn.setBlockState(pos,
|
||||
state.withProperty(FACING, enumfacing).withProperty(TRIGGERED, Boolean.valueOf(false)), 2);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
if (!world.isRemote) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityDispenser) {
|
||||
entityplayer.displayGUIChest((TileEntityDispenser) tileentity);
|
||||
if (tileentity instanceof TileEntityDropper) {
|
||||
entityplayer.triggerAchievement(StatList.field_181731_O);
|
||||
} else {
|
||||
entityplayer.triggerAchievement(StatList.field_181733_Q);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +153,12 @@ public class BlockDispenser extends BlockContainer {
|
|||
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom var4) {
|
||||
if (!world.isRemote) {
|
||||
this.dispense(world, blockpos);
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Returns a new instance of a block's tile entity class. Called
|
||||
* on placing the block.
|
||||
|
|
|
|||
|
|
@ -209,7 +209,11 @@ public class BlockDoor extends Block {
|
|||
}
|
||||
}
|
||||
|
||||
if (!flag1) {
|
||||
if (flag1) {
|
||||
if (!world.isRemote) {
|
||||
this.dropBlockAsItem(world, blockpos, iblockstate, 0);
|
||||
}
|
||||
} else {
|
||||
boolean flag = world.isBlockPowered(blockpos) || world.isBlockPowered(blockpos2);
|
||||
if ((flag || block.canProvidePower()) && block != this
|
||||
&& flag != ((Boolean) iblockstate2.getValue(POWERED)).booleanValue()) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
|
@ -180,6 +182,16 @@ public class BlockDoublePlant extends BlockBush implements IGrowable {
|
|||
this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER), 2);
|
||||
}
|
||||
|
||||
public void harvestBlock(World world, EntityPlayer entityplayer, BlockPos blockpos, IBlockState iblockstate,
|
||||
TileEntity tileentity) {
|
||||
if (world.isRemote || entityplayer.getCurrentEquippedItem() == null
|
||||
|| entityplayer.getCurrentEquippedItem().getItem() != Items.shears
|
||||
|| iblockstate.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.LOWER
|
||||
|| !this.onHarvest(world, blockpos, iblockstate, entityplayer)) {
|
||||
super.harvestBlock(world, entityplayer, blockpos, iblockstate, tileentity);
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockHarvested(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer entityplayer) {
|
||||
if (iblockstate.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER) {
|
||||
if (world.getBlockState(blockpos.down()).getBlock() == this) {
|
||||
|
|
@ -190,6 +202,14 @@ public class BlockDoublePlant extends BlockBush implements IGrowable {
|
|||
if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN
|
||||
&& blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS) {
|
||||
world.destroyBlock(blockpos.down(), true);
|
||||
} else if (!world.isRemote) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null
|
||||
&& entityplayer.getCurrentEquippedItem().getItem() == Items.shears) {
|
||||
this.onHarvest(world, blockpos, iblockstate1, entityplayer);
|
||||
world.setBlockToAir(blockpos.down());
|
||||
} else {
|
||||
world.destroyBlock(blockpos.down(), true);
|
||||
}
|
||||
} else {
|
||||
world.setBlockToAir(blockpos.down());
|
||||
}
|
||||
|
|
@ -204,6 +224,22 @@ public class BlockDoublePlant extends BlockBush implements IGrowable {
|
|||
super.onBlockHarvested(world, blockpos, iblockstate, entityplayer);
|
||||
}
|
||||
|
||||
private boolean onHarvest(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) {
|
||||
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType) state
|
||||
.getValue(VARIANT);
|
||||
if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN
|
||||
&& blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS) {
|
||||
return false;
|
||||
} else {
|
||||
player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||
int i = (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS
|
||||
? BlockTallGrass.EnumType.GRASS
|
||||
: BlockTallGrass.EnumType.FERN).getMeta();
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(Blocks.tallgrass, 2, i));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* returns a list of blocks with the same ID, but different meta
|
||||
* (eg: wood returns 4 blocks)
|
||||
|
|
|
|||
|
|
@ -96,20 +96,26 @@ public class BlockDragonEgg extends Block {
|
|||
worldIn.rand.nextInt(8) - worldIn.rand.nextInt(8),
|
||||
worldIn.rand.nextInt(16) - worldIn.rand.nextInt(16));
|
||||
if (worldIn.getBlockState(blockpos).getBlock().blockMaterial == Material.air) {
|
||||
for (int j = 0; j < 128; ++j) {
|
||||
double d0 = worldIn.rand.nextDouble();
|
||||
float f = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
|
||||
float f1 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
|
||||
float f2 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
|
||||
double d1 = (double) blockpos.getX() + (double) (pos.getX() - blockpos.getX()) * d0
|
||||
+ (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
|
||||
double d2 = (double) blockpos.getY() + (double) (pos.getY() - blockpos.getY()) * d0
|
||||
+ worldIn.rand.nextDouble() * 1.0D - 0.5D;
|
||||
double d3 = (double) blockpos.getZ() + (double) (pos.getZ() - blockpos.getZ()) * d0
|
||||
+ (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
|
||||
worldIn.spawnParticle(EnumParticleTypes.PORTAL, d1, d2, d3, (double) f, (double) f1,
|
||||
(double) f2, new int[0]);
|
||||
if (worldIn.isRemote) {
|
||||
for (int j = 0; j < 128; ++j) {
|
||||
double d0 = worldIn.rand.nextDouble();
|
||||
float f = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
|
||||
float f1 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
|
||||
float f2 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
|
||||
double d1 = (double) blockpos.getX() + (double) (pos.getX() - blockpos.getX()) * d0
|
||||
+ (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
|
||||
double d2 = (double) blockpos.getY() + (double) (pos.getY() - blockpos.getY()) * d0
|
||||
+ worldIn.rand.nextDouble() * 1.0D - 0.5D;
|
||||
double d3 = (double) blockpos.getZ() + (double) (pos.getZ() - blockpos.getZ()) * d0
|
||||
+ (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
|
||||
worldIn.spawnParticle(EnumParticleTypes.PORTAL, d1, d2, d3, (double) f, (double) f1,
|
||||
(double) f2, new int[0]);
|
||||
}
|
||||
} else {
|
||||
worldIn.setBlockState(blockpos, iblockstate, 2);
|
||||
worldIn.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,12 @@ public class BlockEnchantmentTable extends BlockContainer {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
if (!world.isRemote) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityEnchantmentTable) {
|
||||
entityplayer.displayGui((TileEntityEnchantmentTable) tileentity);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,16 @@ public class BlockEndPortal extends BlockContainer {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called When an Entity Collided with the Block
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World world, BlockPos var2, IBlockState var3, Entity entity) {
|
||||
if (entity.ridingEntity == null && entity.riddenByEntity == null && !world.isRemote) {
|
||||
entity.travelToDimension(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom random) {
|
||||
double d0 = (double) ((float) blockpos.getX() + random.nextFloat());
|
||||
double d1 = (double) ((float) blockpos.getY() + 0.8F);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.InventoryEnderChest;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityEnderChest;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
|
@ -109,7 +111,22 @@ public class BlockEnderChest extends BlockContainer {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
InventoryEnderChest inventoryenderchest = entityplayer.getInventoryEnderChest();
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (inventoryenderchest != null && tileentity instanceof TileEntityEnderChest) {
|
||||
if (world.getBlockState(blockpos.up()).getBlock().isNormalCube()) {
|
||||
return true;
|
||||
} else if (world.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
inventoryenderchest.setChestTileEntity((TileEntityEnderChest) tileentity);
|
||||
entityplayer.displayGUIChest(inventoryenderchest);
|
||||
entityplayer.triggerAchievement(StatList.field_181738_V);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package net.minecraft.block;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
|
@ -51,6 +52,37 @@ public class BlockFalling extends Block {
|
|||
world.scheduleUpdate(blockpos, this, this.tickRate(world));
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom var4) {
|
||||
if (!world.isRemote) {
|
||||
this.checkFallable(world, blockpos);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkFallable(World worldIn, BlockPos pos) {
|
||||
if (canFallInto(worldIn, pos.down()) && pos.getY() >= 0) {
|
||||
byte b0 = 32;
|
||||
if (!fallInstantly && worldIn.isAreaLoaded(pos.add(-b0, -b0, -b0), pos.add(b0, b0, b0))) {
|
||||
EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldIn, (double) pos.getX() + 0.5D,
|
||||
(double) pos.getY(), (double) pos.getZ() + 0.5D, worldIn.getBlockState(pos));
|
||||
this.onStartFalling(entityfallingblock);
|
||||
worldIn.spawnEntityInWorld(entityfallingblock);
|
||||
} else {
|
||||
worldIn.setBlockToAir(pos);
|
||||
|
||||
BlockPos blockpos;
|
||||
for (blockpos = pos.down(); canFallInto(worldIn, blockpos)
|
||||
&& blockpos.getY() > 0; blockpos = blockpos.down()) {
|
||||
;
|
||||
}
|
||||
|
||||
if (blockpos.getY() > 0) {
|
||||
worldIn.setBlockState(blockpos.up(), this.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void onStartFalling(EntityFallingBlock var1) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import net.minecraft.block.state.BlockState;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
|
@ -84,6 +85,14 @@ public class BlockFarmland extends Block {
|
|||
*/
|
||||
public void onFallenUpon(World world, BlockPos blockpos, Entity entity, float f) {
|
||||
if (entity instanceof EntityLivingBase) {
|
||||
if (!world.isRemote && world.rand.nextFloat() < f - 0.5F) {
|
||||
if (!(entity instanceof EntityPlayer) && !world.getGameRules().getBoolean("mobGriefing")) {
|
||||
return;
|
||||
}
|
||||
|
||||
world.setBlockState(blockpos, Blocks.dirt.getDefaultState());
|
||||
}
|
||||
|
||||
super.onFallenUpon(world, blockpos, entity, f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemLead;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
@ -182,7 +183,7 @@ public class BlockFence extends Block {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
return world.isRemote ? true : ItemLead.attachToFence(entityplayer, world, blockpos);
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
|||
|
|
@ -145,6 +145,30 @@ public class BlockFenceGate extends BlockDirectional {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a neighboring block changes.
|
||||
*/
|
||||
public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState iblockstate, Block block) {
|
||||
if (!world.isRemote) {
|
||||
boolean flag = world.isBlockPowered(blockpos);
|
||||
if (flag || block.canProvidePower()) {
|
||||
if (flag && !((Boolean) iblockstate.getValue(OPEN)).booleanValue()
|
||||
&& !((Boolean) iblockstate.getValue(POWERED)).booleanValue()) {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(OPEN, Boolean.valueOf(true))
|
||||
.withProperty(POWERED, Boolean.valueOf(true)), 2);
|
||||
world.playAuxSFXAtEntity((EntityPlayer) null, 1003, blockpos, 0);
|
||||
} else if (!flag && ((Boolean) iblockstate.getValue(OPEN)).booleanValue()
|
||||
&& ((Boolean) iblockstate.getValue(POWERED)).booleanValue()) {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(OPEN, Boolean.valueOf(false))
|
||||
.withProperty(POWERED, Boolean.valueOf(false)), 2);
|
||||
world.playAuxSFXAtEntity((EntityPlayer) null, 1006, blockpos, 0);
|
||||
} else if (flag != ((Boolean) iblockstate.getValue(POWERED)).booleanValue()) {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(POWERED, Boolean.valueOf(flag)), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldSideBeRendered(IBlockAccess var1, BlockPos var2, EnumFacing var3) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import net.minecraft.inventory.Container;
|
|||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
|
@ -59,6 +60,31 @@ public class BlockFurnace extends BlockContainer {
|
|||
return Item.getItemFromBlock(Blocks.furnace);
|
||||
}
|
||||
|
||||
public void onBlockAdded(World world, BlockPos blockpos, IBlockState iblockstate) {
|
||||
this.setDefaultFacing(world, blockpos, iblockstate);
|
||||
}
|
||||
|
||||
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if (!worldIn.isRemote) {
|
||||
Block block = worldIn.getBlockState(pos.north()).getBlock();
|
||||
Block block1 = worldIn.getBlockState(pos.south()).getBlock();
|
||||
Block block2 = worldIn.getBlockState(pos.west()).getBlock();
|
||||
Block block3 = worldIn.getBlockState(pos.east()).getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock()) {
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
} else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock()) {
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
} else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock()) {
|
||||
enumfacing = EnumFacing.EAST;
|
||||
} else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock()) {
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World world, BlockPos blockpos, IBlockState iblockstate, EaglercraftRandom random) {
|
||||
if (this.isBurning) {
|
||||
EnumFacing enumfacing = (EnumFacing) iblockstate.getValue(FACING);
|
||||
|
|
@ -90,7 +116,17 @@ public class BlockFurnace extends BlockContainer {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityFurnace) {
|
||||
entityplayer.displayGUIChest((TileEntityFurnace) tileentity);
|
||||
entityplayer.triggerAchievement(StatList.field_181741_Y);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setState(boolean active, World worldIn, BlockPos pos) {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,29 @@ public class BlockGrass extends Block implements IGrowable {
|
|||
return BiomeColorHelper.getGrassColorAtPos(iblockaccess, blockpos);
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom random) {
|
||||
if (!world.isRemote) {
|
||||
if (world.getLightFromNeighbors(blockpos.up()) < 4
|
||||
&& world.getBlockState(blockpos.up()).getBlock().getLightOpacity() > 2) {
|
||||
world.setBlockState(blockpos, Blocks.dirt.getDefaultState());
|
||||
} else {
|
||||
if (world.getLightFromNeighbors(blockpos.up()) >= 9) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
BlockPos blockpos1 = blockpos.add(random.nextInt(3) - 1, random.nextInt(5) - 3,
|
||||
random.nextInt(3) - 1);
|
||||
Block block = world.getBlockState(blockpos1.up()).getBlock();
|
||||
IBlockState iblockstate = world.getBlockState(blockpos1);
|
||||
if (iblockstate.getBlock() == Blocks.dirt
|
||||
&& iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT
|
||||
&& world.getLightFromNeighbors(blockpos1.up()) >= 4 && block.getLightOpacity() <= 2) {
|
||||
world.setBlockState(blockpos1, Blocks.grass.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityHopper;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
|
@ -131,7 +132,17 @@ public class BlockHopper extends BlockContainer {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityHopper) {
|
||||
entityplayer.displayGUIChest((TileEntityHopper) tileentity);
|
||||
entityplayer.triggerAchievement(StatList.field_181732_P);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import net.minecraft.block.properties.PropertyBool;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
|
|
@ -49,6 +50,7 @@ public class BlockJukebox extends BlockContainer {
|
|||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer var4,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
if (((Boolean) iblockstate.getValue(HAS_RECORD)).booleanValue()) {
|
||||
this.dropRecord(world, blockpos, iblockstate);
|
||||
iblockstate = iblockstate.withProperty(HAS_RECORD, Boolean.valueOf(false));
|
||||
world.setBlockState(blockpos, iblockstate, 2);
|
||||
return true;
|
||||
|
|
@ -58,7 +60,52 @@ public class BlockJukebox extends BlockContainer {
|
|||
}
|
||||
|
||||
public void insertRecord(World worldIn, BlockPos pos, IBlockState state, ItemStack recordStack) {
|
||||
if (!worldIn.isRemote) {
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
if (tileentity instanceof BlockJukebox.TileEntityJukebox) {
|
||||
((BlockJukebox.TileEntityJukebox) tileentity)
|
||||
.setRecord(new ItemStack(recordStack.getItem(), 1, recordStack.getMetadata()));
|
||||
worldIn.setBlockState(pos, state.withProperty(HAS_RECORD, Boolean.valueOf(true)), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dropRecord(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if (!worldIn.isRemote) {
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
if (tileentity instanceof BlockJukebox.TileEntityJukebox) {
|
||||
BlockJukebox.TileEntityJukebox blockjukebox$tileentityjukebox = (BlockJukebox.TileEntityJukebox) tileentity;
|
||||
ItemStack itemstack = blockjukebox$tileentityjukebox.getRecord();
|
||||
if (itemstack != null) {
|
||||
worldIn.playAuxSFX(1005, pos, 0);
|
||||
worldIn.playRecord(pos, (String) null);
|
||||
blockjukebox$tileentityjukebox.setRecord((ItemStack) null);
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (worldIn.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d1 = (double) (worldIn.rand.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D;
|
||||
double d2 = (double) (worldIn.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
EntityItem entityitem = new EntityItem(worldIn, (double) pos.getX() + d0, (double) pos.getY() + d1,
|
||||
(double) pos.getZ() + d2, itemstack1);
|
||||
entityitem.setDefaultPickupDelay();
|
||||
worldIn.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void breakBlock(World world, BlockPos blockpos, IBlockState iblockstate) {
|
||||
this.dropRecord(world, blockpos, iblockstate);
|
||||
super.breakBlock(world, blockpos, iblockstate);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Spawns this Block's drops into the World as EntityItems.
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState iblockstate, float f, int var5) {
|
||||
if (!world.isRemote) {
|
||||
super.dropBlockAsItemWithChance(world, blockpos, iblockstate, f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
|
|
@ -88,6 +89,89 @@ public abstract class BlockLeaves extends BlockLeavesBase {
|
|||
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState iblockstate, EaglercraftRandom var4) {
|
||||
if (!world.isRemote) {
|
||||
if (((Boolean) iblockstate.getValue(CHECK_DECAY)).booleanValue()
|
||||
&& ((Boolean) iblockstate.getValue(DECAYABLE)).booleanValue()) {
|
||||
byte b0 = 4;
|
||||
int i = b0 + 1;
|
||||
int j = blockpos.getX();
|
||||
int k = blockpos.getY();
|
||||
int l = blockpos.getZ();
|
||||
byte b1 = 32;
|
||||
int i1 = b1 * b1;
|
||||
int j1 = b1 / 2;
|
||||
if (this.surroundings == null) {
|
||||
this.surroundings = new int[b1 * b1 * b1];
|
||||
}
|
||||
|
||||
if (world.isAreaLoaded(new BlockPos(j - i, k - i, l - i), new BlockPos(j + i, k + i, l + i))) {
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int k1 = -b0; k1 <= b0; ++k1) {
|
||||
for (int l1 = -b0; l1 <= b0; ++l1) {
|
||||
for (int i2 = -b0; i2 <= b0; ++i2) {
|
||||
Block block = world
|
||||
.getBlockState(blockpos$mutableblockpos.func_181079_c(j + k1, k + l1, l + i2))
|
||||
.getBlock();
|
||||
if (block != Blocks.log && block != Blocks.log2) {
|
||||
if (block.getMaterial() == Material.leaves) {
|
||||
this.surroundings[(k1 + j1) * i1 + (l1 + j1) * b1 + i2 + j1] = -2;
|
||||
} else {
|
||||
this.surroundings[(k1 + j1) * i1 + (l1 + j1) * b1 + i2 + j1] = -1;
|
||||
}
|
||||
} else {
|
||||
this.surroundings[(k1 + j1) * i1 + (l1 + j1) * b1 + i2 + j1] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int k2 = 1; k2 <= 4; ++k2) {
|
||||
for (int l2 = -b0; l2 <= b0; ++l2) {
|
||||
for (int i3 = -b0; i3 <= b0; ++i3) {
|
||||
for (int j3 = -b0; j3 <= b0; ++j3) {
|
||||
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + j3 + j1] == k2 - 1) {
|
||||
if (this.surroundings[(l2 + j1 - 1) * i1 + (i3 + j1) * b1 + j3 + j1] == -2) {
|
||||
this.surroundings[(l2 + j1 - 1) * i1 + (i3 + j1) * b1 + j3 + j1] = k2;
|
||||
}
|
||||
|
||||
if (this.surroundings[(l2 + j1 + 1) * i1 + (i3 + j1) * b1 + j3 + j1] == -2) {
|
||||
this.surroundings[(l2 + j1 + 1) * i1 + (i3 + j1) * b1 + j3 + j1] = k2;
|
||||
}
|
||||
|
||||
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1 - 1) * b1 + j3 + j1] == -2) {
|
||||
this.surroundings[(l2 + j1) * i1 + (i3 + j1 - 1) * b1 + j3 + j1] = k2;
|
||||
}
|
||||
|
||||
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1 + 1) * b1 + j3 + j1] == -2) {
|
||||
this.surroundings[(l2 + j1) * i1 + (i3 + j1 + 1) * b1 + j3 + j1] = k2;
|
||||
}
|
||||
|
||||
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + (j3 + j1 - 1)] == -2) {
|
||||
this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + (j3 + j1 - 1)] = k2;
|
||||
}
|
||||
|
||||
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + j3 + j1 + 1] == -2) {
|
||||
this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + j3 + j1 + 1] = k2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int j2 = this.surroundings[j1 * i1 + j1 * b1 + j1];
|
||||
if (j2 >= 0) {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(CHECK_DECAY, Boolean.valueOf(false)), 4);
|
||||
} else {
|
||||
this.destroy(world, blockpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom random) {
|
||||
if (world.canLightningStrike(blockpos.up()) && !World.doesBlockHaveSolidTopSurface(world, blockpos.down())
|
||||
&& random.nextInt(15) == 1) {
|
||||
|
|
@ -118,6 +202,36 @@ public abstract class BlockLeaves extends BlockLeavesBase {
|
|||
return Item.getItemFromBlock(Blocks.sapling);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Spawns this Block's drops into the World as EntityItems.
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState iblockstate, float var4, int i) {
|
||||
if (!world.isRemote) {
|
||||
int j = this.getSaplingDropChance(iblockstate);
|
||||
if (i > 0) {
|
||||
j -= 2 << i;
|
||||
if (j < 10) {
|
||||
j = 10;
|
||||
}
|
||||
}
|
||||
|
||||
if (world.rand.nextInt(j) == 0) {
|
||||
Item item = this.getItemDropped(iblockstate, world.rand, i);
|
||||
spawnAsEntity(world, blockpos, new ItemStack(item, 1, this.damageDropped(iblockstate)));
|
||||
}
|
||||
|
||||
j = 200;
|
||||
if (i > 0) {
|
||||
j -= 10 << i;
|
||||
if (j < 40) {
|
||||
j = 40;
|
||||
}
|
||||
}
|
||||
|
||||
this.dropApple(world, blockpos, iblockstate, j);
|
||||
}
|
||||
}
|
||||
|
||||
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,19 @@ public class BlockLever extends Block {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer var4,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
iblockstate = iblockstate.cycleProperty(POWERED);
|
||||
world.setBlockState(blockpos, iblockstate, 3);
|
||||
world.playSoundEffect((double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 0.5D,
|
||||
(double) blockpos.getZ() + 0.5D, "random.click", 0.3F,
|
||||
((Boolean) iblockstate.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F);
|
||||
world.notifyNeighborsOfStateChange(blockpos, this);
|
||||
EnumFacing enumfacing = ((BlockLever.EnumOrientation) iblockstate.getValue(FACING)).getFacing();
|
||||
world.notifyNeighborsOfStateChange(blockpos.offset(enumfacing.getOpposite()), this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void breakBlock(World world, BlockPos blockpos, IBlockState iblockstate) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
|
|
@ -90,6 +91,23 @@ public class BlockMushroom extends BlockBush implements IGrowable {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean generateBigMushroom(World worldIn, BlockPos pos, IBlockState state, EaglercraftRandom rand) {
|
||||
worldIn.setBlockToAir(pos);
|
||||
WorldGenBigMushroom worldgenbigmushroom = null;
|
||||
if (this == Blocks.brown_mushroom) {
|
||||
worldgenbigmushroom = new WorldGenBigMushroom(Blocks.brown_mushroom_block);
|
||||
} else if (this == Blocks.red_mushroom) {
|
||||
worldgenbigmushroom = new WorldGenBigMushroom(Blocks.red_mushroom_block);
|
||||
}
|
||||
|
||||
if (worldgenbigmushroom != null && worldgenbigmushroom.generate(worldIn, rand, pos)) {
|
||||
return true;
|
||||
} else {
|
||||
worldIn.setBlockState(pos, state, 3);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Whether this IGrowable can grow
|
||||
*/
|
||||
|
|
@ -100,4 +118,8 @@ public class BlockMushroom extends BlockBush implements IGrowable {
|
|||
public boolean canUseBonemeal(World var1, EaglercraftRandom random, BlockPos var3, IBlockState var4) {
|
||||
return (double) random.nextFloat() < 0.4D;
|
||||
}
|
||||
|
||||
public void grow(World world, EaglercraftRandom random, BlockPos blockpos, IBlockState iblockstate) {
|
||||
this.generateBigMushroom(world, blockpos, iblockstate, random);
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +56,30 @@ public class BlockMycelium extends Block {
|
|||
return iblockstate.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer));
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom random) {
|
||||
if (!world.isRemote) {
|
||||
if (world.getLightFromNeighbors(blockpos.up()) < 4
|
||||
&& world.getBlockState(blockpos.up()).getBlock().getLightOpacity() > 2) {
|
||||
world.setBlockState(blockpos,
|
||||
Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
|
||||
} else {
|
||||
if (world.getLightFromNeighbors(blockpos.up()) >= 9) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
BlockPos blockpos1 = blockpos.add(random.nextInt(3) - 1, random.nextInt(5) - 3,
|
||||
random.nextInt(3) - 1);
|
||||
IBlockState iblockstate = world.getBlockState(blockpos1);
|
||||
Block block = world.getBlockState(blockpos1.up()).getBlock();
|
||||
if (iblockstate.getBlock() == Blocks.dirt
|
||||
&& iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT
|
||||
&& world.getLightFromNeighbors(blockpos1.up()) >= 4 && block.getLightOpacity() <= 2) {
|
||||
world.setBlockState(blockpos1, this.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World world, BlockPos blockpos, IBlockState iblockstate, EaglercraftRandom random) {
|
||||
super.randomDisplayTick(world, blockpos, iblockstate, random);
|
||||
if (random.nextInt(10) == 0) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
|
@ -68,6 +69,25 @@ public class BlockNetherWart extends BlockBush {
|
|||
super.updateTick(world, blockpos, iblockstate, random);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Spawns this Block's drops into the World as EntityItems.
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState iblockstate, float var4, int i) {
|
||||
if (!world.isRemote) {
|
||||
int j = 1;
|
||||
if (((Integer) iblockstate.getValue(AGE)).intValue() >= 3) {
|
||||
j = 2 + world.rand.nextInt(3);
|
||||
if (i > 0) {
|
||||
j += world.rand.nextInt(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < j; ++k) {
|
||||
spawnAsEntity(world, blockpos, new ItemStack(Items.nether_wart));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,9 +9,12 @@ import net.minecraft.block.properties.PropertyEnum;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
|
@ -55,7 +58,6 @@ public class BlockNewLeaf extends BlockLeaves {
|
|||
if (iblockstate.getValue(VARIANT) == BlockPlanks.EnumType.DARK_OAK && world.rand.nextInt(i) == 0) {
|
||||
spawnAsEntity(world, blockpos, new ItemStack(Items.apple, 1, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
@ -121,4 +123,15 @@ public class BlockNewLeaf extends BlockLeaves {
|
|||
return new BlockState(this, new IProperty[] { VARIANT, CHECK_DECAY, DECAYABLE });
|
||||
}
|
||||
|
||||
public void harvestBlock(World world, EntityPlayer entityplayer, BlockPos blockpos, IBlockState iblockstate,
|
||||
TileEntity tileentity) {
|
||||
if (!world.isRemote && entityplayer.getCurrentEquippedItem() != null
|
||||
&& entityplayer.getCurrentEquippedItem().getItem() == Items.shears) {
|
||||
entityplayer.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||
spawnAsEntity(world, blockpos, new ItemStack(Item.getItemFromBlock(this), 1,
|
||||
((BlockPlanks.EnumType) iblockstate.getValue(VARIANT)).getMetadata() - 4));
|
||||
} else {
|
||||
super.harvestBlock(world, entityplayer, blockpos, iblockstate, tileentity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityNote;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
|
@ -65,7 +66,29 @@ public class BlockNote extends BlockContainer {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityNote) {
|
||||
TileEntityNote tileentitynote = (TileEntityNote) tileentity;
|
||||
tileentitynote.changePitch();
|
||||
tileentitynote.triggerNote(world, blockpos);
|
||||
entityplayer.triggerAchievement(StatList.field_181735_S);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockClicked(World world, BlockPos blockpos, EntityPlayer entityplayer) {
|
||||
if (!world.isRemote) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntityNote) {
|
||||
((TileEntityNote) tileentity).triggerNote(world, blockpos);
|
||||
entityplayer.triggerAchievement(StatList.field_181734_R);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
|||
|
|
@ -9,9 +9,12 @@ import net.minecraft.block.properties.PropertyEnum;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.ColorizerFoliage;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
|
@ -152,4 +155,15 @@ public class BlockOldLeaf extends BlockLeaves {
|
|||
return ((BlockPlanks.EnumType) iblockstate.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
public void harvestBlock(World world, EntityPlayer entityplayer, BlockPos blockpos, IBlockState iblockstate,
|
||||
TileEntity tileentity) {
|
||||
if (!world.isRemote && entityplayer.getCurrentEquippedItem() != null
|
||||
&& entityplayer.getCurrentEquippedItem().getItem() == Items.shears) {
|
||||
entityplayer.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||
spawnAsEntity(world, blockpos, new ItemStack(Item.getItemFromBlock(this), 1,
|
||||
((BlockPlanks.EnumType) iblockstate.getValue(VARIANT)).getMetadata()));
|
||||
} else {
|
||||
super.harvestBlock(world, entityplayer, blockpos, iblockstate, tileentity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +74,27 @@ public class BlockPistonBase extends Block {
|
|||
EntityLivingBase entitylivingbase, ItemStack var5) {
|
||||
world.setBlockState(blockpos,
|
||||
iblockstate.withProperty(FACING, getFacingFromEntity(world, blockpos, entitylivingbase)), 2);
|
||||
if (!world.isRemote) {
|
||||
this.checkForMove(world, blockpos, iblockstate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a neighboring block changes.
|
||||
*/
|
||||
public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState iblockstate, Block var4) {
|
||||
if (!world.isRemote) {
|
||||
this.checkForMove(world, blockpos, iblockstate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onBlockAdded(World world, BlockPos blockpos, IBlockState iblockstate) {
|
||||
if (!world.isRemote && world.getTileEntity(blockpos) == null) {
|
||||
this.checkForMove(world, blockpos, iblockstate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
@ -129,6 +150,18 @@ public class BlockPistonBase extends Block {
|
|||
*/
|
||||
public boolean onBlockEventReceived(World world, BlockPos blockpos, IBlockState iblockstate, int i, int j) {
|
||||
EnumFacing enumfacing = (EnumFacing) iblockstate.getValue(FACING);
|
||||
if (!world.isRemote) {
|
||||
boolean flag = this.shouldBeExtended(world, blockpos, enumfacing);
|
||||
if (flag && i == 1) {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(EXTENDED, Boolean.valueOf(true)), 2);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!flag && i == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
if (!this.doMove(world, blockpos, enumfacing, true)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import net.minecraft.block.properties.PropertyDirection;
|
|||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
|
@ -114,6 +115,16 @@ public class BlockPistonMoving extends BlockContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer var4,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
if (!world.isRemote && world.getTileEntity(blockpos) == null) {
|
||||
world.setBlockToAir(blockpos);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
|
|
@ -121,6 +132,19 @@ public class BlockPistonMoving extends BlockContainer {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Spawns this Block's drops into the World as EntityItems.
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState var3, float var4, int var5) {
|
||||
if (!world.isRemote) {
|
||||
TileEntityPiston tileentitypiston = this.getTileEntity(world, blockpos);
|
||||
if (tileentitypiston != null) {
|
||||
IBlockState iblockstate = tileentitypiston.getPistonState();
|
||||
iblockstate.getBlock().dropBlockAsItem(world, blockpos, iblockstate, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Ray traces through the blocks collision from start vector to
|
||||
* end vector returning a ray trace hit.
|
||||
|
|
@ -129,6 +153,15 @@ public class BlockPistonMoving extends BlockContainer {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a neighboring block changes.
|
||||
*/
|
||||
public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState var3, Block var4) {
|
||||
if (!world.isRemote) {
|
||||
world.getTileEntity(blockpos);
|
||||
}
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos blockpos, IBlockState var3) {
|
||||
TileEntityPiston tileentitypiston = this.getTileEntity(world, blockpos);
|
||||
if (tileentitypiston == null) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
package net.minecraft.block;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
|
|
@ -32,4 +36,15 @@ public class BlockPotato extends BlockCrops {
|
|||
return Items.potato;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Spawns this Block's drops into the World as EntityItems.
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState iblockstate, float f, int i) {
|
||||
super.dropBlockAsItemWithChance(world, blockpos, iblockstate, f, i);
|
||||
if (!world.isRemote) {
|
||||
if (((Integer) iblockstate.getValue(AGE)).intValue() >= 7 && world.rand.nextInt(50) == 0) {
|
||||
spawnAsEntity(world, blockpos, new ItemStack(Items.poisonous_potato));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -101,12 +101,58 @@ public abstract class BlockRailBase extends Block {
|
|||
return World.doesBlockHaveSolidTopSurface(world, blockpos.down());
|
||||
}
|
||||
|
||||
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if (!worldIn.isRemote) {
|
||||
state = this.func_176564_a(worldIn, pos, state, true);
|
||||
if (this.isPowered) {
|
||||
this.onNeighborBlockChange(worldIn, pos, state, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a neighboring block changes.
|
||||
*/
|
||||
public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState iblockstate, Block block) {
|
||||
if (!world.isRemote) {
|
||||
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection) iblockstate
|
||||
.getValue(this.getShapeProperty());
|
||||
boolean flag = false;
|
||||
if (!World.doesBlockHaveSolidTopSurface(world, blockpos.down())) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_EAST
|
||||
&& !World.doesBlockHaveSolidTopSurface(world, blockpos.east())) {
|
||||
flag = true;
|
||||
} else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_WEST
|
||||
&& !World.doesBlockHaveSolidTopSurface(world, blockpos.west())) {
|
||||
flag = true;
|
||||
} else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_NORTH
|
||||
&& !World.doesBlockHaveSolidTopSurface(world, blockpos.north())) {
|
||||
flag = true;
|
||||
} else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_SOUTH
|
||||
&& !World.doesBlockHaveSolidTopSurface(world, blockpos.south())) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
this.dropBlockAsItem(world, blockpos, iblockstate, 0);
|
||||
world.setBlockToAir(blockpos);
|
||||
} else {
|
||||
this.onNeighborChangedInternal(world, blockpos, iblockstate, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void onNeighborChangedInternal(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
|
||||
}
|
||||
|
||||
protected IBlockState func_176564_a(World worldIn, BlockPos parBlockPos, IBlockState parIBlockState,
|
||||
boolean parFlag) {
|
||||
return parIBlockState;
|
||||
return worldIn.isRemote ? parIBlockState
|
||||
: (new BlockRailBase.Rail(worldIn, parBlockPos, parIBlockState))
|
||||
.func_180364_a(worldIn.isBlockPowered(parBlockPos), parFlag).getBlockState();
|
||||
}
|
||||
|
||||
public int getMobilityFlag() {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
|
@ -42,6 +43,7 @@ import net.minecraft.world.World;
|
|||
*
|
||||
*/
|
||||
public class BlockRailDetector extends BlockRailBase {
|
||||
|
||||
public static PropertyEnum<BlockRailBase.EnumRailDirection> SHAPE;
|
||||
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||
|
||||
|
|
@ -79,6 +81,30 @@ public class BlockRailDetector extends BlockRailBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called When an Entity Collided with the Block
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World world, BlockPos blockpos, IBlockState iblockstate, Entity var4) {
|
||||
if (!world.isRemote) {
|
||||
if (!((Boolean) iblockstate.getValue(POWERED)).booleanValue()) {
|
||||
this.updatePoweredState(world, blockpos, iblockstate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called randomly when setTickRandomly is set to true (used by
|
||||
* e.g. crops to grow, etc.)
|
||||
*/
|
||||
public void randomTick(World var1, BlockPos var2, IBlockState var3, EaglercraftRandom var4) {
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState iblockstate, EaglercraftRandom var4) {
|
||||
if (!world.isRemote && ((Boolean) iblockstate.getValue(POWERED)).booleanValue()) {
|
||||
this.updatePoweredState(world, blockpos, iblockstate);
|
||||
}
|
||||
}
|
||||
|
||||
public int getWeakPower(IBlockAccess var1, BlockPos var2, IBlockState iblockstate, EnumFacing var4) {
|
||||
return ((Boolean) iblockstate.getValue(POWERED)).booleanValue() ? 15 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,37 @@ public class BlockRedstoneLight extends Block {
|
|||
|
||||
}
|
||||
|
||||
public void onBlockAdded(World world, BlockPos blockpos, IBlockState var3) {
|
||||
if (!world.isRemote) {
|
||||
if (this.isOn && !world.isBlockPowered(blockpos)) {
|
||||
world.setBlockState(blockpos, Blocks.redstone_lamp.getDefaultState(), 2);
|
||||
} else if (!this.isOn && world.isBlockPowered(blockpos)) {
|
||||
world.setBlockState(blockpos, Blocks.lit_redstone_lamp.getDefaultState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a neighboring block changes.
|
||||
*/
|
||||
public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState var3, Block var4) {
|
||||
if (!world.isRemote) {
|
||||
if (this.isOn && !world.isBlockPowered(blockpos)) {
|
||||
world.scheduleUpdate(blockpos, this, 4);
|
||||
} else if (!this.isOn && world.isBlockPowered(blockpos)) {
|
||||
world.setBlockState(blockpos, Blocks.lit_redstone_lamp.getDefaultState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom var4) {
|
||||
if (!world.isRemote) {
|
||||
if (this.isOn && !world.isBlockPowered(blockpos)) {
|
||||
world.setBlockState(blockpos, Blocks.redstone_lamp.getDefaultState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -224,6 +224,53 @@ public class BlockRedstoneWire extends Block {
|
|||
}
|
||||
}
|
||||
|
||||
public void onBlockAdded(World world, BlockPos blockpos, IBlockState iblockstate) {
|
||||
if (!world.isRemote) {
|
||||
this.updateSurroundingRedstone(world, blockpos, iblockstate);
|
||||
|
||||
for (EnumFacing enumfacing : EnumFacing.Plane.VERTICAL) {
|
||||
world.notifyNeighborsOfStateChange(blockpos.offset(enumfacing), this);
|
||||
}
|
||||
|
||||
for (EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL) {
|
||||
this.notifyWireNeighborsOfStateChange(world, blockpos.offset(enumfacing1));
|
||||
}
|
||||
|
||||
for (EnumFacing enumfacing2 : EnumFacing.Plane.HORIZONTAL) {
|
||||
BlockPos blockpos1 = blockpos.offset(enumfacing2);
|
||||
if (world.getBlockState(blockpos1).getBlock().isNormalCube()) {
|
||||
this.notifyWireNeighborsOfStateChange(world, blockpos1.up());
|
||||
} else {
|
||||
this.notifyWireNeighborsOfStateChange(world, blockpos1.down());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void breakBlock(World world, BlockPos blockpos, IBlockState iblockstate) {
|
||||
super.breakBlock(world, blockpos, iblockstate);
|
||||
if (!world.isRemote) {
|
||||
for (EnumFacing enumfacing : EnumFacing.values()) {
|
||||
world.notifyNeighborsOfStateChange(blockpos.offset(enumfacing), this);
|
||||
}
|
||||
|
||||
this.updateSurroundingRedstone(world, blockpos, iblockstate);
|
||||
|
||||
for (EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL) {
|
||||
this.notifyWireNeighborsOfStateChange(world, blockpos.offset(enumfacing1));
|
||||
}
|
||||
|
||||
for (EnumFacing enumfacing2 : EnumFacing.Plane.HORIZONTAL) {
|
||||
BlockPos blockpos1 = blockpos.offset(enumfacing2);
|
||||
if (world.getBlockState(blockpos1).getBlock().isNormalCube()) {
|
||||
this.notifyWireNeighborsOfStateChange(world, blockpos1.up());
|
||||
} else {
|
||||
this.notifyWireNeighborsOfStateChange(world, blockpos1.down());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getMaxCurrentStrength(World worldIn, BlockPos pos, int strength) {
|
||||
if (worldIn.getBlockState(pos).getBlock() != this) {
|
||||
return strength;
|
||||
|
|
@ -233,6 +280,20 @@ public class BlockRedstoneWire extends Block {
|
|||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a neighboring block changes.
|
||||
*/
|
||||
public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState iblockstate, Block var4) {
|
||||
if (!world.isRemote) {
|
||||
if (this.canPlaceBlockAt(world, blockpos)) {
|
||||
this.updateSurroundingRedstone(world, blockpos, iblockstate);
|
||||
} else {
|
||||
this.dropBlockAsItem(world, blockpos, iblockstate, 0);
|
||||
world.setBlockToAir(blockpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,11 +9,21 @@ import net.minecraft.block.properties.PropertyInteger;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenBigTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenCanopyTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenForest;
|
||||
import net.minecraft.world.gen.feature.WorldGenMegaJungle;
|
||||
import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenSavannaTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenTaiga2;
|
||||
import net.minecraft.world.gen.feature.WorldGenTrees;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
|
|
@ -61,6 +71,113 @@ public class BlockSapling extends BlockBush implements IGrowable {
|
|||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState iblockstate, EaglercraftRandom random) {
|
||||
if (!world.isRemote) {
|
||||
super.updateTick(world, blockpos, iblockstate, random);
|
||||
if (world.getLightFromNeighbors(blockpos.up()) >= 9 && random.nextInt(7) == 0) {
|
||||
this.grow(world, blockpos, iblockstate, random);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void grow(World worldIn, BlockPos pos, IBlockState state, EaglercraftRandom rand) {
|
||||
if (((Integer) state.getValue(STAGE)).intValue() == 0) {
|
||||
worldIn.setBlockState(pos, state.cycleProperty(STAGE), 4);
|
||||
} else {
|
||||
this.generateTree(worldIn, pos, state, rand);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void generateTree(World worldIn, BlockPos pos, IBlockState state, EaglercraftRandom rand) {
|
||||
Object object = rand.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
boolean flag = false;
|
||||
switch ((BlockPlanks.EnumType) state.getValue(TYPE)) {
|
||||
case SPRUCE:
|
||||
label114: for (i = 0; i >= -1; --i) {
|
||||
for (j = 0; j >= -1; --j) {
|
||||
if (this.func_181624_a(worldIn, pos, i, j, BlockPlanks.EnumType.SPRUCE)) {
|
||||
object = new WorldGenMegaPineTree(false, rand.nextBoolean());
|
||||
flag = true;
|
||||
break label114;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
j = 0;
|
||||
i = 0;
|
||||
object = new WorldGenTaiga2(true);
|
||||
}
|
||||
break;
|
||||
case BIRCH:
|
||||
object = new WorldGenForest(true, false);
|
||||
break;
|
||||
case JUNGLE:
|
||||
IBlockState iblockstate = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT,
|
||||
BlockPlanks.EnumType.JUNGLE);
|
||||
IBlockState iblockstate1 = Blocks.leaves.getDefaultState()
|
||||
.withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE)
|
||||
.withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
|
||||
|
||||
label269: for (i = 0; i >= -1; --i) {
|
||||
for (j = 0; j >= -1; --j) {
|
||||
if (this.func_181624_a(worldIn, pos, i, j, BlockPlanks.EnumType.JUNGLE)) {
|
||||
object = new WorldGenMegaJungle(true, 10, 20, iblockstate, iblockstate1);
|
||||
flag = true;
|
||||
break label269;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
j = 0;
|
||||
i = 0;
|
||||
object = new WorldGenTrees(true, 4 + rand.nextInt(7), iblockstate, iblockstate1, false);
|
||||
}
|
||||
break;
|
||||
case ACACIA:
|
||||
object = new WorldGenSavannaTree(true);
|
||||
break;
|
||||
case DARK_OAK:
|
||||
label390: for (i = 0; i >= -1; --i) {
|
||||
for (j = 0; j >= -1; --j) {
|
||||
if (this.func_181624_a(worldIn, pos, i, j, BlockPlanks.EnumType.DARK_OAK)) {
|
||||
object = new WorldGenCanopyTree(true);
|
||||
flag = true;
|
||||
break label390;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
return;
|
||||
}
|
||||
case OAK:
|
||||
}
|
||||
|
||||
IBlockState iblockstate2 = Blocks.air.getDefaultState();
|
||||
if (flag) {
|
||||
worldIn.setBlockState(pos.add(i, 0, j), iblockstate2, 4);
|
||||
worldIn.setBlockState(pos.add(i + 1, 0, j), iblockstate2, 4);
|
||||
worldIn.setBlockState(pos.add(i, 0, j + 1), iblockstate2, 4);
|
||||
worldIn.setBlockState(pos.add(i + 1, 0, j + 1), iblockstate2, 4);
|
||||
} else {
|
||||
worldIn.setBlockState(pos, iblockstate2, 4);
|
||||
}
|
||||
|
||||
if (!((WorldGenerator) object).generate(worldIn, rand, pos.add(i, 0, j))) {
|
||||
if (flag) {
|
||||
worldIn.setBlockState(pos.add(i, 0, j), state, 4);
|
||||
worldIn.setBlockState(pos.add(i + 1, 0, j), state, 4);
|
||||
worldIn.setBlockState(pos.add(i, 0, j + 1), state, 4);
|
||||
worldIn.setBlockState(pos.add(i + 1, 0, j + 1), state, 4);
|
||||
} else {
|
||||
worldIn.setBlockState(pos, state, 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean func_181624_a(World parWorld, BlockPos parBlockPos, int parInt1, int parInt2,
|
||||
|
|
@ -112,6 +229,10 @@ public class BlockSapling extends BlockBush implements IGrowable {
|
|||
return (double) world.rand.nextFloat() < 0.45D;
|
||||
}
|
||||
|
||||
public void grow(World world, EaglercraftRandom random, BlockPos blockpos, IBlockState iblockstate) {
|
||||
this.grow(world, blockpos, iblockstate, random);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -93,7 +93,13 @@ public class BlockSign extends BlockContainer {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
return tileentity instanceof TileEntitySign ? ((TileEntitySign) tileentity).executeCommand(entityplayer)
|
||||
: false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPlaceBlockAt(World world, BlockPos blockpos) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import net.minecraft.block.properties.PropertyEnum;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.monster.EntitySilverfish;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
|
@ -80,6 +81,20 @@ public class BlockSilverfish extends Block {
|
|||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Spawns this Block's drops into the World as EntityItems.
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState var3, float var4, int var5) {
|
||||
if (!world.isRemote && world.getGameRules().getBoolean("doTileDrops")) {
|
||||
EntitySilverfish entitysilverfish = new EntitySilverfish(world);
|
||||
entitysilverfish.setLocationAndAngles((double) blockpos.getX() + 0.5D, (double) blockpos.getY(),
|
||||
(double) blockpos.getZ() + 0.5D, 0.0F, 0.0F);
|
||||
world.spawnEntityInWorld(entitysilverfish);
|
||||
entitysilverfish.spawnExplosionParticle();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getDamageValue(World world, BlockPos blockpos) {
|
||||
IBlockState iblockstate = world.getBlockState(blockpos);
|
||||
return iblockstate.getBlock().getMetaFromState(iblockstate);
|
||||
|
|
|
|||
|
|
@ -15,17 +15,23 @@ import net.minecraft.block.state.pattern.BlockPattern;
|
|||
import net.minecraft.block.state.pattern.BlockStateHelper;
|
||||
import net.minecraft.block.state.pattern.FactoryBlockPattern;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.stats.AchievementList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
|
@ -159,7 +165,25 @@ public class BlockSkull extends BlockContainer {
|
|||
}
|
||||
|
||||
public void breakBlock(World world, BlockPos blockpos, IBlockState iblockstate) {
|
||||
if (!world.isRemote) {
|
||||
if (!((Boolean) iblockstate.getValue(NODROP)).booleanValue()) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity instanceof TileEntitySkull) {
|
||||
TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
|
||||
ItemStack itemstack = new ItemStack(Items.skull, 1, this.getDamageValue(world, blockpos));
|
||||
if (tileentityskull.getSkullType() == 3 && tileentityskull.getPlayerProfile() != null) {
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(nbttagcompound, tileentityskull.getPlayerProfile());
|
||||
itemstack.getTagCompound().setTag("SkullOwner", nbttagcompound);
|
||||
}
|
||||
|
||||
spawnAsEntity(world, blockpos, itemstack);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, blockpos, iblockstate);
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
@ -170,11 +194,63 @@ public class BlockSkull extends BlockContainer {
|
|||
}
|
||||
|
||||
public boolean canDispenserPlace(World worldIn, BlockPos pos, ItemStack stack) {
|
||||
return false;
|
||||
return stack.getMetadata() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL
|
||||
&& !worldIn.isRemote ? this.getWitherBasePattern().match(worldIn, pos) != null : false;
|
||||
}
|
||||
|
||||
public void checkWitherSpawn(World worldIn, BlockPos pos, TileEntitySkull te) {
|
||||
if (te.getSkullType() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL
|
||||
&& !worldIn.isRemote) {
|
||||
BlockPattern blockpattern = this.getWitherPattern();
|
||||
BlockPattern.PatternHelper blockpattern$patternhelper = blockpattern.match(worldIn, pos);
|
||||
if (blockpattern$patternhelper != null) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, 0, 0);
|
||||
worldIn.setBlockState(blockworldstate.getPos(),
|
||||
blockworldstate.getBlockState().withProperty(NODROP, Boolean.valueOf(true)), 2);
|
||||
}
|
||||
|
||||
for (int j = 0; j < blockpattern.getPalmLength(); ++j) {
|
||||
for (int k = 0; k < blockpattern.getThumbLength(); ++k) {
|
||||
BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(j, k, 0);
|
||||
worldIn.setBlockState(blockworldstate1.getPos(), Blocks.air.getDefaultState(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos blockpos = blockpattern$patternhelper.translateOffset(1, 0, 0).getPos();
|
||||
EntityWither entitywither = new EntityWither(worldIn);
|
||||
BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
|
||||
entitywither.setLocationAndAngles((double) blockpos1.getX() + 0.5D, (double) blockpos1.getY() + 0.55D,
|
||||
(double) blockpos1.getZ() + 0.5D,
|
||||
blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F, 0.0F);
|
||||
entitywither.renderYawOffset = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X
|
||||
? 0.0F
|
||||
: 90.0F;
|
||||
entitywither.func_82206_m();
|
||||
|
||||
for (EntityPlayer entityplayer : worldIn.getEntitiesWithinAABB(EntityPlayer.class,
|
||||
entitywither.getEntityBoundingBox().expand(50.0D, 50.0D, 50.0D))) {
|
||||
entityplayer.triggerAchievement(AchievementList.spawnWither);
|
||||
}
|
||||
|
||||
worldIn.spawnEntityInWorld(entitywither);
|
||||
|
||||
for (int l = 0; l < 120; ++l) {
|
||||
worldIn.spawnParticle(EnumParticleTypes.SNOWBALL,
|
||||
(double) blockpos.getX() + worldIn.rand.nextDouble(),
|
||||
(double) (blockpos.getY() - 2) + worldIn.rand.nextDouble() * 3.9D,
|
||||
(double) blockpos.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < blockpattern.getPalmLength(); ++i1) {
|
||||
for (int j1 = 0; j1 < blockpattern.getThumbLength(); ++j1) {
|
||||
BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(i1, j1, 0);
|
||||
worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.air);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
|||
|
|
@ -9,8 +9,11 @@ import net.minecraft.block.properties.PropertyEnum;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
@ -188,4 +191,17 @@ public abstract class BlockSlab extends Block {
|
|||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
if (!world.isRemote && MinecraftServer.getServer().worldServers[0].getWorldInfo().getGameRulesInstance()
|
||||
.getBoolean("clickToSit") && entityplayer.getHeldItem() == null) {
|
||||
EntityArrow arrow = new EntityArrow(world, blockpos.getX() + 0.5D, blockpos.getY(), blockpos.getZ() + 0.5D);
|
||||
arrow.isChair = true;
|
||||
world.spawnEntityInWorld(arrow);
|
||||
entityplayer.mountEntity(arrow);
|
||||
return true;
|
||||
}
|
||||
return super.onBlockActivated(world, blockpos, var3, entityplayer, var5, var6, var7, var8);
|
||||
}
|
||||
}
|
||||
|
|
@ -102,11 +102,15 @@ public class BlockStainedGlass extends BlockBreakable {
|
|||
}
|
||||
|
||||
public void onBlockAdded(World world, BlockPos blockpos, IBlockState var3) {
|
||||
|
||||
if (!world.isRemote) {
|
||||
BlockBeacon.updateColorAsync(world, blockpos);
|
||||
}
|
||||
}
|
||||
|
||||
public void breakBlock(World world, BlockPos blockpos, IBlockState var3) {
|
||||
|
||||
if (!world.isRemote) {
|
||||
BlockBeacon.updateColorAsync(world, blockpos);
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
|||
|
|
@ -99,10 +99,14 @@ public class BlockStainedGlassPane extends BlockPane {
|
|||
}
|
||||
|
||||
public void onBlockAdded(World world, BlockPos blockpos, IBlockState var3) {
|
||||
|
||||
if (!world.isRemote) {
|
||||
BlockBeacon.updateColorAsync(world, blockpos);
|
||||
}
|
||||
}
|
||||
|
||||
public void breakBlock(World world, BlockPos blockpos, IBlockState var3) {
|
||||
|
||||
if (!world.isRemote) {
|
||||
BlockBeacon.updateColorAsync(world, blockpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,9 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
@ -526,6 +528,14 @@ public class BlockStairs extends Block {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
if (!world.isRemote && MinecraftServer.getServer().worldServers[0].getWorldInfo().getGameRulesInstance()
|
||||
.getBoolean("clickToSit") && entityplayer.getHeldItem() == null) {
|
||||
EntityArrow arrow = new EntityArrow(world, blockpos.getX() + 0.5D, blockpos.getY(), blockpos.getZ() + 0.5D);
|
||||
arrow.isChair = true;
|
||||
world.spawnEntityInWorld(arrow);
|
||||
entityplayer.mountEntity(arrow);
|
||||
return true;
|
||||
}
|
||||
return this.modelBlock.onBlockActivated(world, blockpos, this.modelState, entityplayer, EnumFacing.DOWN, 0.0F,
|
||||
0.0F, 0.0F);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
|
@ -148,6 +149,26 @@ public class BlockStem extends BlockBush implements IGrowable {
|
|||
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, (float) this.maxY, 0.5F + f);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Spawns this Block's drops into the World as EntityItems.
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState iblockstate, float f, int i) {
|
||||
super.dropBlockAsItemWithChance(world, blockpos, iblockstate, f, i);
|
||||
if (!world.isRemote) {
|
||||
Item item = this.getSeedItem();
|
||||
if (item != null) {
|
||||
int j = ((Integer) iblockstate.getValue(AGE)).intValue();
|
||||
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
if (world.rand.nextInt(15) <= j) {
|
||||
spawnAsEntity(world, blockpos, new ItemStack(item));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Item getSeedItem() {
|
||||
return this.crop == Blocks.pumpkin ? Items.pumpkin_seeds
|
||||
: (this.crop == Blocks.melon_block ? Items.melon_seeds : null);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@ import net.minecraft.block.properties.PropertyBool;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
|
@ -64,6 +67,19 @@ public class BlockTNT extends Block {
|
|||
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when this Block is destroyed by an Explosion
|
||||
*/
|
||||
public void onBlockDestroyedByExplosion(World world, BlockPos blockpos, Explosion explosion) {
|
||||
if (!world.isRemote) {
|
||||
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockpos.getX() + 0.5F),
|
||||
(double) blockpos.getY(), (double) ((float) blockpos.getZ() + 0.5F),
|
||||
explosion.getExplosivePlacedBy());
|
||||
entitytntprimed.fuse = world.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
|
||||
world.spawnEntityInWorld(entitytntprimed);
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a player destroys this Block
|
||||
*/
|
||||
|
|
@ -72,7 +88,14 @@ public class BlockTNT extends Block {
|
|||
}
|
||||
|
||||
public void explode(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
|
||||
|
||||
if (!worldIn.isRemote) {
|
||||
if (((Boolean) state.getValue(EXPLODE)).booleanValue()) {
|
||||
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
|
||||
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter);
|
||||
worldIn.spawnEntityInWorld(entitytntprimed);
|
||||
worldIn.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer entityplayer,
|
||||
|
|
@ -95,6 +118,24 @@ public class BlockTNT extends Block {
|
|||
return super.onBlockActivated(world, blockpos, iblockstate, entityplayer, enumfacing, f, f1, f2);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called When an Entity Collided with the Block
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World world, BlockPos blockpos, IBlockState var3, Entity entity) {
|
||||
if (!world.isRemote && entity instanceof EntityArrow) {
|
||||
EntityArrow entityarrow = (EntityArrow) entity;
|
||||
if (entityarrow.isBurning()) {
|
||||
this.explode(world, blockpos,
|
||||
world.getBlockState(blockpos).withProperty(EXPLODE, Boolean.valueOf(true)),
|
||||
entityarrow.shootingEntity instanceof EntityLivingBase
|
||||
? (EntityLivingBase) entityarrow.shootingEntity
|
||||
: null);
|
||||
world.setBlockToAir(blockpos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether this block can drop from an explosion.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,10 +9,13 @@ import net.minecraft.block.properties.PropertyEnum;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.world.ColorizerGrass;
|
||||
|
|
@ -97,6 +100,19 @@ public class BlockTallGrass extends BlockBush implements IGrowable {
|
|||
return 1 + random.nextInt(i * 2 + 1);
|
||||
}
|
||||
|
||||
public void harvestBlock(World world, EntityPlayer entityplayer, BlockPos blockpos, IBlockState iblockstate,
|
||||
TileEntity tileentity) {
|
||||
if (!world.isRemote && entityplayer.getCurrentEquippedItem() != null
|
||||
&& entityplayer.getCurrentEquippedItem().getItem() == Items.shears) {
|
||||
entityplayer.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||
spawnAsEntity(world, blockpos, new ItemStack(Blocks.tallgrass, 1,
|
||||
((BlockTallGrass.EnumType) iblockstate.getValue(TYPE)).getMeta()));
|
||||
} else {
|
||||
super.harvestBlock(world, entityplayer, blockpos, iblockstate, tileentity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getDamageValue(World world, BlockPos blockpos) {
|
||||
IBlockState iblockstate = world.getBlockState(blockpos);
|
||||
return iblockstate.getBlock().getMetaFromState(iblockstate);
|
||||
|
|
|
|||
|
|
@ -144,6 +144,28 @@ public class BlockTrapDoor extends Block {
|
|||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a neighboring block changes.
|
||||
*/
|
||||
public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState iblockstate, Block block) {
|
||||
if (!world.isRemote) {
|
||||
BlockPos blockpos1 = blockpos.offset(((EnumFacing) iblockstate.getValue(FACING)).getOpposite());
|
||||
if (!isValidSupportBlock(world.getBlockState(blockpos1).getBlock())) {
|
||||
world.setBlockToAir(blockpos);
|
||||
this.dropBlockAsItem(world, blockpos, iblockstate, 0);
|
||||
} else {
|
||||
boolean flag = world.isBlockPowered(blockpos);
|
||||
if (flag || block.canProvidePower()) {
|
||||
boolean flag1 = ((Boolean) iblockstate.getValue(OPEN)).booleanValue();
|
||||
if (flag1 != flag) {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(OPEN, Boolean.valueOf(flag)), 2);
|
||||
world.playAuxSFXAtEntity((EntityPlayer) null, flag ? 1003 : 1006, blockpos, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Ray traces through the blocks collision from start vector to
|
||||
* end vector returning a ray trace hit.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package net.minecraft.block;
|
||||
|
||||
import java.util.List;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
|
@ -7,6 +8,8 @@ import net.minecraft.block.properties.IProperty;
|
|||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
|
|
@ -144,6 +147,15 @@ public class BlockTripWire extends Block {
|
|||
this.notifyHook(world, blockpos, iblockstate.withProperty(POWERED, Boolean.valueOf(true)));
|
||||
}
|
||||
|
||||
public void onBlockHarvested(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer entityplayer) {
|
||||
if (!world.isRemote) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null
|
||||
&& entityplayer.getCurrentEquippedItem().getItem() == Items.shears) {
|
||||
world.setBlockState(blockpos, iblockstate.withProperty(DISARMED, Boolean.valueOf(true)), 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyHook(World worldIn, BlockPos pos, IBlockState state) {
|
||||
for (EnumFacing enumfacing : new EnumFacing[] { EnumFacing.SOUTH, EnumFacing.WEST }) {
|
||||
for (int i = 1; i < 42; ++i) {
|
||||
|
|
@ -164,6 +176,61 @@ public class BlockTripWire extends Block {
|
|||
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called When an Entity Collided with the Block
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World world, BlockPos blockpos, IBlockState iblockstate, Entity var4) {
|
||||
if (!world.isRemote) {
|
||||
if (!((Boolean) iblockstate.getValue(POWERED)).booleanValue()) {
|
||||
this.updateState(world, blockpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called randomly when setTickRandomly is set to true (used by
|
||||
* e.g. crops to grow, etc.)
|
||||
*/
|
||||
public void randomTick(World var1, BlockPos var2, IBlockState var3, EaglercraftRandom var4) {
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom var4) {
|
||||
if (!world.isRemote) {
|
||||
if (((Boolean) world.getBlockState(blockpos).getValue(POWERED)).booleanValue()) {
|
||||
this.updateState(world, blockpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateState(World worldIn, BlockPos pos) {
|
||||
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||
boolean flag = ((Boolean) iblockstate.getValue(POWERED)).booleanValue();
|
||||
boolean flag1 = false;
|
||||
List list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity) null,
|
||||
new AxisAlignedBB((double) pos.getX() + this.minX, (double) pos.getY() + this.minY,
|
||||
(double) pos.getZ() + this.minZ, (double) pos.getX() + this.maxX,
|
||||
(double) pos.getY() + this.maxY, (double) pos.getZ() + this.maxZ));
|
||||
if (!list.isEmpty()) {
|
||||
for (Entity entity : (List<Entity>) list) {
|
||||
if (!entity.doesEntityNotTriggerPressurePlate()) {
|
||||
flag1 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1 != flag) {
|
||||
iblockstate = iblockstate.withProperty(POWERED, Boolean.valueOf(flag1));
|
||||
worldIn.setBlockState(pos, iblockstate, 3);
|
||||
this.notifyHook(worldIn, pos, iblockstate);
|
||||
}
|
||||
|
||||
if (flag1) {
|
||||
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isConnectedTo(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing direction) {
|
||||
BlockPos blockpos = pos.offset(direction);
|
||||
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,13 @@ import net.minecraft.block.state.BlockState;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
@ -216,6 +222,142 @@ public class BlockVine extends Block {
|
|||
return iblockaccess.getBiomeGenForCoords(blockpos).getFoliageColorAtPos(blockpos);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when a neighboring block changes.
|
||||
*/
|
||||
public void onNeighborBlockChange(World world, BlockPos blockpos, IBlockState iblockstate, Block var4) {
|
||||
if (!world.isRemote && !this.recheckGrownSides(world, blockpos, iblockstate)) {
|
||||
this.dropBlockAsItem(world, blockpos, iblockstate, 0);
|
||||
world.setBlockToAir(blockpos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateTick(World world, BlockPos blockpos, IBlockState iblockstate, EaglercraftRandom random) {
|
||||
if (!world.isRemote) {
|
||||
if (world.rand.nextInt(4) == 0) {
|
||||
byte b0 = 4;
|
||||
int i = 5;
|
||||
boolean flag = false;
|
||||
|
||||
label62: for (int j = -b0; j <= b0; ++j) {
|
||||
for (int k = -b0; k <= b0; ++k) {
|
||||
for (int l = -1; l <= 1; ++l) {
|
||||
if (world.getBlockState(blockpos.add(j, l, k)).getBlock() == this) {
|
||||
--i;
|
||||
if (i <= 0) {
|
||||
flag = true;
|
||||
break label62;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnumFacing enumfacing1 = EnumFacing.random(random);
|
||||
BlockPos blockpos2 = blockpos.up();
|
||||
if (enumfacing1 == EnumFacing.UP && blockpos.getY() < 255 && world.isAirBlock(blockpos2)) {
|
||||
if (!flag) {
|
||||
IBlockState iblockstate3 = iblockstate;
|
||||
|
||||
for (EnumFacing enumfacing3 : EnumFacing.Plane.HORIZONTAL) {
|
||||
if (random.nextBoolean() || !this
|
||||
.canPlaceOn(world.getBlockState(blockpos2.offset(enumfacing3)).getBlock())) {
|
||||
iblockstate3 = iblockstate3.withProperty(getPropertyFor(enumfacing3),
|
||||
Boolean.valueOf(false));
|
||||
}
|
||||
}
|
||||
|
||||
if (((Boolean) iblockstate3.getValue(NORTH)).booleanValue()
|
||||
|| ((Boolean) iblockstate3.getValue(EAST)).booleanValue()
|
||||
|| ((Boolean) iblockstate3.getValue(SOUTH)).booleanValue()
|
||||
|| ((Boolean) iblockstate3.getValue(WEST)).booleanValue()) {
|
||||
world.setBlockState(blockpos2, iblockstate3, 2);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (enumfacing1.getAxis().isHorizontal()
|
||||
&& !((Boolean) iblockstate.getValue(getPropertyFor(enumfacing1))).booleanValue()) {
|
||||
if (!flag) {
|
||||
BlockPos blockpos4 = blockpos.offset(enumfacing1);
|
||||
Block block1 = world.getBlockState(blockpos4).getBlock();
|
||||
if (block1.blockMaterial == Material.air) {
|
||||
EnumFacing enumfacing2 = enumfacing1.rotateY();
|
||||
EnumFacing enumfacing4 = enumfacing1.rotateYCCW();
|
||||
boolean flag1 = ((Boolean) iblockstate.getValue(getPropertyFor(enumfacing2)))
|
||||
.booleanValue();
|
||||
boolean flag2 = ((Boolean) iblockstate.getValue(getPropertyFor(enumfacing4)))
|
||||
.booleanValue();
|
||||
BlockPos blockpos5 = blockpos4.offset(enumfacing2);
|
||||
BlockPos blockpos1 = blockpos4.offset(enumfacing4);
|
||||
if (flag1 && this.canPlaceOn(world.getBlockState(blockpos5).getBlock())) {
|
||||
world.setBlockState(blockpos4, this.getDefaultState()
|
||||
.withProperty(getPropertyFor(enumfacing2), Boolean.valueOf(true)), 2);
|
||||
} else if (flag2 && this.canPlaceOn(world.getBlockState(blockpos1).getBlock())) {
|
||||
world.setBlockState(blockpos4, this.getDefaultState()
|
||||
.withProperty(getPropertyFor(enumfacing4), Boolean.valueOf(true)), 2);
|
||||
} else if (flag1 && world.isAirBlock(blockpos5)
|
||||
&& this.canPlaceOn(world.getBlockState(blockpos.offset(enumfacing2)).getBlock())) {
|
||||
world.setBlockState(blockpos5, this.getDefaultState().withProperty(
|
||||
getPropertyFor(enumfacing1.getOpposite()), Boolean.valueOf(true)), 2);
|
||||
} else if (flag2 && world.isAirBlock(blockpos1)
|
||||
&& this.canPlaceOn(world.getBlockState(blockpos.offset(enumfacing4)).getBlock())) {
|
||||
world.setBlockState(blockpos1, this.getDefaultState().withProperty(
|
||||
getPropertyFor(enumfacing1.getOpposite()), Boolean.valueOf(true)), 2);
|
||||
} else if (this.canPlaceOn(world.getBlockState(blockpos4.up()).getBlock())) {
|
||||
world.setBlockState(blockpos4, this.getDefaultState(), 2);
|
||||
}
|
||||
} else if (block1.blockMaterial.isOpaque() && block1.isFullCube()) {
|
||||
world.setBlockState(blockpos,
|
||||
iblockstate.withProperty(getPropertyFor(enumfacing1), Boolean.valueOf(true)), 2);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (blockpos.getY() > 1) {
|
||||
BlockPos blockpos3 = blockpos.down();
|
||||
IBlockState iblockstate1 = world.getBlockState(blockpos3);
|
||||
Block block = iblockstate1.getBlock();
|
||||
if (block.blockMaterial == Material.air) {
|
||||
IBlockState iblockstate2 = iblockstate;
|
||||
|
||||
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
|
||||
if (random.nextBoolean()) {
|
||||
iblockstate2 = iblockstate2.withProperty(getPropertyFor(enumfacing),
|
||||
Boolean.valueOf(false));
|
||||
}
|
||||
}
|
||||
|
||||
if (((Boolean) iblockstate2.getValue(NORTH)).booleanValue()
|
||||
|| ((Boolean) iblockstate2.getValue(EAST)).booleanValue()
|
||||
|| ((Boolean) iblockstate2.getValue(SOUTH)).booleanValue()
|
||||
|| ((Boolean) iblockstate2.getValue(WEST)).booleanValue()) {
|
||||
world.setBlockState(blockpos3, iblockstate2, 2);
|
||||
}
|
||||
} else if (block == this) {
|
||||
IBlockState iblockstate4 = iblockstate1;
|
||||
|
||||
for (EnumFacing enumfacing5 : EnumFacing.Plane.HORIZONTAL) {
|
||||
PropertyBool propertybool = getPropertyFor(enumfacing5);
|
||||
if (random.nextBoolean()
|
||||
&& ((Boolean) iblockstate.getValue(propertybool)).booleanValue()) {
|
||||
iblockstate4 = iblockstate4.withProperty(propertybool, Boolean.valueOf(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (((Boolean) iblockstate4.getValue(NORTH)).booleanValue()
|
||||
|| ((Boolean) iblockstate4.getValue(EAST)).booleanValue()
|
||||
|| ((Boolean) iblockstate4.getValue(SOUTH)).booleanValue()
|
||||
|| ((Boolean) iblockstate4.getValue(WEST)).booleanValue()) {
|
||||
world.setBlockState(blockpos3, iblockstate4, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called by ItemBlocks just before a block is actually set in
|
||||
* the world, to allow for adjustments to the IBlockstate
|
||||
|
|
@ -244,6 +386,18 @@ public class BlockVine extends Block {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public void harvestBlock(World world, EntityPlayer entityplayer, BlockPos blockpos, IBlockState iblockstate,
|
||||
TileEntity tileentity) {
|
||||
if (!world.isRemote && entityplayer.getCurrentEquippedItem() != null
|
||||
&& entityplayer.getCurrentEquippedItem().getItem() == Items.shears) {
|
||||
entityplayer.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||
spawnAsEntity(world, blockpos, new ItemStack(Blocks.vine, 1, 0));
|
||||
} else {
|
||||
super.harvestBlock(world, entityplayer, blockpos, iblockstate, tileentity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public EnumWorldBlockLayer getBlockLayer() {
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import net.minecraft.entity.player.InventoryPlayer;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ContainerWorkbench;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
@ -43,7 +44,13 @@ public class BlockWorkbench extends Block {
|
|||
|
||||
public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState var3, EntityPlayer entityplayer,
|
||||
EnumFacing var5, float var6, float var7, float var8) {
|
||||
return true;
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
entityplayer.displayGui(new BlockWorkbench.InterfaceCraftingTable(world, blockpos));
|
||||
entityplayer.triggerAchievement(StatList.field_181742_Z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InterfaceCraftingTable implements IInteractionObject {
|
||||
|
|
|
|||
|
|
@ -33,4 +33,6 @@ public interface IGrowable {
|
|||
boolean canGrow(World var1, BlockPos var2, IBlockState var3, boolean var4);
|
||||
|
||||
boolean canUseBonemeal(World var1, EaglercraftRandom var2, BlockPos var3, IBlockState var4);
|
||||
|
||||
void grow(World var1, EaglercraftRandom var2, BlockPos var3, IBlockState var4);
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ public class FactoryBlockPattern {
|
|||
}
|
||||
|
||||
public FactoryBlockPattern aisle(String... aisle) {
|
||||
if (aisle.length > 0 && !StringUtils.isEmpty(aisle[0])) {
|
||||
if (!(aisle == null || aisle.length <= 0) && !StringUtils.isEmpty(aisle[0])) {
|
||||
if (this.depth.isEmpty()) {
|
||||
this.aisleHeight = aisle.length;
|
||||
this.rowWidth = aisle[0].length();
|
||||
|
|
@ -67,7 +67,7 @@ public class FactoryBlockPattern {
|
|||
|
||||
for (char c0 : s.toCharArray()) {
|
||||
if (!this.symbolMap.containsKey(Character.valueOf(c0))) {
|
||||
this.symbolMap.put(Character.valueOf(c0), (Predicate<BlockWorldState>) null);
|
||||
this.symbolMap.put(Character.valueOf(c0), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -95,8 +95,7 @@ public class FactoryBlockPattern {
|
|||
|
||||
private Predicate<BlockWorldState>[][][] makePredicateArray() {
|
||||
this.checkMissingPredicates();
|
||||
Predicate[][][] apredicate = (Predicate[][][]) ((Predicate[][][]) Array.newInstance(Predicate.class,
|
||||
new int[] { this.depth.size(), this.aisleHeight, this.rowWidth }));
|
||||
Predicate[][][] apredicate = new Predicate[this.depth.size()][this.aisleHeight][this.rowWidth];
|
||||
|
||||
for (int i = 0; i < this.depth.size(); ++i) {
|
||||
for (int j = 0; j < this.aisleHeight; ++j) {
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ public class Minecraft implements IThreadListener {
|
|||
|
||||
public Minecraft(GameConfiguration gameConfig) {
|
||||
theMinecraft = this;
|
||||
StringTranslate.doCLINIT();
|
||||
StringTranslate.initClient();
|
||||
this.launchedVersion = gameConfig.gameInfo.version;
|
||||
this.mcDefaultResourcePack = new DefaultResourcePack();
|
||||
this.session = gameConfig.userInfo.session;
|
||||
|
|
@ -2054,7 +2054,7 @@ public class Minecraft implements IThreadListener {
|
|||
}
|
||||
|
||||
public ListenableFuture<Object> scheduleResourcesRefresh() {
|
||||
return this.addScheduledTask(new Runnable() {
|
||||
return this.addScheduledTaskFuture(new Runnable() {
|
||||
public void run() {
|
||||
Minecraft.this.loadingScreen.eaglerShow(I18n.format("resourcePack.load.refreshing"),
|
||||
I18n.format("resourcePack.load.pleaseWait"));
|
||||
|
|
@ -2186,7 +2186,7 @@ public class Minecraft implements IThreadListener {
|
|||
this.entityRenderer.loadEntityShader(viewingEntity);
|
||||
}
|
||||
|
||||
public <V> ListenableFuture<V> addScheduledTask(Callable<V> callableToSchedule) {
|
||||
public <V> ListenableFuture<V> addScheduledTaskFuture(Callable<V> callableToSchedule) {
|
||||
Validate.notNull(callableToSchedule);
|
||||
ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callableToSchedule);
|
||||
synchronized (this.scheduledTasks) {
|
||||
|
|
@ -2195,9 +2195,13 @@ public class Minecraft implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
public ListenableFuture<Object> addScheduledTask(Runnable runnableToSchedule) {
|
||||
public ListenableFuture<Object> addScheduledTaskFuture(Runnable runnableToSchedule) {
|
||||
Validate.notNull(runnableToSchedule);
|
||||
return this.addScheduledTask(Executors.callable(runnableToSchedule));
|
||||
return this.addScheduledTaskFuture(Executors.callable(runnableToSchedule));
|
||||
}
|
||||
|
||||
public void addScheduledTask(Runnable runnableToSchedule) {
|
||||
this.addScheduledTaskFuture(Executors.callable(runnableToSchedule));
|
||||
}
|
||||
|
||||
public BlockRendererDispatcher getBlockRendererDispatcher() {
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ public class GuiOverlayDebug extends Gui {
|
|||
Float.valueOf(MathHelper.wrapAngleTo180_float(entity.rotationPitch)) }) });
|
||||
if (this.mc.theWorld != null && this.mc.theWorld.isBlockLoaded(blockpos)) {
|
||||
Chunk chunk = this.mc.theWorld.getChunkFromBlockCoords(blockpos);
|
||||
arraylist.add("Biome: " + chunk.getBiome(blockpos).biomeName);
|
||||
arraylist.add("Biome: " + chunk.getBiome(blockpos, null).biomeName);
|
||||
arraylist.add("Light: " + chunk.getLightSubtracted(blockpos, 0) + " ("
|
||||
+ chunk.getLightFor(EnumSkyBlock.SKY, blockpos) + " sky, "
|
||||
+ chunk.getLightFor(EnumSkyBlock.BLOCK, blockpos) + " block)");
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import net.lax1dude.eaglercraft.v1_8.netty.Unpooled;
|
|||
import net.lax1dude.eaglercraft.v1_8.profile.ServerSkinCache;
|
||||
import net.lax1dude.eaglercraft.v1_8.profile.SkinPackets;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.EaglercraftNetworkManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.lan.LANClientNetworkManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.socket.ClientIntegratedServerNetworkManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.update.UpdateService;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
|
|
@ -239,6 +241,7 @@ public class NetHandlerPlayClient implements INetHandlerPlayClient {
|
|||
private final Map<EaglercraftUUID, NetworkPlayerInfo> playerInfoMap = Maps.newHashMap();
|
||||
public int currentServerMaxPlayers = 20;
|
||||
private boolean field_147308_k = false;
|
||||
private boolean isIntegratedServer = false;
|
||||
/**+
|
||||
* Just an ordinary random number generator, used to randomize
|
||||
* audio pitch of item/orb pickup and randomize both
|
||||
|
|
@ -254,6 +257,8 @@ public class NetHandlerPlayClient implements INetHandlerPlayClient {
|
|||
this.netManager = parNetworkManager;
|
||||
this.profile = parGameProfile;
|
||||
this.skinCache = new ServerSkinCache(parNetworkManager, mcIn.getTextureManager());
|
||||
this.isIntegratedServer = (parNetworkManager instanceof ClientIntegratedServerNetworkManager)
|
||||
|| (parNetworkManager instanceof LANClientNetworkManager);
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
@ -1769,4 +1774,8 @@ public class NetHandlerPlayClient implements INetHandlerPlayClient {
|
|||
public GameProfile getGameProfile() {
|
||||
return this.profile;
|
||||
}
|
||||
|
||||
public boolean isClientInEaglerSingleplayerOrLAN() {
|
||||
return isIntegratedServer;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package net.minecraft.client.renderer.entity;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DynamicLightManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture.EmissiveItems;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
|
@ -55,9 +57,18 @@ public class RenderSnowball<T extends Entity> extends Render<T> {
|
|||
GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
|
||||
this.bindTexture(TextureMap.locationBlocksTexture);
|
||||
this.field_177083_e.func_181564_a(this.func_177082_d(entity), ItemCameraTransforms.TransformType.GROUND);
|
||||
ItemStack itm = this.func_177082_d(entity);
|
||||
this.field_177083_e.func_181564_a(itm, ItemCameraTransforms.TransformType.GROUND);
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.popMatrix();
|
||||
if (DynamicLightManager.isRenderingLights()) {
|
||||
float[] emission = EmissiveItems.getItemEmission(itm);
|
||||
if (emission != null) {
|
||||
float mag = 0.1f;
|
||||
DynamicLightManager.renderDynamicLight("entity_" + entity.getEntityId() + "_item_throw", d0, d1, d2,
|
||||
emission[0] * mag, emission[1] * mag, emission[2] * mag, false);
|
||||
}
|
||||
}
|
||||
super.doRender(entity, d0, d1, d2, f, f1);
|
||||
}
|
||||
|
||||
|
|
|
|||
662
src/main/java/net/minecraft/command/CommandBase.java
Executable file
662
src/main/java/net/minecraft/command/CommandBase.java
Executable file
|
|
@ -0,0 +1,662 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Doubles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.EntityNotFoundException;
|
||||
import net.minecraft.command.IAdminCommand;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.NumberInvalidException;
|
||||
import net.minecraft.command.PlayerNotFoundException;
|
||||
import net.minecraft.command.PlayerSelector;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public abstract class CommandBase implements ICommand {
|
||||
|
||||
private static IAdminCommand theAdmin;
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets a list of aliases for this command
|
||||
*/
|
||||
public List<String> getCommandAliases() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Returns true if the given command sender is allowed to use
|
||||
* this command.
|
||||
*/
|
||||
public boolean canCommandSenderUseCommand(ICommandSender icommandsender) {
|
||||
return icommandsender.canCommandSenderUseCommand(this.getRequiredPermissionLevel(), this.getCommandName());
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] var2, BlockPos var3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int parseInt(String input) throws NumberInvalidException {
|
||||
try {
|
||||
return Integer.parseInt(input);
|
||||
} catch (NumberFormatException var2) {
|
||||
throw new NumberInvalidException("commands.generic.num.invalid", new Object[] { input });
|
||||
}
|
||||
}
|
||||
|
||||
public static int parseInt(String input, int min) throws NumberInvalidException {
|
||||
return parseInt(input, min, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public static int parseInt(String input, int min, int max) throws NumberInvalidException {
|
||||
int i = parseInt(input);
|
||||
if (i < min) {
|
||||
throw new NumberInvalidException("commands.generic.num.tooSmall",
|
||||
new Object[] { Integer.valueOf(i), Integer.valueOf(min) });
|
||||
} else if (i > max) {
|
||||
throw new NumberInvalidException("commands.generic.num.tooBig",
|
||||
new Object[] { Integer.valueOf(i), Integer.valueOf(max) });
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static long parseLong(String input) throws NumberInvalidException {
|
||||
try {
|
||||
return Long.parseLong(input);
|
||||
} catch (NumberFormatException var2) {
|
||||
throw new NumberInvalidException("commands.generic.num.invalid", new Object[] { input });
|
||||
}
|
||||
}
|
||||
|
||||
public static long parseLong(String input, long min, long max) throws NumberInvalidException {
|
||||
long i = parseLong(input);
|
||||
if (i < min) {
|
||||
throw new NumberInvalidException("commands.generic.num.tooSmall",
|
||||
new Object[] { Long.valueOf(i), Long.valueOf(min) });
|
||||
} else if (i > max) {
|
||||
throw new NumberInvalidException("commands.generic.num.tooBig",
|
||||
new Object[] { Long.valueOf(i), Long.valueOf(max) });
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockPos parseBlockPos(ICommandSender sender, String[] args, int startIndex, boolean centerBlock)
|
||||
throws NumberInvalidException {
|
||||
BlockPos blockpos = sender.getPosition();
|
||||
return new BlockPos(parseDouble((double) blockpos.getX(), args[startIndex], -30000000, 30000000, centerBlock),
|
||||
parseDouble((double) blockpos.getY(), args[startIndex + 1], 0, 256, false),
|
||||
parseDouble((double) blockpos.getZ(), args[startIndex + 2], -30000000, 30000000, centerBlock));
|
||||
}
|
||||
|
||||
public static double parseDouble(String input) throws NumberInvalidException {
|
||||
try {
|
||||
double d0 = Double.parseDouble(input);
|
||||
if (!Doubles.isFinite(d0)) {
|
||||
throw new NumberInvalidException("commands.generic.num.invalid", new Object[] { input });
|
||||
} else {
|
||||
return d0;
|
||||
}
|
||||
} catch (NumberFormatException var3) {
|
||||
throw new NumberInvalidException("commands.generic.num.invalid", new Object[] { input });
|
||||
}
|
||||
}
|
||||
|
||||
public static double parseDouble(String input, double min) throws NumberInvalidException {
|
||||
return parseDouble(input, min, Double.MAX_VALUE);
|
||||
}
|
||||
|
||||
public static double parseDouble(String input, double min, double max) throws NumberInvalidException {
|
||||
double d0 = parseDouble(input);
|
||||
if (d0 < min) {
|
||||
throw new NumberInvalidException("commands.generic.double.tooSmall",
|
||||
new Object[] { Double.valueOf(d0), Double.valueOf(min) });
|
||||
} else if (d0 > max) {
|
||||
throw new NumberInvalidException("commands.generic.double.tooBig",
|
||||
new Object[] { Double.valueOf(d0), Double.valueOf(max) });
|
||||
} else {
|
||||
return d0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean parseBoolean(String input) throws CommandException {
|
||||
if (!input.equals("true") && !input.equals("1")) {
|
||||
if (!input.equals("false") && !input.equals("0")) {
|
||||
throw new CommandException("commands.generic.boolean.invalid", new Object[] { input });
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Returns the given ICommandSender as a EntityPlayer or throw
|
||||
* an exception.
|
||||
*/
|
||||
public static EntityPlayerMP getCommandSenderAsPlayer(ICommandSender sender) throws PlayerNotFoundException {
|
||||
if (sender instanceof EntityPlayerMP) {
|
||||
return (EntityPlayerMP) sender;
|
||||
} else {
|
||||
throw new PlayerNotFoundException("You must specify which player you wish to perform this action on.",
|
||||
new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityPlayerMP getPlayer(ICommandSender sender, String username) throws PlayerNotFoundException {
|
||||
EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(sender, username);
|
||||
if (entityplayermp == null) {
|
||||
try {
|
||||
entityplayermp = MinecraftServer.getServer().getConfigurationManager()
|
||||
.getPlayerByUUID(EaglercraftUUID.fromString(username));
|
||||
} catch (IllegalArgumentException var4) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (entityplayermp == null) {
|
||||
entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(username);
|
||||
}
|
||||
|
||||
if (entityplayermp == null) {
|
||||
throw new PlayerNotFoundException();
|
||||
} else {
|
||||
return entityplayermp;
|
||||
}
|
||||
}
|
||||
|
||||
public static Entity func_175768_b(ICommandSender parICommandSender, String parString1)
|
||||
throws EntityNotFoundException {
|
||||
return getEntity(parICommandSender, parString1, Entity.class);
|
||||
}
|
||||
|
||||
public static <T extends Entity> T getEntity(ICommandSender commandSender, String parString1,
|
||||
Class<? extends T> parClass1) throws EntityNotFoundException {
|
||||
Object object = PlayerSelector.matchOneEntity(commandSender, parString1, parClass1);
|
||||
MinecraftServer minecraftserver = MinecraftServer.getServer();
|
||||
if (object == null) {
|
||||
object = minecraftserver.getConfigurationManager().getPlayerByUsername(parString1);
|
||||
}
|
||||
|
||||
if (object == null) {
|
||||
try {
|
||||
EaglercraftUUID uuid = EaglercraftUUID.fromString(parString1);
|
||||
object = minecraftserver.getEntityFromUuid(uuid);
|
||||
if (object == null) {
|
||||
object = minecraftserver.getConfigurationManager().getPlayerByUUID(uuid);
|
||||
}
|
||||
} catch (IllegalArgumentException var6) {
|
||||
throw new EntityNotFoundException("commands.generic.entity.invalidUuid", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (object != null && parClass1.isAssignableFrom(object.getClass())) {
|
||||
return (T) object;
|
||||
} else {
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Entity> func_175763_c(ICommandSender parICommandSender, String parString1)
|
||||
throws EntityNotFoundException {
|
||||
return (List<Entity>) (PlayerSelector.hasArguments(parString1)
|
||||
? PlayerSelector.matchEntities(parICommandSender, parString1, Entity.class)
|
||||
: Lists.newArrayList(new Entity[] { func_175768_b(parICommandSender, parString1) }));
|
||||
}
|
||||
|
||||
public static String getPlayerName(ICommandSender sender, String query) throws PlayerNotFoundException {
|
||||
try {
|
||||
return getPlayer(sender, query).getName();
|
||||
} catch (PlayerNotFoundException playernotfoundexception) {
|
||||
if (PlayerSelector.hasArguments(query)) {
|
||||
throw playernotfoundexception;
|
||||
} else {
|
||||
return query;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Attempts to retrieve an entity's name, first assuming that
|
||||
* the entity is a player, and then exhausting all other
|
||||
* possibilities.
|
||||
*/
|
||||
public static String getEntityName(ICommandSender parICommandSender, String parString1)
|
||||
throws EntityNotFoundException {
|
||||
try {
|
||||
return getPlayer(parICommandSender, parString1).getName();
|
||||
} catch (PlayerNotFoundException var5) {
|
||||
try {
|
||||
return func_175768_b(parICommandSender, parString1).getUniqueID().toString();
|
||||
} catch (EntityNotFoundException entitynotfoundexception) {
|
||||
if (PlayerSelector.hasArguments(parString1)) {
|
||||
throw entitynotfoundexception;
|
||||
} else {
|
||||
return parString1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IChatComponent getChatComponentFromNthArg(ICommandSender sender, String[] args, int parInt1)
|
||||
throws PlayerNotFoundException {
|
||||
return getChatComponentFromNthArg(sender, args, parInt1, false);
|
||||
}
|
||||
|
||||
public static IChatComponent getChatComponentFromNthArg(ICommandSender sender, String[] args, int index,
|
||||
boolean parFlag) throws PlayerNotFoundException {
|
||||
ChatComponentText chatcomponenttext = new ChatComponentText("");
|
||||
|
||||
for (int i = index; i < args.length; ++i) {
|
||||
if (i > index) {
|
||||
chatcomponenttext.appendText(" ");
|
||||
}
|
||||
|
||||
Object object = new ChatComponentText(args[i]);
|
||||
if (parFlag) {
|
||||
IChatComponent ichatcomponent = PlayerSelector.matchEntitiesToChatComponent(sender, args[i]);
|
||||
if (ichatcomponent == null) {
|
||||
if (PlayerSelector.hasArguments(args[i])) {
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
} else {
|
||||
object = ichatcomponent;
|
||||
}
|
||||
}
|
||||
|
||||
chatcomponenttext.appendSibling((IChatComponent) object);
|
||||
}
|
||||
|
||||
return chatcomponenttext;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Builds a string starting at startPos
|
||||
*/
|
||||
public static String buildString(String[] args, int startPos) {
|
||||
StringBuilder stringbuilder = new StringBuilder();
|
||||
|
||||
for (int i = startPos; i < args.length; ++i) {
|
||||
if (i > startPos) {
|
||||
stringbuilder.append(" ");
|
||||
}
|
||||
|
||||
String s = args[i];
|
||||
stringbuilder.append(s);
|
||||
}
|
||||
|
||||
return stringbuilder.toString();
|
||||
}
|
||||
|
||||
public static CommandBase.CoordinateArg parseCoordinate(double base, String centerBlock, boolean parFlag)
|
||||
throws NumberInvalidException {
|
||||
return parseCoordinate(base, centerBlock, -30000000, 30000000, parFlag);
|
||||
}
|
||||
|
||||
public static CommandBase.CoordinateArg parseCoordinate(double min, String max, int centerBlock, int parInt2,
|
||||
boolean parFlag) throws NumberInvalidException {
|
||||
boolean flag = max.startsWith("~");
|
||||
if (flag && Double.isNaN(min)) {
|
||||
throw new NumberInvalidException("commands.generic.num.invalid", new Object[] { Double.valueOf(min) });
|
||||
} else {
|
||||
double d0 = 0.0D;
|
||||
if (!flag || max.length() > 1) {
|
||||
boolean flag1 = max.contains(".");
|
||||
if (flag) {
|
||||
max = max.substring(1);
|
||||
}
|
||||
|
||||
d0 += parseDouble(max);
|
||||
if (!flag1 && !flag && parFlag) {
|
||||
d0 += 0.5D;
|
||||
}
|
||||
}
|
||||
|
||||
if (centerBlock != 0 || parInt2 != 0) {
|
||||
if (d0 < (double) centerBlock) {
|
||||
throw new NumberInvalidException("commands.generic.double.tooSmall",
|
||||
new Object[] { Double.valueOf(d0), Integer.valueOf(centerBlock) });
|
||||
}
|
||||
|
||||
if (d0 > (double) parInt2) {
|
||||
throw new NumberInvalidException("commands.generic.double.tooBig",
|
||||
new Object[] { Double.valueOf(d0), Integer.valueOf(parInt2) });
|
||||
}
|
||||
}
|
||||
|
||||
return new CommandBase.CoordinateArg(d0 + (flag ? min : 0.0D), d0, flag);
|
||||
}
|
||||
}
|
||||
|
||||
public static double parseDouble(double base, String input, boolean centerBlock) throws NumberInvalidException {
|
||||
return parseDouble(base, input, -30000000, 30000000, centerBlock);
|
||||
}
|
||||
|
||||
public static double parseDouble(double base, String input, int min, int max, boolean centerBlock)
|
||||
throws NumberInvalidException {
|
||||
boolean flag = input.startsWith("~");
|
||||
if (flag && Double.isNaN(base)) {
|
||||
throw new NumberInvalidException("commands.generic.num.invalid", new Object[] { Double.valueOf(base) });
|
||||
} else {
|
||||
double d0 = flag ? base : 0.0D;
|
||||
if (!flag || input.length() > 1) {
|
||||
boolean flag1 = input.contains(".");
|
||||
if (flag) {
|
||||
input = input.substring(1);
|
||||
}
|
||||
|
||||
d0 += parseDouble(input);
|
||||
if (!flag1 && !flag && centerBlock) {
|
||||
d0 += 0.5D;
|
||||
}
|
||||
}
|
||||
|
||||
if (min != 0 || max != 0) {
|
||||
if (d0 < (double) min) {
|
||||
throw new NumberInvalidException("commands.generic.double.tooSmall",
|
||||
new Object[] { Double.valueOf(d0), Integer.valueOf(min) });
|
||||
}
|
||||
|
||||
if (d0 > (double) max) {
|
||||
throw new NumberInvalidException("commands.generic.double.tooBig",
|
||||
new Object[] { Double.valueOf(d0), Integer.valueOf(max) });
|
||||
}
|
||||
}
|
||||
|
||||
return d0;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the Item specified by the given text string. First
|
||||
* checks the item registry, then tries by parsing the string as
|
||||
* an integer ID (deprecated). Warns the sender if we matched by
|
||||
* parsing the ID. Throws if the item wasn't found. Returns the
|
||||
* item if it was found.
|
||||
*/
|
||||
public static Item getItemByText(ICommandSender sender, String id) throws NumberInvalidException {
|
||||
ResourceLocation resourcelocation = new ResourceLocation(id);
|
||||
Item item = (Item) Item.itemRegistry.getObject(resourcelocation);
|
||||
if (item == null) {
|
||||
throw new NumberInvalidException("commands.give.item.notFound", new Object[] { resourcelocation });
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the Block specified by the given text string. First
|
||||
* checks the block registry, then tries by parsing the string
|
||||
* as an integer ID (deprecated). Warns the sender if we matched
|
||||
* by parsing the ID. Throws if the block wasn't found. Returns
|
||||
* the block if it was found.
|
||||
*/
|
||||
public static Block getBlockByText(ICommandSender sender, String id) throws NumberInvalidException {
|
||||
ResourceLocation resourcelocation = new ResourceLocation(id);
|
||||
if (!Block.blockRegistry.containsKey(resourcelocation)) {
|
||||
throw new NumberInvalidException("commands.give.block.notFound", new Object[] { resourcelocation });
|
||||
} else {
|
||||
Block block = (Block) Block.blockRegistry.getObject(resourcelocation);
|
||||
if (block == null) {
|
||||
throw new NumberInvalidException("commands.give.block.notFound", new Object[] { resourcelocation });
|
||||
} else {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Creates a linguistic series joining the input objects
|
||||
* together. Examples: 1) {} --> "", 2) {"Steve"} --> "Steve",
|
||||
* 3) {"Steve", "Phil"} --> "Steve and Phil", 4) {"Steve",
|
||||
* "Phil", "Mark"} --> "Steve, Phil and Mark"
|
||||
*/
|
||||
public static String joinNiceString(Object[] elements) {
|
||||
StringBuilder stringbuilder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
String s = elements[i].toString();
|
||||
if (i > 0) {
|
||||
if (i == elements.length - 1) {
|
||||
stringbuilder.append(" and ");
|
||||
} else {
|
||||
stringbuilder.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
stringbuilder.append(s);
|
||||
}
|
||||
|
||||
return stringbuilder.toString();
|
||||
}
|
||||
|
||||
public static IChatComponent join(List<IChatComponent> components) {
|
||||
ChatComponentText chatcomponenttext = new ChatComponentText("");
|
||||
|
||||
for (int i = 0; i < components.size(); ++i) {
|
||||
if (i > 0) {
|
||||
if (i == components.size() - 1) {
|
||||
chatcomponenttext.appendText(" and ");
|
||||
} else if (i > 0) {
|
||||
chatcomponenttext.appendText(", ");
|
||||
}
|
||||
}
|
||||
|
||||
chatcomponenttext.appendSibling((IChatComponent) components.get(i));
|
||||
}
|
||||
|
||||
return chatcomponenttext;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Creates a linguistic series joining together the elements of
|
||||
* the given collection. Examples: 1) {} --> "", 2) {"Steve"}
|
||||
* --> "Steve", 3) {"Steve", "Phil"} --> "Steve and Phil", 4)
|
||||
* {"Steve", "Phil", "Mark"} --> "Steve, Phil and Mark"
|
||||
*/
|
||||
public static String joinNiceStringFromCollection(Collection<String> strings) {
|
||||
/**+
|
||||
* Creates a linguistic series joining the input objects
|
||||
* together. Examples: 1) {} --> "", 2) {"Steve"} --> "Steve",
|
||||
* 3) {"Steve", "Phil"} --> "Steve and Phil", 4) {"Steve",
|
||||
* "Phil", "Mark"} --> "Steve, Phil and Mark"
|
||||
*/
|
||||
return joinNiceString(strings.toArray(new String[strings.size()]));
|
||||
}
|
||||
|
||||
public static List<String> func_175771_a(String[] parArrayOfString, int parInt1, BlockPos parBlockPos) {
|
||||
if (parBlockPos == null) {
|
||||
return null;
|
||||
} else {
|
||||
int i = parArrayOfString.length - 1;
|
||||
String s;
|
||||
if (i == parInt1) {
|
||||
s = Integer.toString(parBlockPos.getX());
|
||||
} else if (i == parInt1 + 1) {
|
||||
s = Integer.toString(parBlockPos.getY());
|
||||
} else {
|
||||
if (i != parInt1 + 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
s = Integer.toString(parBlockPos.getZ());
|
||||
}
|
||||
|
||||
return Lists.newArrayList(new String[] { s });
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> func_181043_b(String[] parArrayOfString, int parInt1, BlockPos parBlockPos) {
|
||||
if (parBlockPos == null) {
|
||||
return null;
|
||||
} else {
|
||||
int i = parArrayOfString.length - 1;
|
||||
String s;
|
||||
if (i == parInt1) {
|
||||
s = Integer.toString(parBlockPos.getX());
|
||||
} else {
|
||||
if (i != parInt1 + 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
s = Integer.toString(parBlockPos.getZ());
|
||||
}
|
||||
|
||||
return Lists.newArrayList(new String[] { s });
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Returns true if the given substring is exactly equal to the
|
||||
* start of the given string (case insensitive).
|
||||
*/
|
||||
public static boolean doesStringStartWith(String original, String region) {
|
||||
return region.regionMatches(true, 0, original, 0, original.length());
|
||||
}
|
||||
|
||||
/**+
|
||||
* Returns a List of strings (chosen from the given strings)
|
||||
* which the last word in the given string array is a
|
||||
* beginning-match for. (Tab completion).
|
||||
*/
|
||||
public static List<String> getListOfStringsMatchingLastWord(String[] args, String... possibilities) {
|
||||
/**+
|
||||
* Returns a List of strings (chosen from the given strings)
|
||||
* which the last word in the given string array is a
|
||||
* beginning-match for. (Tab completion).
|
||||
*/
|
||||
return getListOfStringsMatchingLastWord(args, (Collection) Arrays.asList(possibilities));
|
||||
}
|
||||
|
||||
/**+
|
||||
* Returns a List of strings (chosen from the given strings)
|
||||
* which the last word in the given string array is a
|
||||
* beginning-match for. (Tab completion).
|
||||
*/
|
||||
public static List<String> getListOfStringsMatchingLastWord(String[] parArrayOfString,
|
||||
Collection<?> parCollection) {
|
||||
String s = parArrayOfString[parArrayOfString.length - 1];
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
if (!parCollection.isEmpty()) {
|
||||
for (String s1 : Iterables.transform(parCollection, Functions.toStringFunction())) {
|
||||
if (doesStringStartWith(s, s1)) {
|
||||
arraylist.add(s1);
|
||||
}
|
||||
}
|
||||
|
||||
if (arraylist.isEmpty()) {
|
||||
for (Object object : parCollection) {
|
||||
if (object instanceof ResourceLocation
|
||||
&& doesStringStartWith(s, ((ResourceLocation) object).getResourcePath())) {
|
||||
arraylist.add(String.valueOf(object));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int var2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void notifyOperators(ICommandSender sender, ICommand command, String msgFormat, Object... msgParams) {
|
||||
notifyOperators(sender, command, 0, msgFormat, msgParams);
|
||||
}
|
||||
|
||||
public static void notifyOperators(ICommandSender sender, ICommand command, int msgFormat, String msgParams,
|
||||
Object... parArrayOfObject) {
|
||||
if (theAdmin != null) {
|
||||
theAdmin.notifyOperators(sender, command, msgFormat, msgParams, parArrayOfObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**+
|
||||
* Sets the static IAdminCommander.
|
||||
*/
|
||||
public static void setAdminCommander(IAdminCommand command) {
|
||||
theAdmin = command;
|
||||
}
|
||||
|
||||
public int compareTo(ICommand icommand) {
|
||||
return this.getCommandName().compareTo(icommand.getCommandName());
|
||||
}
|
||||
|
||||
public static class CoordinateArg {
|
||||
private final double field_179633_a;
|
||||
private final double field_179631_b;
|
||||
private final boolean field_179632_c;
|
||||
|
||||
protected CoordinateArg(double parDouble1, double parDouble2, boolean parFlag) {
|
||||
this.field_179633_a = parDouble1;
|
||||
this.field_179631_b = parDouble2;
|
||||
this.field_179632_c = parFlag;
|
||||
}
|
||||
|
||||
public double func_179628_a() {
|
||||
return this.field_179633_a;
|
||||
}
|
||||
|
||||
public double func_179629_b() {
|
||||
return this.field_179631_b;
|
||||
}
|
||||
|
||||
public boolean func_179630_c() {
|
||||
return this.field_179632_c;
|
||||
}
|
||||
}
|
||||
}
|
||||
116
src/main/java/net/minecraft/command/CommandBlockData.java
Executable file
116
src/main/java/net/minecraft/command/CommandBlockData.java
Executable file
|
|
@ -0,0 +1,116 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandBlockData extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "blockdata";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.blockdata.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 4) {
|
||||
throw new WrongUsageException("commands.blockdata.usage", new Object[0]);
|
||||
} else {
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 0);
|
||||
BlockPos blockpos = parseBlockPos(parICommandSender, parArrayOfString, 0, false);
|
||||
World world = parICommandSender.getEntityWorld();
|
||||
if (!world.isBlockLoaded(blockpos)) {
|
||||
throw new CommandException("commands.blockdata.outOfWorld", new Object[0]);
|
||||
} else {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity == null) {
|
||||
throw new CommandException("commands.blockdata.notValid", new Object[0]);
|
||||
} else {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
tileentity.writeToNBT(nbttagcompound);
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttagcompound.copy();
|
||||
|
||||
NBTTagCompound nbttagcompound2;
|
||||
try {
|
||||
nbttagcompound2 = JsonToNBT
|
||||
.getTagFromJson(getChatComponentFromNthArg(parICommandSender, parArrayOfString, 3)
|
||||
.getUnformattedText());
|
||||
} catch (NBTException nbtexception) {
|
||||
throw new CommandException("commands.blockdata.tagError",
|
||||
new Object[] { nbtexception.getMessage() });
|
||||
}
|
||||
|
||||
nbttagcompound.merge(nbttagcompound2);
|
||||
nbttagcompound.setInteger("x", blockpos.getX());
|
||||
nbttagcompound.setInteger("y", blockpos.getY());
|
||||
nbttagcompound.setInteger("z", blockpos.getZ());
|
||||
if (nbttagcompound.equals(nbttagcompound1)) {
|
||||
throw new CommandException("commands.blockdata.failed",
|
||||
new Object[] { nbttagcompound.toString() });
|
||||
} else {
|
||||
tileentity.readFromNBT(nbttagcompound);
|
||||
tileentity.markDirty();
|
||||
world.markBlockForUpdate(blockpos);
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 1);
|
||||
notifyOperators(parICommandSender, this, "commands.blockdata.success",
|
||||
new Object[] { nbttagcompound.toString() });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length > 0 && astring.length <= 3 ? func_175771_a(astring, 0, blockpos) : null;
|
||||
}
|
||||
}
|
||||
122
src/main/java/net/minecraft/command/CommandClearInventory.java
Executable file
122
src/main/java/net/minecraft/command/CommandClearInventory.java
Executable file
|
|
@ -0,0 +1,122 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandClearInventory extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "clear";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.clear.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
EntityPlayerMP entityplayermp = parArrayOfString.length == 0 ? getCommandSenderAsPlayer(parICommandSender)
|
||||
: getPlayer(parICommandSender, parArrayOfString[0]);
|
||||
Item item = parArrayOfString.length >= 2 ? getItemByText(parICommandSender, parArrayOfString[1]) : null;
|
||||
int i = parArrayOfString.length >= 3 ? parseInt(parArrayOfString[2], -1) : -1;
|
||||
int j = parArrayOfString.length >= 4 ? parseInt(parArrayOfString[3], -1) : -1;
|
||||
NBTTagCompound nbttagcompound = null;
|
||||
if (parArrayOfString.length >= 5) {
|
||||
try {
|
||||
nbttagcompound = JsonToNBT.getTagFromJson(buildString(parArrayOfString, 4));
|
||||
} catch (NBTException nbtexception) {
|
||||
throw new CommandException("commands.clear.tagError", new Object[] { nbtexception.getMessage() });
|
||||
}
|
||||
}
|
||||
|
||||
if (parArrayOfString.length >= 2 && item == null) {
|
||||
throw new CommandException("commands.clear.failure", new Object[] { entityplayermp.getName() });
|
||||
} else {
|
||||
int k = entityplayermp.inventory.clearMatchingItems(item, i, j, nbttagcompound);
|
||||
entityplayermp.inventoryContainer.detectAndSendChanges();
|
||||
if (!entityplayermp.capabilities.isCreativeMode) {
|
||||
entityplayermp.updateHeldItem();
|
||||
}
|
||||
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, k);
|
||||
if (k == 0) {
|
||||
throw new CommandException("commands.clear.failure", new Object[] { entityplayermp.getName() });
|
||||
} else {
|
||||
if (j == 0) {
|
||||
parICommandSender.addChatMessage(new ChatComponentTranslation("commands.clear.testing",
|
||||
new Object[] { entityplayermp.getName(), Integer.valueOf(k) }));
|
||||
} else {
|
||||
notifyOperators(parICommandSender, this, "commands.clear.success",
|
||||
new Object[] { entityplayermp.getName(), Integer.valueOf(k) });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1 ? getListOfStringsMatchingLastWord(astring, this.func_147209_d())
|
||||
: (astring.length == 2 ? getListOfStringsMatchingLastWord(astring, Item.itemRegistry.getKeys()) : null);
|
||||
}
|
||||
|
||||
protected String[] func_147209_d() {
|
||||
return MinecraftServer.getServer().getAllUsernames();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 0;
|
||||
}
|
||||
}
|
||||
286
src/main/java/net/minecraft/command/CommandClone.java
Executable file
286
src/main/java/net/minecraft/command/CommandClone.java
Executable file
|
|
@ -0,0 +1,286 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.NextTickListEntry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandClone extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "clone";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.clone.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 9) {
|
||||
throw new WrongUsageException("commands.clone.usage", new Object[0]);
|
||||
} else {
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 0);
|
||||
BlockPos blockpos = parseBlockPos(parICommandSender, parArrayOfString, 0, false);
|
||||
BlockPos blockpos1 = parseBlockPos(parICommandSender, parArrayOfString, 3, false);
|
||||
BlockPos blockpos2 = parseBlockPos(parICommandSender, parArrayOfString, 6, false);
|
||||
StructureBoundingBox structureboundingbox = new StructureBoundingBox(blockpos, blockpos1);
|
||||
StructureBoundingBox structureboundingbox1 = new StructureBoundingBox(blockpos2,
|
||||
blockpos2.add(structureboundingbox.func_175896_b()));
|
||||
int i = structureboundingbox.getXSize() * structureboundingbox.getYSize() * structureboundingbox.getZSize();
|
||||
if (i > '\u8000') {
|
||||
throw new CommandException("commands.clone.tooManyBlocks",
|
||||
new Object[] { Integer.valueOf(i), Integer.valueOf('\u8000') });
|
||||
} else {
|
||||
boolean flag = false;
|
||||
Block block = null;
|
||||
int j = -1;
|
||||
if ((parArrayOfString.length < 11
|
||||
|| !parArrayOfString[10].equals("force") && !parArrayOfString[10].equals("move"))
|
||||
&& structureboundingbox.intersectsWith(structureboundingbox1)) {
|
||||
throw new CommandException("commands.clone.noOverlap", new Object[0]);
|
||||
} else {
|
||||
if (parArrayOfString.length >= 11 && parArrayOfString[10].equals("move")) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (structureboundingbox.minY >= 0 && structureboundingbox.maxY < 256
|
||||
&& structureboundingbox1.minY >= 0 && structureboundingbox1.maxY < 256) {
|
||||
World world = parICommandSender.getEntityWorld();
|
||||
if (world.isAreaLoaded(structureboundingbox) && world.isAreaLoaded(structureboundingbox1)) {
|
||||
boolean flag1 = false;
|
||||
if (parArrayOfString.length >= 10) {
|
||||
if (parArrayOfString[9].equals("masked")) {
|
||||
flag1 = true;
|
||||
} else if (parArrayOfString[9].equals("filtered")) {
|
||||
if (parArrayOfString.length < 12) {
|
||||
throw new WrongUsageException("commands.clone.usage", new Object[0]);
|
||||
}
|
||||
|
||||
block = getBlockByText(parICommandSender, parArrayOfString[11]);
|
||||
if (parArrayOfString.length >= 13) {
|
||||
j = parseInt(parArrayOfString[12], 0, 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
ArrayList arraylist1 = Lists.newArrayList();
|
||||
ArrayList arraylist2 = Lists.newArrayList();
|
||||
LinkedList linkedlist = Lists.newLinkedList();
|
||||
BlockPos blockpos3 = new BlockPos(structureboundingbox1.minX - structureboundingbox.minX,
|
||||
structureboundingbox1.minY - structureboundingbox.minY,
|
||||
structureboundingbox1.minZ - structureboundingbox.minZ);
|
||||
|
||||
for (int k = structureboundingbox.minZ; k <= structureboundingbox.maxZ; ++k) {
|
||||
for (int l = structureboundingbox.minY; l <= structureboundingbox.maxY; ++l) {
|
||||
for (int i1 = structureboundingbox.minX; i1 <= structureboundingbox.maxX; ++i1) {
|
||||
BlockPos blockpos4 = new BlockPos(i1, l, k);
|
||||
BlockPos blockpos5 = blockpos4.add(blockpos3);
|
||||
IBlockState iblockstate = world.getBlockState(blockpos4);
|
||||
if ((!flag1 || iblockstate.getBlock() != Blocks.air) && (block == null
|
||||
|| iblockstate.getBlock() == block && (j < 0 || iblockstate.getBlock()
|
||||
.getMetaFromState(iblockstate) == j))) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos4);
|
||||
if (tileentity != null) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
tileentity.writeToNBT(nbttagcompound);
|
||||
arraylist1.add(new CommandClone.StaticCloneData(blockpos5, iblockstate,
|
||||
nbttagcompound));
|
||||
linkedlist.addLast(blockpos4);
|
||||
} else if (!iblockstate.getBlock().isFullBlock()
|
||||
&& !iblockstate.getBlock().isFullCube()) {
|
||||
arraylist2.add(new CommandClone.StaticCloneData(blockpos5, iblockstate,
|
||||
(NBTTagCompound) null));
|
||||
linkedlist.addFirst(blockpos4);
|
||||
} else {
|
||||
arraylist.add(new CommandClone.StaticCloneData(blockpos5, iblockstate,
|
||||
(NBTTagCompound) null));
|
||||
linkedlist.addLast(blockpos4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
for (BlockPos blockpos6 : (LinkedList<BlockPos>) linkedlist) {
|
||||
TileEntity tileentity1 = world.getTileEntity(blockpos6);
|
||||
if (tileentity1 instanceof IInventory) {
|
||||
((IInventory) tileentity1).clear();
|
||||
}
|
||||
|
||||
world.setBlockState(blockpos6, Blocks.barrier.getDefaultState(), 2);
|
||||
}
|
||||
|
||||
for (BlockPos blockpos7 : (LinkedList<BlockPos>) linkedlist) {
|
||||
world.setBlockState(blockpos7, Blocks.air.getDefaultState(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList arraylist3 = Lists.newArrayList();
|
||||
arraylist3.addAll(arraylist);
|
||||
arraylist3.addAll(arraylist1);
|
||||
arraylist3.addAll(arraylist2);
|
||||
List list = Lists.reverse(arraylist3);
|
||||
|
||||
for (CommandClone.StaticCloneData commandclone$staticclonedata : (List<CommandClone.StaticCloneData>) list) {
|
||||
TileEntity tileentity2 = world
|
||||
.getTileEntity(commandclone$staticclonedata.field_179537_a);
|
||||
if (tileentity2 instanceof IInventory) {
|
||||
((IInventory) tileentity2).clear();
|
||||
}
|
||||
|
||||
world.setBlockState(commandclone$staticclonedata.field_179537_a,
|
||||
Blocks.barrier.getDefaultState(), 2);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
for (CommandClone.StaticCloneData commandclone$staticclonedata1 : (ArrayList<CommandClone.StaticCloneData>) arraylist3) {
|
||||
if (world.setBlockState(commandclone$staticclonedata1.field_179537_a,
|
||||
commandclone$staticclonedata1.blockState, 2)) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
for (CommandClone.StaticCloneData commandclone$staticclonedata2 : (ArrayList<CommandClone.StaticCloneData>) arraylist1) {
|
||||
TileEntity tileentity3 = world
|
||||
.getTileEntity(commandclone$staticclonedata2.field_179537_a);
|
||||
if (commandclone$staticclonedata2.field_179536_c != null && tileentity3 != null) {
|
||||
commandclone$staticclonedata2.field_179536_c.setInteger("x",
|
||||
commandclone$staticclonedata2.field_179537_a.getX());
|
||||
commandclone$staticclonedata2.field_179536_c.setInteger("y",
|
||||
commandclone$staticclonedata2.field_179537_a.getY());
|
||||
commandclone$staticclonedata2.field_179536_c.setInteger("z",
|
||||
commandclone$staticclonedata2.field_179537_a.getZ());
|
||||
tileentity3.readFromNBT(commandclone$staticclonedata2.field_179536_c);
|
||||
tileentity3.markDirty();
|
||||
}
|
||||
|
||||
world.setBlockState(commandclone$staticclonedata2.field_179537_a,
|
||||
commandclone$staticclonedata2.blockState, 2);
|
||||
}
|
||||
|
||||
for (CommandClone.StaticCloneData commandclone$staticclonedata3 : (List<CommandClone.StaticCloneData>) list) {
|
||||
world.notifyNeighborsRespectDebug(commandclone$staticclonedata3.field_179537_a,
|
||||
commandclone$staticclonedata3.blockState.getBlock());
|
||||
}
|
||||
|
||||
List list1 = world.func_175712_a(structureboundingbox, false);
|
||||
if (list1 != null) {
|
||||
for (NextTickListEntry nextticklistentry : (List<NextTickListEntry>) list1) {
|
||||
if (structureboundingbox.isVecInside(nextticklistentry.position)) {
|
||||
BlockPos blockpos8 = nextticklistentry.position.add(blockpos3);
|
||||
world.scheduleBlockUpdate(blockpos8, nextticklistentry.getBlock(),
|
||||
(int) (nextticklistentry.scheduledTime
|
||||
- world.getWorldInfo().getWorldTotalTime()),
|
||||
nextticklistentry.priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i <= 0) {
|
||||
throw new CommandException("commands.clone.failed", new Object[0]);
|
||||
} else {
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, i);
|
||||
notifyOperators(parICommandSender, this, "commands.clone.success",
|
||||
new Object[] { Integer.valueOf(i) });
|
||||
}
|
||||
} else {
|
||||
throw new CommandException("commands.clone.outOfWorld", new Object[0]);
|
||||
}
|
||||
} else {
|
||||
throw new CommandException("commands.clone.outOfWorld", new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length > 0
|
||||
&& astring.length <= 3
|
||||
? func_175771_a(astring, 0, blockpos)
|
||||
: (astring.length > 3
|
||||
&& astring.length <= 6
|
||||
? func_175771_a(astring, 3, blockpos)
|
||||
: (astring.length > 6 && astring.length <= 9
|
||||
? func_175771_a(astring, 6, blockpos)
|
||||
: (astring.length == 10
|
||||
? getListOfStringsMatchingLastWord(astring,
|
||||
new String[] { "replace", "masked", "filtered" })
|
||||
: (astring.length == 11
|
||||
? getListOfStringsMatchingLastWord(astring,
|
||||
new String[] { "normal", "force", "move" })
|
||||
: (astring.length == 12 && "filtered".equals(astring[9])
|
||||
? getListOfStringsMatchingLastWord(astring,
|
||||
Block.blockRegistry.getKeys())
|
||||
: null)))));
|
||||
}
|
||||
|
||||
static class StaticCloneData {
|
||||
public final BlockPos field_179537_a;
|
||||
public final IBlockState blockState;
|
||||
public final NBTTagCompound field_179536_c;
|
||||
|
||||
public StaticCloneData(BlockPos parBlockPos, IBlockState parIBlockState, NBTTagCompound parNBTTagCompound) {
|
||||
this.field_179537_a = parBlockPos;
|
||||
this.blockState = parIBlockState;
|
||||
this.field_179536_c = parNBTTagCompound;
|
||||
}
|
||||
}
|
||||
}
|
||||
159
src/main/java/net/minecraft/command/CommandCompare.java
Executable file
159
src/main/java/net/minecraft/command/CommandCompare.java
Executable file
|
|
@ -0,0 +1,159 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandCompare extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "testforblocks";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.compare.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 9) {
|
||||
throw new WrongUsageException("commands.compare.usage", new Object[0]);
|
||||
} else {
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 0);
|
||||
BlockPos blockpos = parseBlockPos(parICommandSender, parArrayOfString, 0, false);
|
||||
BlockPos blockpos1 = parseBlockPos(parICommandSender, parArrayOfString, 3, false);
|
||||
BlockPos blockpos2 = parseBlockPos(parICommandSender, parArrayOfString, 6, false);
|
||||
StructureBoundingBox structureboundingbox = new StructureBoundingBox(blockpos, blockpos1);
|
||||
StructureBoundingBox structureboundingbox1 = new StructureBoundingBox(blockpos2,
|
||||
blockpos2.add(structureboundingbox.func_175896_b()));
|
||||
int i = structureboundingbox.getXSize() * structureboundingbox.getYSize() * structureboundingbox.getZSize();
|
||||
if (i > 524288) {
|
||||
throw new CommandException("commands.compare.tooManyBlocks",
|
||||
new Object[] { Integer.valueOf(i), Integer.valueOf(524288) });
|
||||
} else if (structureboundingbox.minY >= 0 && structureboundingbox.maxY < 256
|
||||
&& structureboundingbox1.minY >= 0 && structureboundingbox1.maxY < 256) {
|
||||
World world = parICommandSender.getEntityWorld();
|
||||
if (world.isAreaLoaded(structureboundingbox) && world.isAreaLoaded(structureboundingbox1)) {
|
||||
boolean flag = false;
|
||||
if (parArrayOfString.length > 9 && parArrayOfString[9].equals("masked")) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
BlockPos blockpos3 = new BlockPos(structureboundingbox1.minX - structureboundingbox.minX,
|
||||
structureboundingbox1.minY - structureboundingbox.minY,
|
||||
structureboundingbox1.minZ - structureboundingbox.minZ);
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos1 = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int j = structureboundingbox.minZ; j <= structureboundingbox.maxZ; ++j) {
|
||||
for (int k = structureboundingbox.minY; k <= structureboundingbox.maxY; ++k) {
|
||||
for (int l = structureboundingbox.minX; l <= structureboundingbox.maxX; ++l) {
|
||||
blockpos$mutableblockpos.func_181079_c(l, k, j);
|
||||
blockpos$mutableblockpos1.func_181079_c(l + blockpos3.getX(), k + blockpos3.getY(),
|
||||
j + blockpos3.getZ());
|
||||
boolean flag1 = false;
|
||||
IBlockState iblockstate = world.getBlockState(blockpos$mutableblockpos);
|
||||
if (!flag || iblockstate.getBlock() != Blocks.air) {
|
||||
if (iblockstate == world.getBlockState(blockpos$mutableblockpos1)) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos$mutableblockpos);
|
||||
TileEntity tileentity1 = world.getTileEntity(blockpos$mutableblockpos1);
|
||||
if (tileentity != null && tileentity1 != null) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
tileentity.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.removeTag("x");
|
||||
nbttagcompound.removeTag("y");
|
||||
nbttagcompound.removeTag("z");
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
tileentity1.writeToNBT(nbttagcompound1);
|
||||
nbttagcompound1.removeTag("x");
|
||||
nbttagcompound1.removeTag("y");
|
||||
nbttagcompound1.removeTag("z");
|
||||
if (!nbttagcompound.equals(nbttagcompound1)) {
|
||||
flag1 = true;
|
||||
}
|
||||
} else if (tileentity != null) {
|
||||
flag1 = true;
|
||||
}
|
||||
} else {
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
++i;
|
||||
if (flag1) {
|
||||
throw new CommandException("commands.compare.failed", new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, i);
|
||||
notifyOperators(parICommandSender, this, "commands.compare.success",
|
||||
new Object[] { Integer.valueOf(i) });
|
||||
} else {
|
||||
throw new CommandException("commands.compare.outOfWorld", new Object[0]);
|
||||
}
|
||||
} else {
|
||||
throw new CommandException("commands.compare.outOfWorld", new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length > 0 && astring.length <= 3 ? func_175771_a(astring, 0, blockpos)
|
||||
: (astring.length > 3 && astring.length <= 6 ? func_175771_a(astring, 3, blockpos)
|
||||
: (astring.length > 6 && astring.length <= 9 ? func_175771_a(astring, 6, blockpos)
|
||||
: (astring.length == 10
|
||||
? getListOfStringsMatchingLastWord(astring, new String[] { "masked", "all" })
|
||||
: null)));
|
||||
}
|
||||
}
|
||||
75
src/main/java/net/minecraft/command/CommandDefaultGameMode.java
Executable file
75
src/main/java/net/minecraft/command/CommandDefaultGameMode.java
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandGameMode;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandDefaultGameMode extends CommandGameMode {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "defaultgamemode";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.defaultgamemode.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length <= 0) {
|
||||
throw new WrongUsageException("commands.defaultgamemode.usage", new Object[0]);
|
||||
} else {
|
||||
WorldSettings.GameType worldsettings$gametype = this.getGameModeFromCommand(parICommandSender,
|
||||
parArrayOfString[0]);
|
||||
this.setGameType(worldsettings$gametype);
|
||||
notifyOperators(parICommandSender, this, "commands.defaultgamemode.success", new Object[] {
|
||||
new ChatComponentTranslation("gameMode." + worldsettings$gametype.getName(), new Object[0]) });
|
||||
}
|
||||
}
|
||||
|
||||
protected void setGameType(WorldSettings.GameType parGameType) {
|
||||
MinecraftServer minecraftserver = MinecraftServer.getServer();
|
||||
minecraftserver.setGameType(parGameType);
|
||||
if (minecraftserver.getForceGamemode()) {
|
||||
for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager()
|
||||
.func_181057_v()) {
|
||||
entityplayermp.setGameType(parGameType);
|
||||
entityplayermp.fallDistance = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
91
src/main/java/net/minecraft/command/CommandDifficulty.java
Executable file
91
src/main/java/net/minecraft/command/CommandDifficulty.java
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.NumberInvalidException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandDifficulty extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "difficulty";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.difficulty.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length <= 0) {
|
||||
throw new WrongUsageException("commands.difficulty.usage", new Object[0]);
|
||||
} else {
|
||||
EnumDifficulty enumdifficulty = this.getDifficultyFromCommand(parArrayOfString[0]);
|
||||
MinecraftServer.getServer().setDifficultyForAllWorlds(enumdifficulty);
|
||||
notifyOperators(parICommandSender, this, "commands.difficulty.success", new Object[] {
|
||||
new ChatComponentTranslation(enumdifficulty.getDifficultyResourceKey(), new Object[0]) });
|
||||
}
|
||||
}
|
||||
|
||||
protected EnumDifficulty getDifficultyFromCommand(String parString1) throws NumberInvalidException {
|
||||
return !parString1.equalsIgnoreCase("peaceful") && !parString1.equalsIgnoreCase("p")
|
||||
? (!parString1.equalsIgnoreCase("easy") && !parString1.equalsIgnoreCase("e")
|
||||
? (!parString1.equalsIgnoreCase("normal") && !parString1.equalsIgnoreCase("n")
|
||||
? (!parString1.equalsIgnoreCase("hard") && !parString1.equalsIgnoreCase("h")
|
||||
? EnumDifficulty.getDifficultyEnum(parseInt(parString1, 0, 3))
|
||||
: EnumDifficulty.HARD)
|
||||
: EnumDifficulty.NORMAL)
|
||||
: EnumDifficulty.EASY)
|
||||
: EnumDifficulty.PEACEFUL;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1
|
||||
? getListOfStringsMatchingLastWord(astring, new String[] { "peaceful", "easy", "normal", "hard" })
|
||||
: null;
|
||||
}
|
||||
}
|
||||
162
src/main/java/net/minecraft/command/CommandEffect.java
Executable file
162
src/main/java/net/minecraft/command/CommandEffect.java
Executable file
|
|
@ -0,0 +1,162 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.NumberInvalidException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandEffect extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "effect";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.effect.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 2) {
|
||||
throw new WrongUsageException("commands.effect.usage", new Object[0]);
|
||||
} else {
|
||||
EntityLivingBase entitylivingbase = (EntityLivingBase) getEntity(parICommandSender, parArrayOfString[0],
|
||||
EntityLivingBase.class);
|
||||
if (parArrayOfString[1].equals("clear")) {
|
||||
if (entitylivingbase.getActivePotionEffects().isEmpty()) {
|
||||
throw new CommandException("commands.effect.failure.notActive.all",
|
||||
new Object[] { entitylivingbase.getName() });
|
||||
} else {
|
||||
entitylivingbase.clearActivePotions();
|
||||
notifyOperators(parICommandSender, this, "commands.effect.success.removed.all",
|
||||
new Object[] { entitylivingbase.getName() });
|
||||
}
|
||||
} else {
|
||||
int i;
|
||||
try {
|
||||
i = parseInt(parArrayOfString[1], 1);
|
||||
} catch (NumberInvalidException numberinvalidexception) {
|
||||
Potion potion = Potion.getPotionFromResourceLocation(parArrayOfString[1]);
|
||||
if (potion == null) {
|
||||
throw numberinvalidexception;
|
||||
}
|
||||
|
||||
i = potion.id;
|
||||
}
|
||||
|
||||
int j = 600;
|
||||
int l = 30;
|
||||
int k = 0;
|
||||
if (i >= 0 && i < Potion.potionTypes.length && Potion.potionTypes[i] != null) {
|
||||
Potion potion1 = Potion.potionTypes[i];
|
||||
if (parArrayOfString.length >= 3) {
|
||||
l = parseInt(parArrayOfString[2], 0, 1000000);
|
||||
if (potion1.isInstant()) {
|
||||
j = l;
|
||||
} else {
|
||||
j = l * 20;
|
||||
}
|
||||
} else if (potion1.isInstant()) {
|
||||
j = 1;
|
||||
}
|
||||
|
||||
if (parArrayOfString.length >= 4) {
|
||||
k = parseInt(parArrayOfString[3], 0, 255);
|
||||
}
|
||||
|
||||
boolean flag = true;
|
||||
if (parArrayOfString.length >= 5 && "true".equalsIgnoreCase(parArrayOfString[4])) {
|
||||
flag = false;
|
||||
}
|
||||
|
||||
if (l > 0) {
|
||||
PotionEffect potioneffect = new PotionEffect(i, j, k, false, flag);
|
||||
entitylivingbase.addPotionEffect(potioneffect);
|
||||
notifyOperators(parICommandSender, this, "commands.effect.success",
|
||||
new Object[] {
|
||||
new ChatComponentTranslation(potioneffect.getEffectName(), new Object[0]),
|
||||
Integer.valueOf(i), Integer.valueOf(k), entitylivingbase.getName(),
|
||||
Integer.valueOf(l) });
|
||||
} else if (entitylivingbase.isPotionActive(i)) {
|
||||
entitylivingbase.removePotionEffect(i);
|
||||
notifyOperators(parICommandSender, this, "commands.effect.success.removed",
|
||||
new Object[] { new ChatComponentTranslation(potion1.getName(), new Object[0]),
|
||||
entitylivingbase.getName() });
|
||||
} else {
|
||||
throw new CommandException("commands.effect.failure.notActive",
|
||||
new Object[] { new ChatComponentTranslation(potion1.getName(), new Object[0]),
|
||||
entitylivingbase.getName() });
|
||||
}
|
||||
} else {
|
||||
throw new NumberInvalidException("commands.effect.notFound", new Object[] { Integer.valueOf(i) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1 ? getListOfStringsMatchingLastWord(astring, this.getAllUsernames())
|
||||
: (astring.length == 2 ? getListOfStringsMatchingLastWord(astring, Potion.func_181168_c())
|
||||
: (astring.length == 5
|
||||
? getListOfStringsMatchingLastWord(astring, new String[] { "true", "false" })
|
||||
: null));
|
||||
}
|
||||
|
||||
protected String[] getAllUsernames() {
|
||||
return MinecraftServer.getServer().getAllUsernames();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 0;
|
||||
}
|
||||
}
|
||||
142
src/main/java/net/minecraft/command/CommandEnchant.java
Executable file
142
src/main/java/net/minecraft/command/CommandEnchant.java
Executable file
|
|
@ -0,0 +1,142 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.NumberInvalidException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandEnchant extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "enchant";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.enchant.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 2) {
|
||||
throw new WrongUsageException("commands.enchant.usage", new Object[0]);
|
||||
} else {
|
||||
EntityPlayerMP entityplayermp = getPlayer(parICommandSender, parArrayOfString[0]);
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 0);
|
||||
|
||||
int i;
|
||||
try {
|
||||
i = parseInt(parArrayOfString[1], 0);
|
||||
} catch (NumberInvalidException numberinvalidexception) {
|
||||
Enchantment enchantment = Enchantment.getEnchantmentByLocation(parArrayOfString[1]);
|
||||
if (enchantment == null) {
|
||||
throw numberinvalidexception;
|
||||
}
|
||||
|
||||
i = enchantment.effectId;
|
||||
}
|
||||
|
||||
int j = 1;
|
||||
ItemStack itemstack = entityplayermp.getCurrentEquippedItem();
|
||||
if (itemstack == null) {
|
||||
throw new CommandException("commands.enchant.noItem", new Object[0]);
|
||||
} else {
|
||||
Enchantment enchantment1 = Enchantment.getEnchantmentById(i);
|
||||
if (enchantment1 == null) {
|
||||
throw new NumberInvalidException("commands.enchant.notFound", new Object[] { Integer.valueOf(i) });
|
||||
} else if (!enchantment1.canApply(itemstack)) {
|
||||
throw new CommandException("commands.enchant.cantEnchant", new Object[0]);
|
||||
} else {
|
||||
if (parArrayOfString.length >= 3) {
|
||||
j = parseInt(parArrayOfString[2], enchantment1.getMinLevel(), enchantment1.getMaxLevel());
|
||||
}
|
||||
|
||||
if (itemstack.hasTagCompound()) {
|
||||
NBTTagList nbttaglist = itemstack.getEnchantmentTagList();
|
||||
if (nbttaglist != null) {
|
||||
for (int k = 0; k < nbttaglist.tagCount(); ++k) {
|
||||
short short1 = nbttaglist.getCompoundTagAt(k).getShort("id");
|
||||
if (Enchantment.getEnchantmentById(short1) != null) {
|
||||
Enchantment enchantment2 = Enchantment.getEnchantmentById(short1);
|
||||
if (!enchantment2.canApplyTogether(enchantment1)) {
|
||||
throw new CommandException("commands.enchant.cantCombine",
|
||||
new Object[] { enchantment1.getTranslatedName(j),
|
||||
enchantment2.getTranslatedName(
|
||||
nbttaglist.getCompoundTagAt(k).getShort("lvl")) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
itemstack.addEnchantment(enchantment1, j);
|
||||
notifyOperators(parICommandSender, this, "commands.enchant.success", new Object[0]);
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1 ? getListOfStringsMatchingLastWord(astring, this.getListOfPlayers())
|
||||
: (astring.length == 2 ? getListOfStringsMatchingLastWord(astring, Enchantment.func_181077_c()) : null);
|
||||
}
|
||||
|
||||
protected String[] getListOfPlayers() {
|
||||
return MinecraftServer.getServer().getAllUsernames();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] args, int index) {
|
||||
return index == 0;
|
||||
}
|
||||
}
|
||||
102
src/main/java/net/minecraft/command/CommandEntityData.java
Executable file
102
src/main/java/net/minecraft/command/CommandEntityData.java
Executable file
|
|
@ -0,0 +1,102 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandEntityData extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "entitydata";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.entitydata.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 2) {
|
||||
throw new WrongUsageException("commands.entitydata.usage", new Object[0]);
|
||||
} else {
|
||||
Entity entity = func_175768_b(parICommandSender, parArrayOfString[0]);
|
||||
if (entity instanceof EntityPlayer) {
|
||||
throw new CommandException("commands.entitydata.noPlayers", new Object[] { entity.getDisplayName() });
|
||||
} else {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
entity.writeToNBT(nbttagcompound);
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttagcompound.copy();
|
||||
|
||||
NBTTagCompound nbttagcompound2;
|
||||
try {
|
||||
nbttagcompound2 = JsonToNBT.getTagFromJson(
|
||||
getChatComponentFromNthArg(parICommandSender, parArrayOfString, 1).getUnformattedText());
|
||||
} catch (NBTException nbtexception) {
|
||||
throw new CommandException("commands.entitydata.tagError",
|
||||
new Object[] { nbtexception.getMessage() });
|
||||
}
|
||||
|
||||
nbttagcompound2.removeTag("UUIDMost");
|
||||
nbttagcompound2.removeTag("UUIDLeast");
|
||||
nbttagcompound.merge(nbttagcompound2);
|
||||
if (nbttagcompound.equals(nbttagcompound1)) {
|
||||
throw new CommandException("commands.entitydata.failed",
|
||||
new Object[] { nbttagcompound.toString() });
|
||||
} else {
|
||||
entity.readFromNBT(nbttagcompound);
|
||||
notifyOperators(parICommandSender, this, "commands.entitydata.success",
|
||||
new Object[] { nbttagcompound.toString() });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 0;
|
||||
}
|
||||
}
|
||||
171
src/main/java/net/minecraft/command/CommandExecuteAt.java
Executable file
171
src/main/java/net/minecraft/command/CommandExecuteAt.java
Executable file
|
|
@ -0,0 +1,171 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandManager;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandExecuteAt extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "execute";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.execute.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(final ICommandSender parICommandSender, String[] parArrayOfString)
|
||||
throws CommandException {
|
||||
if (parArrayOfString.length < 5) {
|
||||
throw new WrongUsageException("commands.execute.usage", new Object[0]);
|
||||
} else {
|
||||
final Entity entity = getEntity(parICommandSender, parArrayOfString[0], Entity.class);
|
||||
final double d0 = parseDouble(entity.posX, parArrayOfString[1], false);
|
||||
final double d1 = parseDouble(entity.posY, parArrayOfString[2], false);
|
||||
final double d2 = parseDouble(entity.posZ, parArrayOfString[3], false);
|
||||
final BlockPos blockpos = new BlockPos(d0, d1, d2);
|
||||
byte b0 = 4;
|
||||
if ("detect".equals(parArrayOfString[4]) && parArrayOfString.length > 10) {
|
||||
World world = entity.getEntityWorld();
|
||||
double d3 = parseDouble(d0, parArrayOfString[5], false);
|
||||
double d4 = parseDouble(d1, parArrayOfString[6], false);
|
||||
double d5 = parseDouble(d2, parArrayOfString[7], false);
|
||||
Block block = getBlockByText(parICommandSender, parArrayOfString[8]);
|
||||
int j = parseInt(parArrayOfString[9], -1, 15);
|
||||
BlockPos blockpos1 = new BlockPos(d3, d4, d5);
|
||||
IBlockState iblockstate = world.getBlockState(blockpos1);
|
||||
if (iblockstate.getBlock() != block
|
||||
|| j >= 0 && iblockstate.getBlock().getMetaFromState(iblockstate) != j) {
|
||||
throw new CommandException("commands.execute.failed", new Object[] { "detect", entity.getName() });
|
||||
}
|
||||
|
||||
b0 = 10;
|
||||
}
|
||||
|
||||
String s = buildString(parArrayOfString, b0);
|
||||
ICommandSender icommandsender = new ICommandSender() {
|
||||
public String getName() {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
public IChatComponent getDisplayName() {
|
||||
return entity.getDisplayName();
|
||||
}
|
||||
|
||||
public void addChatMessage(IChatComponent component) {
|
||||
parICommandSender.addChatMessage(component);
|
||||
}
|
||||
|
||||
public boolean canCommandSenderUseCommand(int permLevel, String commandName) {
|
||||
return parICommandSender.canCommandSenderUseCommand(permLevel, commandName);
|
||||
}
|
||||
|
||||
public BlockPos getPosition() {
|
||||
return blockpos;
|
||||
}
|
||||
|
||||
public Vec3 getPositionVector() {
|
||||
return new Vec3(d0, d1, d2);
|
||||
}
|
||||
|
||||
public World getEntityWorld() {
|
||||
return entity.worldObj;
|
||||
}
|
||||
|
||||
public Entity getCommandSenderEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public boolean sendCommandFeedback() {
|
||||
MinecraftServer minecraftserver = MinecraftServer.getServer();
|
||||
return minecraftserver == null
|
||||
|| minecraftserver.worldServers[0].getGameRules().getBoolean("commandBlockOutput");
|
||||
}
|
||||
|
||||
public void setCommandStat(CommandResultStats.Type type, int amount) {
|
||||
entity.setCommandStat(type, amount);
|
||||
}
|
||||
};
|
||||
ICommandManager icommandmanager = MinecraftServer.getServer().getCommandManager();
|
||||
|
||||
try {
|
||||
int i = icommandmanager.executeCommand(icommandsender, s);
|
||||
if (i < 1) {
|
||||
throw new CommandException("commands.execute.allInvocationsFailed", new Object[] { s });
|
||||
}
|
||||
} catch (Throwable var23) {
|
||||
throw new CommandException("commands.execute.failed", new Object[] { s, entity.getName() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length == 1
|
||||
? getListOfStringsMatchingLastWord(astring, MinecraftServer.getServer().getAllUsernames())
|
||||
: (astring.length > 1 && astring.length <= 4 ? func_175771_a(astring, 1, blockpos)
|
||||
: (astring.length > 5 && astring.length <= 8 && "detect".equals(astring[4])
|
||||
? func_175771_a(astring, 5, blockpos)
|
||||
: (astring.length == 9 && "detect".equals(astring[4])
|
||||
? getListOfStringsMatchingLastWord(astring, Block.blockRegistry.getKeys())
|
||||
: null)));
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 0;
|
||||
}
|
||||
}
|
||||
222
src/main/java/net/minecraft/command/CommandFill.java
Executable file
222
src/main/java/net/minecraft/command/CommandFill.java
Executable file
|
|
@ -0,0 +1,222 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandFill extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "fill";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.fill.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 7) {
|
||||
throw new WrongUsageException("commands.fill.usage", new Object[0]);
|
||||
} else {
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 0);
|
||||
BlockPos blockpos = parseBlockPos(parICommandSender, parArrayOfString, 0, false);
|
||||
BlockPos blockpos1 = parseBlockPos(parICommandSender, parArrayOfString, 3, false);
|
||||
Block block = CommandBase.getBlockByText(parICommandSender, parArrayOfString[6]);
|
||||
int i = 0;
|
||||
if (parArrayOfString.length >= 8) {
|
||||
i = parseInt(parArrayOfString[7], 0, 15);
|
||||
}
|
||||
|
||||
BlockPos blockpos2 = new BlockPos(Math.min(blockpos.getX(), blockpos1.getX()),
|
||||
Math.min(blockpos.getY(), blockpos1.getY()), Math.min(blockpos.getZ(), blockpos1.getZ()));
|
||||
BlockPos blockpos3 = new BlockPos(Math.max(blockpos.getX(), blockpos1.getX()),
|
||||
Math.max(blockpos.getY(), blockpos1.getY()), Math.max(blockpos.getZ(), blockpos1.getZ()));
|
||||
int j = (blockpos3.getX() - blockpos2.getX() + 1) * (blockpos3.getY() - blockpos2.getY() + 1)
|
||||
* (blockpos3.getZ() - blockpos2.getZ() + 1);
|
||||
if (j > '\u8000') {
|
||||
throw new CommandException("commands.fill.tooManyBlocks",
|
||||
new Object[] { Integer.valueOf(j), Integer.valueOf('\u8000') });
|
||||
} else if (blockpos2.getY() >= 0 && blockpos3.getY() < 256) {
|
||||
World world = parICommandSender.getEntityWorld();
|
||||
|
||||
for (int k = blockpos2.getZ(); k < blockpos3.getZ() + 16; k += 16) {
|
||||
for (int l = blockpos2.getX(); l < blockpos3.getX() + 16; l += 16) {
|
||||
if (!world.isBlockLoaded(new BlockPos(l, blockpos3.getY() - blockpos2.getY(), k))) {
|
||||
throw new CommandException("commands.fill.outOfWorld", new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
boolean flag = false;
|
||||
if (parArrayOfString.length >= 10 && block.hasTileEntity()) {
|
||||
String s = getChatComponentFromNthArg(parICommandSender, parArrayOfString, 9).getUnformattedText();
|
||||
|
||||
try {
|
||||
nbttagcompound = JsonToNBT.getTagFromJson(s);
|
||||
flag = true;
|
||||
} catch (NBTException nbtexception) {
|
||||
throw new CommandException("commands.fill.tagError",
|
||||
new Object[] { nbtexception.getMessage() });
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
j = 0;
|
||||
|
||||
for (int i1 = blockpos2.getZ(); i1 <= blockpos3.getZ(); ++i1) {
|
||||
for (int j1 = blockpos2.getY(); j1 <= blockpos3.getY(); ++j1) {
|
||||
for (int k1 = blockpos2.getX(); k1 <= blockpos3.getX(); ++k1) {
|
||||
BlockPos blockpos4 = new BlockPos(k1, j1, i1);
|
||||
if (parArrayOfString.length >= 9) {
|
||||
if (!parArrayOfString[8].equals("outline") && !parArrayOfString[8].equals("hollow")) {
|
||||
if (parArrayOfString[8].equals("destroy")) {
|
||||
world.destroyBlock(blockpos4, true);
|
||||
} else if (parArrayOfString[8].equals("keep")) {
|
||||
if (!world.isAirBlock(blockpos4)) {
|
||||
continue;
|
||||
}
|
||||
} else if (parArrayOfString[8].equals("replace") && !block.hasTileEntity()) {
|
||||
if (parArrayOfString.length > 9) {
|
||||
Block block1 = CommandBase.getBlockByText(parICommandSender,
|
||||
parArrayOfString[9]);
|
||||
if (world.getBlockState(blockpos4).getBlock() != block1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (parArrayOfString.length > 10) {
|
||||
int l1 = CommandBase.parseInt(parArrayOfString[10]);
|
||||
IBlockState iblockstate = world.getBlockState(blockpos4);
|
||||
if (iblockstate.getBlock().getMetaFromState(iblockstate) != l1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (k1 != blockpos2.getX() && k1 != blockpos3.getX() && j1 != blockpos2.getY()
|
||||
&& j1 != blockpos3.getY() && i1 != blockpos2.getZ() && i1 != blockpos3.getZ()) {
|
||||
if (parArrayOfString[8].equals("hollow")) {
|
||||
world.setBlockState(blockpos4, Blocks.air.getDefaultState(), 2);
|
||||
arraylist.add(blockpos4);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity tileentity1 = world.getTileEntity(blockpos4);
|
||||
if (tileentity1 != null) {
|
||||
if (tileentity1 instanceof IInventory) {
|
||||
((IInventory) tileentity1).clear();
|
||||
}
|
||||
|
||||
world.setBlockState(blockpos4, Blocks.barrier.getDefaultState(),
|
||||
block == Blocks.barrier ? 2 : 4);
|
||||
}
|
||||
|
||||
IBlockState iblockstate1 = block.getStateFromMeta(i);
|
||||
if (world.setBlockState(blockpos4, iblockstate1, 2)) {
|
||||
arraylist.add(blockpos4);
|
||||
++j;
|
||||
if (flag) {
|
||||
TileEntity tileentity = world.getTileEntity(blockpos4);
|
||||
if (tileentity != null) {
|
||||
nbttagcompound.setInteger("x", blockpos4.getX());
|
||||
nbttagcompound.setInteger("y", blockpos4.getY());
|
||||
nbttagcompound.setInteger("z", blockpos4.getZ());
|
||||
tileentity.readFromNBT(nbttagcompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockPos blockpos5 : (ArrayList<BlockPos>) arraylist) {
|
||||
Block block2 = world.getBlockState(blockpos5).getBlock();
|
||||
world.notifyNeighborsRespectDebug(blockpos5, block2);
|
||||
}
|
||||
|
||||
if (j <= 0) {
|
||||
throw new CommandException("commands.fill.failed", new Object[0]);
|
||||
} else {
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, j);
|
||||
notifyOperators(parICommandSender, this, "commands.fill.success",
|
||||
new Object[] { Integer.valueOf(j) });
|
||||
}
|
||||
} else {
|
||||
throw new CommandException("commands.fill.outOfWorld", new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length > 0
|
||||
&& astring.length <= 3
|
||||
? func_175771_a(astring, 0, blockpos)
|
||||
: (astring.length > 3 && astring.length <= 6 ? func_175771_a(astring, 3, blockpos)
|
||||
: (astring.length == 7
|
||||
? getListOfStringsMatchingLastWord(astring, Block.blockRegistry.getKeys())
|
||||
: (astring.length == 9
|
||||
? getListOfStringsMatchingLastWord(astring,
|
||||
new String[] { "replace", "destroy", "keep", "hollow",
|
||||
"outline" })
|
||||
: (astring.length == 10 && "replace".equals(astring[8])
|
||||
? getListOfStringsMatchingLastWord(astring,
|
||||
Block.blockRegistry.getKeys())
|
||||
: null))));
|
||||
}
|
||||
}
|
||||
139
src/main/java/net/minecraft/command/CommandGameMode.java
Executable file
139
src/main/java/net/minecraft/command/CommandGameMode.java
Executable file
|
|
@ -0,0 +1,139 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.NumberInvalidException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandGameMode extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "gamemode";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.gamemode.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length <= 0) {
|
||||
throw new WrongUsageException("commands.gamemode.usage", new Object[0]);
|
||||
} else {
|
||||
WorldSettings.GameType worldsettings$gametype = this.getGameModeFromCommand(parICommandSender,
|
||||
parArrayOfString[0]);
|
||||
EntityPlayerMP entityplayermp = parArrayOfString.length >= 2
|
||||
? getPlayer(parICommandSender, parArrayOfString[1])
|
||||
: getCommandSenderAsPlayer(parICommandSender);
|
||||
entityplayermp.setGameType(worldsettings$gametype);
|
||||
entityplayermp.fallDistance = 0.0F;
|
||||
if (parICommandSender.getEntityWorld().getGameRules().getBoolean("sendCommandFeedback")) {
|
||||
entityplayermp.addChatMessage(new ChatComponentTranslation("gameMode.changed", new Object[0]));
|
||||
}
|
||||
|
||||
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(
|
||||
"gameMode." + worldsettings$gametype.getName(), new Object[0]);
|
||||
if (entityplayermp != parICommandSender) {
|
||||
notifyOperators(parICommandSender, this, 1, "commands.gamemode.success.other",
|
||||
new Object[] { entityplayermp.getName(), chatcomponenttranslation });
|
||||
} else {
|
||||
notifyOperators(parICommandSender, this, 1, "commands.gamemode.success.self",
|
||||
new Object[] { chatcomponenttranslation });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the Game Mode specified in the command.
|
||||
*/
|
||||
protected WorldSettings.GameType getGameModeFromCommand(ICommandSender parICommandSender, String parString1)
|
||||
throws NumberInvalidException {
|
||||
return !parString1.equalsIgnoreCase(WorldSettings.GameType.SURVIVAL.getName())
|
||||
&& !parString1.equalsIgnoreCase("s")
|
||||
? (!parString1.equalsIgnoreCase(WorldSettings.GameType.CREATIVE.getName())
|
||||
&& !parString1.equalsIgnoreCase("c")
|
||||
? (!parString1.equalsIgnoreCase(WorldSettings.GameType.ADVENTURE.getName())
|
||||
&& !parString1.equalsIgnoreCase("a")
|
||||
? (!parString1.equalsIgnoreCase(
|
||||
WorldSettings.GameType.SPECTATOR.getName())
|
||||
&& !parString1.equalsIgnoreCase("sp")
|
||||
? WorldSettings.getGameTypeById(parseInt(
|
||||
parString1, 0,
|
||||
WorldSettings.GameType.values().length
|
||||
- 2))
|
||||
: WorldSettings.GameType.SPECTATOR)
|
||||
: WorldSettings.GameType.ADVENTURE)
|
||||
: WorldSettings.GameType.CREATIVE)
|
||||
: WorldSettings.GameType.SURVIVAL;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1
|
||||
? getListOfStringsMatchingLastWord(astring,
|
||||
new String[] { "survival", "creative", "adventure", "spectator" })
|
||||
: (astring.length == 2 ? getListOfStringsMatchingLastWord(astring, this.getListOfPlayerUsernames())
|
||||
: null);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Returns String array containing all player usernames in the
|
||||
* server.
|
||||
*/
|
||||
protected String[] getListOfPlayerUsernames() {
|
||||
return MinecraftServer.getServer().getAllUsernames();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 1;
|
||||
}
|
||||
}
|
||||
128
src/main/java/net/minecraft/command/CommandGameRule.java
Executable file
128
src/main/java/net/minecraft/command/CommandGameRule.java
Executable file
|
|
@ -0,0 +1,128 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.play.server.S19PacketEntityStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.GameRules;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandGameRule extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "gamerule";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.gamerule.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
GameRules gamerules = this.getGameRules();
|
||||
String s = parArrayOfString.length > 0 ? parArrayOfString[0] : "";
|
||||
String s1 = parArrayOfString.length > 1 ? buildString(parArrayOfString, 1) : "";
|
||||
switch (parArrayOfString.length) {
|
||||
case 0:
|
||||
parICommandSender.addChatMessage(new ChatComponentText(joinNiceString(gamerules.getRules())));
|
||||
break;
|
||||
case 1:
|
||||
if (!gamerules.hasRule(s)) {
|
||||
throw new CommandException("commands.gamerule.norule", new Object[] { s });
|
||||
}
|
||||
|
||||
String s2 = gamerules.getString(s);
|
||||
parICommandSender.addChatMessage((new ChatComponentText(s)).appendText(" = ").appendText(s2));
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, gamerules.getInt(s));
|
||||
break;
|
||||
default:
|
||||
if (gamerules.areSameType(s, GameRules.ValueType.BOOLEAN_VALUE) && !"true".equals(s1)
|
||||
&& !"false".equals(s1)) {
|
||||
throw new CommandException("commands.generic.boolean.invalid", new Object[] { s1 });
|
||||
}
|
||||
|
||||
gamerules.setOrCreateGameRule(s, s1);
|
||||
func_175773_a(gamerules, s);
|
||||
notifyOperators(parICommandSender, this, "commands.gamerule.success", new Object[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void func_175773_a(GameRules parGameRules, String parString1) {
|
||||
if ("reducedDebugInfo".equals(parString1)) {
|
||||
int i = parGameRules.getBoolean(parString1) ? 22 : 23;
|
||||
|
||||
for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager()
|
||||
.func_181057_v()) {
|
||||
entityplayermp.playerNetServerHandler.sendPacket(new S19PacketEntityStatus(entityplayermp, (byte) i));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
if (astring.length == 1) {
|
||||
return getListOfStringsMatchingLastWord(astring, this.getGameRules().getRules());
|
||||
} else {
|
||||
if (astring.length == 2) {
|
||||
GameRules gamerules = this.getGameRules();
|
||||
if (gamerules.areSameType(astring[0], GameRules.ValueType.BOOLEAN_VALUE)) {
|
||||
return getListOfStringsMatchingLastWord(astring, new String[] { "true", "false" });
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the game rule set this command should be able to
|
||||
* manipulate.
|
||||
*/
|
||||
private GameRules getGameRules() {
|
||||
return MinecraftServer.getServer().worldServerForDimension(0).getGameRules();
|
||||
}
|
||||
}
|
||||
131
src/main/java/net/minecraft/command/CommandGive.java
Executable file
131
src/main/java/net/minecraft/command/CommandGive.java
Executable file
|
|
@ -0,0 +1,131 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandGive extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "give";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.give.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 2) {
|
||||
throw new WrongUsageException("commands.give.usage", new Object[0]);
|
||||
} else {
|
||||
EntityPlayerMP entityplayermp = getPlayer(parICommandSender, parArrayOfString[0]);
|
||||
Item item = getItemByText(parICommandSender, parArrayOfString[1]);
|
||||
int i = parArrayOfString.length >= 3 ? parseInt(parArrayOfString[2], 1, 64) : 1;
|
||||
int j = parArrayOfString.length >= 4 ? parseInt(parArrayOfString[3]) : 0;
|
||||
ItemStack itemstack = new ItemStack(item, i, j);
|
||||
if (parArrayOfString.length >= 5) {
|
||||
String s = getChatComponentFromNthArg(parICommandSender, parArrayOfString, 4).getUnformattedText();
|
||||
|
||||
try {
|
||||
itemstack.setTagCompound(JsonToNBT.getTagFromJson(s));
|
||||
} catch (NBTException nbtexception) {
|
||||
throw new CommandException("commands.give.tagError", new Object[] { nbtexception.getMessage() });
|
||||
}
|
||||
}
|
||||
|
||||
boolean flag = entityplayermp.inventory.addItemStackToInventory(itemstack);
|
||||
if (flag) {
|
||||
entityplayermp.worldObj.playSoundAtEntity(entityplayermp, "random.pop", 0.2F,
|
||||
((entityplayermp.getRNG().nextFloat() - entityplayermp.getRNG().nextFloat()) * 0.7F + 1.0F)
|
||||
* 2.0F);
|
||||
entityplayermp.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
|
||||
if (flag && itemstack.stackSize <= 0) {
|
||||
itemstack.stackSize = 1;
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i);
|
||||
EntityItem entityitem1 = entityplayermp.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
if (entityitem1 != null) {
|
||||
entityitem1.func_174870_v();
|
||||
}
|
||||
} else {
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i - itemstack.stackSize);
|
||||
EntityItem entityitem = entityplayermp.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
if (entityitem != null) {
|
||||
entityitem.setNoPickupDelay();
|
||||
entityitem.setOwner(entityplayermp.getName());
|
||||
}
|
||||
}
|
||||
|
||||
notifyOperators(parICommandSender, this, "commands.give.success",
|
||||
new Object[] { itemstack.getChatComponent(), Integer.valueOf(i), entityplayermp.getName() });
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1 ? getListOfStringsMatchingLastWord(astring, this.getPlayers())
|
||||
: (astring.length == 2 ? getListOfStringsMatchingLastWord(astring, Item.itemRegistry.getKeys()) : null);
|
||||
}
|
||||
|
||||
protected String[] getPlayers() {
|
||||
return MinecraftServer.getServer().getAllUsernames();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 0;
|
||||
}
|
||||
}
|
||||
219
src/main/java/net/minecraft/command/CommandHandler.java
Executable file
219
src/main/java/net/minecraft/command/CommandHandler.java
Executable file
|
|
@ -0,0 +1,219 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandManager;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.PlayerSelector;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandHandler implements ICommandManager {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private final Map<String, ICommand> commandMap = Maps.newHashMap();
|
||||
/**+
|
||||
* The set of ICommand objects currently loaded.
|
||||
*/
|
||||
private final Set<ICommand> commandSet = Sets.newHashSet();
|
||||
|
||||
public int executeCommand(ICommandSender sender, String rawCommand) {
|
||||
rawCommand = rawCommand.trim();
|
||||
if (rawCommand.startsWith("/")) {
|
||||
rawCommand = rawCommand.substring(1);
|
||||
}
|
||||
|
||||
String[] astring = rawCommand.split(" ");
|
||||
String s = astring[0];
|
||||
astring = dropFirstString(astring);
|
||||
ICommand icommand = (ICommand) this.commandMap.get(s);
|
||||
int i = this.getUsernameIndex(icommand, astring);
|
||||
int j = 0;
|
||||
if (icommand == null) {
|
||||
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(
|
||||
"commands.generic.notFound", new Object[0]);
|
||||
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
|
||||
sender.addChatMessage(chatcomponenttranslation);
|
||||
} else if (icommand.canCommandSenderUseCommand(sender)) {
|
||||
if (i > -1) {
|
||||
List list = PlayerSelector.matchEntities(sender, astring[i], Entity.class);
|
||||
String s1 = astring[i];
|
||||
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, list.size());
|
||||
|
||||
for (Entity entity : (List<Entity>) list) {
|
||||
astring[i] = entity.getUniqueID().toString();
|
||||
if (this.tryExecute(sender, astring, icommand, rawCommand)) {
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
||||
astring[i] = s1;
|
||||
} else {
|
||||
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, 1);
|
||||
if (this.tryExecute(sender, astring, icommand, rawCommand)) {
|
||||
++j;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation(
|
||||
"commands.generic.permission", new Object[0]);
|
||||
chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.RED);
|
||||
sender.addChatMessage(chatcomponenttranslation1);
|
||||
}
|
||||
|
||||
sender.setCommandStat(CommandResultStats.Type.SUCCESS_COUNT, j);
|
||||
return j;
|
||||
}
|
||||
|
||||
protected boolean tryExecute(ICommandSender sender, String[] args, ICommand command, String input) {
|
||||
try {
|
||||
command.processCommand(sender, args);
|
||||
return true;
|
||||
} catch (WrongUsageException wrongusageexception) {
|
||||
ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.generic.usage",
|
||||
new Object[] { new ChatComponentTranslation(wrongusageexception.getMessage(),
|
||||
wrongusageexception.getErrorObjects()) });
|
||||
chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.RED);
|
||||
sender.addChatMessage(chatcomponenttranslation2);
|
||||
} catch (CommandException commandexception) {
|
||||
ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation(
|
||||
commandexception.getMessage(), commandexception.getErrorObjects());
|
||||
chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.RED);
|
||||
sender.addChatMessage(chatcomponenttranslation1);
|
||||
} catch (Throwable var9) {
|
||||
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(
|
||||
"commands.generic.exception", new Object[0]);
|
||||
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
|
||||
sender.addChatMessage(chatcomponenttranslation);
|
||||
logger.warn("Couldn\'t process command: \'" + input + "\'");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**+
|
||||
* adds the command and any aliases it has to the internal map
|
||||
* of available commands
|
||||
*/
|
||||
public ICommand registerCommand(ICommand command) {
|
||||
this.commandMap.put(command.getCommandName(), command);
|
||||
this.commandSet.add(command);
|
||||
|
||||
for (String s : command.getCommandAliases()) {
|
||||
ICommand icommand = (ICommand) this.commandMap.get(s);
|
||||
if (icommand == null || !icommand.getCommandName().equals(s)) {
|
||||
this.commandMap.put(s, command);
|
||||
}
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
/**+
|
||||
* creates a new array and sets elements 0..n-2 to be 0..n-1 of
|
||||
* the input (n elements)
|
||||
*/
|
||||
private static String[] dropFirstString(String[] input) {
|
||||
String[] astring = new String[input.length - 1];
|
||||
System.arraycopy(input, 1, astring, 0, input.length - 1);
|
||||
return astring;
|
||||
}
|
||||
|
||||
public List<String> getTabCompletionOptions(ICommandSender sender, String input, BlockPos pos) {
|
||||
String[] astring = input.split(" ", -1);
|
||||
String s = astring[0];
|
||||
if (astring.length == 1) {
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
|
||||
for (Entry entry : this.commandMap.entrySet()) {
|
||||
if (CommandBase.doesStringStartWith(s, (String) entry.getKey())
|
||||
&& ((ICommand) entry.getValue()).canCommandSenderUseCommand(sender)) {
|
||||
arraylist.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist;
|
||||
} else {
|
||||
if (astring.length > 1) {
|
||||
ICommand icommand = (ICommand) this.commandMap.get(s);
|
||||
if (icommand != null && icommand.canCommandSenderUseCommand(sender)) {
|
||||
return icommand.addTabCompletionOptions(sender, dropFirstString(astring), pos);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* returns all commands that the commandSender can use
|
||||
*/
|
||||
public List<ICommand> getPossibleCommands(ICommandSender sender) {
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
|
||||
for (ICommand icommand : this.commandSet) {
|
||||
if (icommand.canCommandSenderUseCommand(sender)) {
|
||||
arraylist.add(icommand);
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist;
|
||||
}
|
||||
|
||||
public Map<String, ICommand> getCommands() {
|
||||
return this.commandMap;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a command's first parameter index containing a valid
|
||||
* username.
|
||||
*/
|
||||
private int getUsernameIndex(ICommand command, String[] args) {
|
||||
if (command == null) {
|
||||
return -1;
|
||||
} else {
|
||||
for (int i = 0; i < args.length; ++i) {
|
||||
if (command.isUsernameIndex(args, i) && PlayerSelector.matchesMultiplePlayers(args[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
147
src/main/java/net/minecraft/command/CommandHelp.java
Executable file
147
src/main/java/net/minecraft/command/CommandHelp.java
Executable file
|
|
@ -0,0 +1,147 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandNotFoundException;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.NumberInvalidException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.event.ClickEvent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandHelp extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "help";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.help.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets a list of aliases for this command
|
||||
*/
|
||||
public List<String> getCommandAliases() {
|
||||
return Arrays.asList(new String[] { "?" });
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
List list = this.getSortedPossibleCommands(parICommandSender);
|
||||
boolean flag = true;
|
||||
int i = (list.size() - 1) / 7;
|
||||
int j = 0;
|
||||
|
||||
try {
|
||||
j = parArrayOfString.length == 0 ? 0 : parseInt(parArrayOfString[0], 1, i + 1) - 1;
|
||||
} catch (NumberInvalidException numberinvalidexception) {
|
||||
Map map = this.getCommands();
|
||||
ICommand icommand = (ICommand) map.get(parArrayOfString[0]);
|
||||
if (icommand != null) {
|
||||
throw new WrongUsageException(icommand.getCommandUsage(parICommandSender), new Object[0]);
|
||||
}
|
||||
|
||||
if (MathHelper.parseIntWithDefault(parArrayOfString[0], -1) != -1) {
|
||||
throw numberinvalidexception;
|
||||
}
|
||||
|
||||
throw new CommandNotFoundException();
|
||||
}
|
||||
|
||||
int k = Math.min((j + 1) * 7, list.size());
|
||||
ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.help.header",
|
||||
new Object[] { Integer.valueOf(j + 1), Integer.valueOf(i + 1) });
|
||||
chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
|
||||
parICommandSender.addChatMessage(chatcomponenttranslation1);
|
||||
|
||||
for (int l = j * 7; l < k; ++l) {
|
||||
ICommand icommand1 = (ICommand) list.get(l);
|
||||
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(
|
||||
icommand1.getCommandUsage(parICommandSender), new Object[0]);
|
||||
chatcomponenttranslation.getChatStyle().setChatClickEvent(
|
||||
new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " "));
|
||||
parICommandSender.addChatMessage(chatcomponenttranslation);
|
||||
}
|
||||
|
||||
if (j == 0 && parICommandSender instanceof EntityPlayer) {
|
||||
ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.help.footer",
|
||||
new Object[0]);
|
||||
chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.GREEN);
|
||||
parICommandSender.addChatMessage(chatcomponenttranslation2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**+
|
||||
* Returns a sorted list of all possible commands for the given
|
||||
* ICommandSender.
|
||||
*/
|
||||
protected List<ICommand> getSortedPossibleCommands(ICommandSender parICommandSender) {
|
||||
List list = MinecraftServer.getServer().getCommandManager().getPossibleCommands(parICommandSender);
|
||||
Collections.sort(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
protected Map<String, ICommand> getCommands() {
|
||||
return MinecraftServer.getServer().getCommandManager().getCommands();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
if (astring.length == 1) {
|
||||
Set set = this.getCommands().keySet();
|
||||
return getListOfStringsMatchingLastWord(astring, (String[]) set.toArray(new String[set.size()]));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
88
src/main/java/net/minecraft/command/CommandKill.java
Executable file
88
src/main/java/net/minecraft/command/CommandKill.java
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandKill extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "kill";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.kill.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length == 0) {
|
||||
EntityPlayerMP entityplayermp = getCommandSenderAsPlayer(parICommandSender);
|
||||
entityplayermp.onKillCommand();
|
||||
notifyOperators(parICommandSender, this, "commands.kill.successful",
|
||||
new Object[] { entityplayermp.getDisplayName() });
|
||||
} else {
|
||||
Entity entity = func_175768_b(parICommandSender, parArrayOfString[0]);
|
||||
entity.onKillCommand();
|
||||
notifyOperators(parICommandSender, this, "commands.kill.successful",
|
||||
new Object[] { entity.getDisplayName() });
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1
|
||||
? getListOfStringsMatchingLastWord(astring, MinecraftServer.getServer().getAllUsernames())
|
||||
: null;
|
||||
}
|
||||
}
|
||||
34
src/main/java/net/minecraft/command/CommandNotFoundException.java
Executable file
34
src/main/java/net/minecraft/command/CommandNotFoundException.java
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandNotFoundException extends CommandException {
|
||||
|
||||
public CommandNotFoundException() {
|
||||
this("commands.generic.notFound", new Object[0]);
|
||||
}
|
||||
|
||||
public CommandNotFoundException(String parString1, Object... parArrayOfObject) {
|
||||
super(parString1, parArrayOfObject);
|
||||
}
|
||||
}
|
||||
139
src/main/java/net/minecraft/command/CommandParticle.java
Executable file
139
src/main/java/net/minecraft/command/CommandParticle.java
Executable file
|
|
@ -0,0 +1,139 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandParticle extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "particle";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.particle.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 8) {
|
||||
throw new WrongUsageException("commands.particle.usage", new Object[0]);
|
||||
} else {
|
||||
boolean flag = false;
|
||||
EnumParticleTypes enumparticletypes = null;
|
||||
|
||||
for (EnumParticleTypes enumparticletypes1 : EnumParticleTypes.values()) {
|
||||
if (enumparticletypes1.hasArguments()) {
|
||||
if (parArrayOfString[0].startsWith(enumparticletypes1.getParticleName())) {
|
||||
flag = true;
|
||||
enumparticletypes = enumparticletypes1;
|
||||
break;
|
||||
}
|
||||
} else if (parArrayOfString[0].equals(enumparticletypes1.getParticleName())) {
|
||||
flag = true;
|
||||
enumparticletypes = enumparticletypes1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
throw new CommandException("commands.particle.notFound", new Object[] { parArrayOfString[0] });
|
||||
} else {
|
||||
String s = parArrayOfString[0];
|
||||
Vec3 vec3 = parICommandSender.getPositionVector();
|
||||
double d6 = (double) ((float) parseDouble(vec3.xCoord, parArrayOfString[1], true));
|
||||
double d0 = (double) ((float) parseDouble(vec3.yCoord, parArrayOfString[2], true));
|
||||
double d1 = (double) ((float) parseDouble(vec3.zCoord, parArrayOfString[3], true));
|
||||
double d2 = (double) ((float) parseDouble(parArrayOfString[4]));
|
||||
double d3 = (double) ((float) parseDouble(parArrayOfString[5]));
|
||||
double d4 = (double) ((float) parseDouble(parArrayOfString[6]));
|
||||
double d5 = (double) ((float) parseDouble(parArrayOfString[7]));
|
||||
int i = 0;
|
||||
if (parArrayOfString.length > 8) {
|
||||
i = parseInt(parArrayOfString[8], 0);
|
||||
}
|
||||
|
||||
boolean flag1 = false;
|
||||
if (parArrayOfString.length > 9 && "force".equals(parArrayOfString[9])) {
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
World world = parICommandSender.getEntityWorld();
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
int[] aint = new int[enumparticletypes.getArgumentCount()];
|
||||
if (enumparticletypes.hasArguments()) {
|
||||
String[] astring = parArrayOfString[0].split("_", 3);
|
||||
|
||||
for (int j = 1; j < astring.length; ++j) {
|
||||
try {
|
||||
aint[j - 1] = Integer.parseInt(astring[j]);
|
||||
} catch (NumberFormatException var29) {
|
||||
throw new CommandException("commands.particle.notFound",
|
||||
new Object[] { parArrayOfString[0] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
worldserver.spawnParticle(enumparticletypes, flag1, d6, d0, d1, i, d2, d3, d4, d5, aint);
|
||||
notifyOperators(parICommandSender, this, "commands.particle.success",
|
||||
new Object[] { s, Integer.valueOf(Math.max(i, 1)) });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length == 1 ? getListOfStringsMatchingLastWord(astring, EnumParticleTypes.getParticleNames())
|
||||
: (astring.length > 1 && astring.length <= 4 ? func_175771_a(astring, 1, blockpos)
|
||||
: (astring.length == 10
|
||||
? getListOfStringsMatchingLastWord(astring, new String[] { "normal", "force" })
|
||||
: null));
|
||||
}
|
||||
}
|
||||
142
src/main/java/net/minecraft/command/CommandPlaySound.java
Executable file
142
src/main/java/net/minecraft/command/CommandPlaySound.java
Executable file
|
|
@ -0,0 +1,142 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.play.server.S29PacketSoundEffect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandPlaySound extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "playsound";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.playsound.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 2) {
|
||||
throw new WrongUsageException(this.getCommandUsage(parICommandSender), new Object[0]);
|
||||
} else {
|
||||
int i = 0;
|
||||
String s = parArrayOfString[i++];
|
||||
EntityPlayerMP entityplayermp = getPlayer(parICommandSender, parArrayOfString[i++]);
|
||||
Vec3 vec3 = parICommandSender.getPositionVector();
|
||||
double d0 = vec3.xCoord;
|
||||
if (parArrayOfString.length > i) {
|
||||
d0 = parseDouble(d0, parArrayOfString[i++], true);
|
||||
}
|
||||
|
||||
double d1 = vec3.yCoord;
|
||||
if (parArrayOfString.length > i) {
|
||||
d1 = parseDouble(d1, parArrayOfString[i++], 0, 0, false);
|
||||
}
|
||||
|
||||
double d2 = vec3.zCoord;
|
||||
if (parArrayOfString.length > i) {
|
||||
d2 = parseDouble(d2, parArrayOfString[i++], true);
|
||||
}
|
||||
|
||||
double d3 = 1.0D;
|
||||
if (parArrayOfString.length > i) {
|
||||
d3 = parseDouble(parArrayOfString[i++], 0.0D, 3.4028234663852886E38D);
|
||||
}
|
||||
|
||||
double d4 = 1.0D;
|
||||
if (parArrayOfString.length > i) {
|
||||
d4 = parseDouble(parArrayOfString[i++], 0.0D, 2.0D);
|
||||
}
|
||||
|
||||
double d5 = 0.0D;
|
||||
if (parArrayOfString.length > i) {
|
||||
d5 = parseDouble(parArrayOfString[i], 0.0D, 1.0D);
|
||||
}
|
||||
|
||||
double d6 = d3 > 1.0D ? d3 * 16.0D : 16.0D;
|
||||
double d7 = entityplayermp.getDistance(d0, d1, d2);
|
||||
if (d7 > d6) {
|
||||
if (d5 <= 0.0D) {
|
||||
throw new CommandException("commands.playsound.playerTooFar",
|
||||
new Object[] { entityplayermp.getName() });
|
||||
}
|
||||
|
||||
double d8 = d0 - entityplayermp.posX;
|
||||
double d9 = d1 - entityplayermp.posY;
|
||||
double d10 = d2 - entityplayermp.posZ;
|
||||
double d11 = Math.sqrt(d8 * d8 + d9 * d9 + d10 * d10);
|
||||
if (d11 > 0.0D) {
|
||||
d0 = entityplayermp.posX + d8 / d11 * 2.0D;
|
||||
d1 = entityplayermp.posY + d9 / d11 * 2.0D;
|
||||
d2 = entityplayermp.posZ + d10 / d11 * 2.0D;
|
||||
}
|
||||
|
||||
d3 = d5;
|
||||
}
|
||||
|
||||
entityplayermp.playerNetServerHandler
|
||||
.sendPacket(new S29PacketSoundEffect(s, d0, d1, d2, (float) d3, (float) d4));
|
||||
notifyOperators(parICommandSender, this, "commands.playsound.success",
|
||||
new Object[] { s, entityplayermp.getName() });
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length == 2
|
||||
? getListOfStringsMatchingLastWord(astring, MinecraftServer.getServer().getAllUsernames())
|
||||
: (astring.length > 2 && astring.length <= 5 ? func_175771_a(astring, 2, blockpos) : null);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 1;
|
||||
}
|
||||
}
|
||||
247
src/main/java/net/minecraft/command/CommandReplaceItem.java
Executable file
247
src/main/java/net/minecraft/command/CommandReplaceItem.java
Executable file
|
|
@ -0,0 +1,247 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.NumberInvalidException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandReplaceItem extends CommandBase {
|
||||
|
||||
private static final Map<String, Integer> SHORTCUTS = Maps.newHashMap();
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "replaceitem";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.replaceitem.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 1) {
|
||||
throw new WrongUsageException("commands.replaceitem.usage", new Object[0]);
|
||||
} else {
|
||||
boolean flag;
|
||||
if (parArrayOfString[0].equals("entity")) {
|
||||
flag = false;
|
||||
} else {
|
||||
if (!parArrayOfString[0].equals("block")) {
|
||||
throw new WrongUsageException("commands.replaceitem.usage", new Object[0]);
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
|
||||
int i;
|
||||
if (flag) {
|
||||
if (parArrayOfString.length < 6) {
|
||||
throw new WrongUsageException("commands.replaceitem.block.usage", new Object[0]);
|
||||
}
|
||||
|
||||
i = 4;
|
||||
} else {
|
||||
if (parArrayOfString.length < 4) {
|
||||
throw new WrongUsageException("commands.replaceitem.entity.usage", new Object[0]);
|
||||
}
|
||||
|
||||
i = 2;
|
||||
}
|
||||
|
||||
int j = this.getSlotForShortcut(parArrayOfString[i++]);
|
||||
|
||||
Item item;
|
||||
try {
|
||||
item = getItemByText(parICommandSender, parArrayOfString[i]);
|
||||
} catch (NumberInvalidException numberinvalidexception) {
|
||||
if (Block.getBlockFromName(parArrayOfString[i]) != Blocks.air) {
|
||||
throw numberinvalidexception;
|
||||
}
|
||||
|
||||
item = null;
|
||||
}
|
||||
|
||||
++i;
|
||||
int k = parArrayOfString.length > i ? parseInt(parArrayOfString[i++], 1, 64) : 1;
|
||||
int l = parArrayOfString.length > i ? parseInt(parArrayOfString[i++]) : 0;
|
||||
ItemStack itemstack = new ItemStack(item, k, l);
|
||||
if (parArrayOfString.length > i) {
|
||||
String s = getChatComponentFromNthArg(parICommandSender, parArrayOfString, i).getUnformattedText();
|
||||
|
||||
try {
|
||||
itemstack.setTagCompound(JsonToNBT.getTagFromJson(s));
|
||||
} catch (NBTException nbtexception) {
|
||||
throw new CommandException("commands.replaceitem.tagError",
|
||||
new Object[] { nbtexception.getMessage() });
|
||||
}
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == null) {
|
||||
itemstack = null;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 0);
|
||||
BlockPos blockpos = parseBlockPos(parICommandSender, parArrayOfString, 1, false);
|
||||
World world = parICommandSender.getEntityWorld();
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity == null || !(tileentity instanceof IInventory)) {
|
||||
throw new CommandException("commands.replaceitem.noContainer",
|
||||
new Object[] { Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()),
|
||||
Integer.valueOf(blockpos.getZ()) });
|
||||
}
|
||||
|
||||
IInventory iinventory = (IInventory) tileentity;
|
||||
if (j >= 0 && j < iinventory.getSizeInventory()) {
|
||||
iinventory.setInventorySlotContents(j, itemstack);
|
||||
}
|
||||
} else {
|
||||
Entity entity = func_175768_b(parICommandSender, parArrayOfString[1]);
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 0);
|
||||
if (entity instanceof EntityPlayer) {
|
||||
((EntityPlayer) entity).inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
|
||||
if (!entity.replaceItemInInventory(j, itemstack)) {
|
||||
throw new CommandException("commands.replaceitem.failed", new Object[] { Integer.valueOf(j),
|
||||
Integer.valueOf(k), itemstack == null ? "Air" : itemstack.getChatComponent() });
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPlayer) {
|
||||
((EntityPlayer) entity).inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, k);
|
||||
notifyOperators(parICommandSender, this, "commands.replaceitem.success", new Object[] { Integer.valueOf(j),
|
||||
Integer.valueOf(k), itemstack == null ? "Air" : itemstack.getChatComponent() });
|
||||
}
|
||||
}
|
||||
|
||||
private int getSlotForShortcut(String shortcut) throws CommandException {
|
||||
if (!SHORTCUTS.containsKey(shortcut)) {
|
||||
throw new CommandException("commands.generic.parameter.invalid", new Object[] { shortcut });
|
||||
} else {
|
||||
return ((Integer) SHORTCUTS.get(shortcut)).intValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length == 1 ? getListOfStringsMatchingLastWord(astring, new String[] { "entity", "block" })
|
||||
: (astring.length == 2 && astring[0].equals("entity")
|
||||
? getListOfStringsMatchingLastWord(astring, this.getUsernames())
|
||||
: (astring.length >= 2 && astring.length <= 4 && astring[0].equals("block")
|
||||
? func_175771_a(astring, 1, blockpos)
|
||||
: ((astring.length != 3 || !astring[0].equals("entity"))
|
||||
&& (astring.length != 5 || !astring[0].equals("block"))
|
||||
? ((astring.length != 4 || !astring[0].equals("entity"))
|
||||
&& (astring.length != 6 || !astring[0].equals("block"))
|
||||
? null
|
||||
: getListOfStringsMatchingLastWord(astring,
|
||||
Item.itemRegistry.getKeys()))
|
||||
: getListOfStringsMatchingLastWord(astring, SHORTCUTS.keySet()))));
|
||||
}
|
||||
|
||||
protected String[] getUsernames() {
|
||||
return MinecraftServer.getServer().getAllUsernames();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] astring, int i) {
|
||||
return astring.length > 0 && astring[0].equals("entity") && i == 1;
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < 54; ++i) {
|
||||
SHORTCUTS.put("slot.container." + i, Integer.valueOf(i));
|
||||
}
|
||||
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
SHORTCUTS.put("slot.hotbar." + j, Integer.valueOf(j));
|
||||
}
|
||||
|
||||
for (int k = 0; k < 27; ++k) {
|
||||
SHORTCUTS.put("slot.inventory." + k, Integer.valueOf(9 + k));
|
||||
}
|
||||
|
||||
for (int l = 0; l < 27; ++l) {
|
||||
SHORTCUTS.put("slot.enderchest." + l, Integer.valueOf(200 + l));
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 8; ++i1) {
|
||||
SHORTCUTS.put("slot.villager." + i1, Integer.valueOf(300 + i1));
|
||||
}
|
||||
|
||||
for (int j1 = 0; j1 < 15; ++j1) {
|
||||
SHORTCUTS.put("slot.horse." + j1, Integer.valueOf(500 + j1));
|
||||
}
|
||||
|
||||
SHORTCUTS.put("slot.weapon", Integer.valueOf(99));
|
||||
SHORTCUTS.put("slot.armor.head", Integer.valueOf(103));
|
||||
SHORTCUTS.put("slot.armor.chest", Integer.valueOf(102));
|
||||
SHORTCUTS.put("slot.armor.legs", Integer.valueOf(101));
|
||||
SHORTCUTS.put("slot.armor.feet", Integer.valueOf(100));
|
||||
SHORTCUTS.put("slot.horse.saddle", Integer.valueOf(400));
|
||||
SHORTCUTS.put("slot.horse.armor", Integer.valueOf(401));
|
||||
SHORTCUTS.put("slot.horse.chest", Integer.valueOf(499));
|
||||
}
|
||||
}
|
||||
240
src/main/java/net/minecraft/command/CommandResultStats.java
Executable file
240
src/main/java/net/minecraft/command/CommandResultStats.java
Executable file
|
|
@ -0,0 +1,240 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.EntityNotFoundException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.scoreboard.Score;
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
import net.minecraft.scoreboard.Scoreboard;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandResultStats {
|
||||
|
||||
/**+
|
||||
* The number of result command result types that are possible.
|
||||
*/
|
||||
private static final int NUM_RESULT_TYPES = CommandResultStats.Type.values().length;
|
||||
private static final String[] STRING_RESULT_TYPES = new String[NUM_RESULT_TYPES];
|
||||
private String[] field_179675_c;
|
||||
private String[] field_179673_d;
|
||||
|
||||
public CommandResultStats() {
|
||||
this.field_179675_c = STRING_RESULT_TYPES;
|
||||
this.field_179673_d = STRING_RESULT_TYPES;
|
||||
}
|
||||
|
||||
public void func_179672_a(final ICommandSender sender, CommandResultStats.Type resultTypeIn, int parInt1) {
|
||||
String s = this.field_179675_c[resultTypeIn.getTypeID()];
|
||||
if (s != null) {
|
||||
ICommandSender icommandsender = new ICommandSender() {
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
public IChatComponent getDisplayName() {
|
||||
return sender.getDisplayName();
|
||||
}
|
||||
|
||||
public void addChatMessage(IChatComponent ichatcomponent) {
|
||||
sender.addChatMessage(ichatcomponent);
|
||||
}
|
||||
|
||||
public boolean canCommandSenderUseCommand(int var1, String var2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public BlockPos getPosition() {
|
||||
return sender.getPosition();
|
||||
}
|
||||
|
||||
public Vec3 getPositionVector() {
|
||||
return sender.getPositionVector();
|
||||
}
|
||||
|
||||
public World getEntityWorld() {
|
||||
return sender.getEntityWorld();
|
||||
}
|
||||
|
||||
public Entity getCommandSenderEntity() {
|
||||
return sender.getCommandSenderEntity();
|
||||
}
|
||||
|
||||
public boolean sendCommandFeedback() {
|
||||
return sender.sendCommandFeedback();
|
||||
}
|
||||
|
||||
public void setCommandStat(CommandResultStats.Type commandresultstats$type, int i) {
|
||||
sender.setCommandStat(commandresultstats$type, i);
|
||||
}
|
||||
};
|
||||
|
||||
String s1;
|
||||
try {
|
||||
s1 = CommandBase.getEntityName(icommandsender, s);
|
||||
} catch (EntityNotFoundException var11) {
|
||||
return;
|
||||
}
|
||||
|
||||
String s2 = this.field_179673_d[resultTypeIn.getTypeID()];
|
||||
if (s2 != null) {
|
||||
Scoreboard scoreboard = sender.getEntityWorld().getScoreboard();
|
||||
ScoreObjective scoreobjective = scoreboard.getObjective(s2);
|
||||
if (scoreobjective != null) {
|
||||
if (scoreboard.entityHasObjective(s1, scoreobjective)) {
|
||||
Score score = scoreboard.getValueFromObjective(s1, scoreobjective);
|
||||
score.setScorePoints(parInt1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readStatsFromNBT(NBTTagCompound tagcompound) {
|
||||
if (tagcompound.hasKey("CommandStats", 10)) {
|
||||
NBTTagCompound nbttagcompound = tagcompound.getCompoundTag("CommandStats");
|
||||
|
||||
for (CommandResultStats.Type commandresultstats$type : CommandResultStats.Type.values()) {
|
||||
String s = commandresultstats$type.getTypeName() + "Name";
|
||||
String s1 = commandresultstats$type.getTypeName() + "Objective";
|
||||
if (nbttagcompound.hasKey(s, 8) && nbttagcompound.hasKey(s1, 8)) {
|
||||
String s2 = nbttagcompound.getString(s);
|
||||
String s3 = nbttagcompound.getString(s1);
|
||||
func_179667_a(this, commandresultstats$type, s2, s3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void writeStatsToNBT(NBTTagCompound tagcompound) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
|
||||
for (CommandResultStats.Type commandresultstats$type : CommandResultStats.Type.values()) {
|
||||
String s = this.field_179675_c[commandresultstats$type.getTypeID()];
|
||||
String s1 = this.field_179673_d[commandresultstats$type.getTypeID()];
|
||||
if (s != null && s1 != null) {
|
||||
nbttagcompound.setString(commandresultstats$type.getTypeName() + "Name", s);
|
||||
nbttagcompound.setString(commandresultstats$type.getTypeName() + "Objective", s1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!nbttagcompound.hasNoTags()) {
|
||||
tagcompound.setTag("CommandStats", nbttagcompound);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void func_179667_a(CommandResultStats stats, CommandResultStats.Type resultType, String parString1,
|
||||
String parString2) {
|
||||
if (parString1 != null && parString1.length() != 0 && parString2 != null && parString2.length() != 0) {
|
||||
if (stats.field_179675_c == STRING_RESULT_TYPES || stats.field_179673_d == STRING_RESULT_TYPES) {
|
||||
stats.field_179675_c = new String[NUM_RESULT_TYPES];
|
||||
stats.field_179673_d = new String[NUM_RESULT_TYPES];
|
||||
}
|
||||
|
||||
stats.field_179675_c[resultType.getTypeID()] = parString1;
|
||||
stats.field_179673_d[resultType.getTypeID()] = parString2;
|
||||
} else {
|
||||
func_179669_a(stats, resultType);
|
||||
}
|
||||
}
|
||||
|
||||
private static void func_179669_a(CommandResultStats resultStatsIn, CommandResultStats.Type resultTypeIn) {
|
||||
if (resultStatsIn.field_179675_c != STRING_RESULT_TYPES
|
||||
&& resultStatsIn.field_179673_d != STRING_RESULT_TYPES) {
|
||||
resultStatsIn.field_179675_c[resultTypeIn.getTypeID()] = null;
|
||||
resultStatsIn.field_179673_d[resultTypeIn.getTypeID()] = null;
|
||||
boolean flag = true;
|
||||
|
||||
for (CommandResultStats.Type commandresultstats$type : CommandResultStats.Type.values()) {
|
||||
if (resultStatsIn.field_179675_c[commandresultstats$type.getTypeID()] != null
|
||||
&& resultStatsIn.field_179673_d[commandresultstats$type.getTypeID()] != null) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
resultStatsIn.field_179675_c = STRING_RESULT_TYPES;
|
||||
resultStatsIn.field_179673_d = STRING_RESULT_TYPES;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void func_179671_a(CommandResultStats resultStatsIn) {
|
||||
for (CommandResultStats.Type commandresultstats$type : CommandResultStats.Type.values()) {
|
||||
func_179667_a(this, commandresultstats$type,
|
||||
resultStatsIn.field_179675_c[commandresultstats$type.getTypeID()],
|
||||
resultStatsIn.field_179673_d[commandresultstats$type.getTypeID()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static enum Type {
|
||||
SUCCESS_COUNT(0, "SuccessCount"), AFFECTED_BLOCKS(1, "AffectedBlocks"),
|
||||
AFFECTED_ENTITIES(2, "AffectedEntities"), AFFECTED_ITEMS(3, "AffectedItems"), QUERY_RESULT(4, "QueryResult");
|
||||
|
||||
final int typeID;
|
||||
final String typeName;
|
||||
|
||||
private Type(int id, String name) {
|
||||
this.typeID = id;
|
||||
this.typeName = name;
|
||||
}
|
||||
|
||||
public int getTypeID() {
|
||||
return this.typeID;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return this.typeName;
|
||||
}
|
||||
|
||||
public static String[] getTypeNames() {
|
||||
String[] astring = new String[values().length];
|
||||
int i = 0;
|
||||
|
||||
for (CommandResultStats.Type commandresultstats$type : values()) {
|
||||
astring[i++] = commandresultstats$type.getTypeName();
|
||||
}
|
||||
|
||||
return astring;
|
||||
}
|
||||
|
||||
public static CommandResultStats.Type getTypeByName(String name) {
|
||||
for (CommandResultStats.Type commandresultstats$type : values()) {
|
||||
if (commandresultstats$type.getTypeName().equals(name)) {
|
||||
return commandresultstats$type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
101
src/main/java/net/minecraft/command/CommandServerKick.java
Executable file
101
src/main/java/net/minecraft/command/CommandServerKick.java
Executable file
|
|
@ -0,0 +1,101 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.PlayerNotFoundException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandServerKick extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "kick";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.kick.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length > 0 && parArrayOfString[0].length() > 1) {
|
||||
EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager()
|
||||
.getPlayerByUsername(parArrayOfString[0]);
|
||||
String s = "Kicked by an operator.";
|
||||
boolean flag = false;
|
||||
if (entityplayermp == null) {
|
||||
throw new PlayerNotFoundException();
|
||||
} else {
|
||||
if (parArrayOfString.length >= 2) {
|
||||
s = getChatComponentFromNthArg(parICommandSender, parArrayOfString, 1).getUnformattedText();
|
||||
if (MinecraftServer.getServer().worldServers[0].getWorldInfo().getGameRulesInstance()
|
||||
.getBoolean("colorCodes")) {
|
||||
s = StringUtils.translateControlCodesAlternate(s);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
|
||||
entityplayermp.playerNetServerHandler.kickPlayerFromServer(s);
|
||||
if (flag) {
|
||||
notifyOperators(parICommandSender, this, "commands.kick.success.reason",
|
||||
new Object[] { entityplayermp.getName(), s });
|
||||
} else {
|
||||
notifyOperators(parICommandSender, this, "commands.kick.success",
|
||||
new Object[] { entityplayermp.getName() });
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
throw new WrongUsageException("commands.kick.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length >= 1
|
||||
? getListOfStringsMatchingLastWord(astring, MinecraftServer.getServer().getAllUsernames())
|
||||
: null;
|
||||
}
|
||||
}
|
||||
65
src/main/java/net/minecraft/command/CommandSetPlayerTimeout.java
Executable file
65
src/main/java/net/minecraft/command/CommandSetPlayerTimeout.java
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandSetPlayerTimeout extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "setidletimeout";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.setidletimeout.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length != 1) {
|
||||
throw new WrongUsageException("commands.setidletimeout.usage", new Object[0]);
|
||||
} else {
|
||||
int i = parseInt(parArrayOfString[0], 0);
|
||||
MinecraftServer.getServer().setPlayerIdleTimeout(i);
|
||||
notifyOperators(parICommandSender, this, "commands.setidletimeout.success",
|
||||
new Object[] { Integer.valueOf(i) });
|
||||
}
|
||||
}
|
||||
}
|
||||
94
src/main/java/net/minecraft/command/CommandSetSpawnpoint.java
Executable file
94
src/main/java/net/minecraft/command/CommandSetSpawnpoint.java
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandSetSpawnpoint extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "spawnpoint";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.spawnpoint.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length > 1 && parArrayOfString.length < 4) {
|
||||
throw new WrongUsageException("commands.spawnpoint.usage", new Object[0]);
|
||||
} else {
|
||||
EntityPlayerMP entityplayermp = parArrayOfString.length > 0
|
||||
? getPlayer(parICommandSender, parArrayOfString[0])
|
||||
: getCommandSenderAsPlayer(parICommandSender);
|
||||
BlockPos blockpos = parArrayOfString.length > 3
|
||||
? parseBlockPos(parICommandSender, parArrayOfString, 1, true)
|
||||
: entityplayermp.getPosition();
|
||||
if (entityplayermp.worldObj != null) {
|
||||
entityplayermp.setSpawnPoint(blockpos, true);
|
||||
notifyOperators(parICommandSender, this, "commands.spawnpoint.success",
|
||||
new Object[] { entityplayermp.getName(), Integer.valueOf(blockpos.getX()),
|
||||
Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ()) });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length == 1
|
||||
? getListOfStringsMatchingLastWord(astring, MinecraftServer.getServer().getAllUsernames())
|
||||
: (astring.length > 1 && astring.length <= 4 ? func_175771_a(astring, 1, blockpos) : null);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 0;
|
||||
}
|
||||
}
|
||||
71
src/main/java/net/minecraft/command/CommandShowSeed.java
Executable file
71
src/main/java/net/minecraft/command/CommandShowSeed.java
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandShowSeed extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Returns true if the given command sender is allowed to use
|
||||
* this command.
|
||||
*/
|
||||
public boolean canCommandSenderUseCommand(ICommandSender icommandsender) {
|
||||
return MinecraftServer.getServer().isSinglePlayer() || super.canCommandSenderUseCommand(icommandsender);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "seed";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.seed.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
Object object = parICommandSender instanceof EntityPlayer ? ((EntityPlayer) parICommandSender).worldObj
|
||||
: MinecraftServer.getServer().worldServerForDimension(0);
|
||||
parICommandSender.addChatMessage(new ChatComponentTranslation("commands.seed.success",
|
||||
new Object[] { Long.valueOf(((World) object).getSeed()) }));
|
||||
}
|
||||
}
|
||||
381
src/main/java/net/minecraft/command/CommandSpreadPlayers.java
Executable file
381
src/main/java/net/minecraft/command/CommandSpreadPlayers.java
Executable file
|
|
@ -0,0 +1,381 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||
import net.lax1dude.eaglercraft.v1_8.HString;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.EntityNotFoundException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.PlayerNotFoundException;
|
||||
import net.minecraft.command.PlayerSelector;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.scoreboard.Team;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandSpreadPlayers extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "spreadplayers";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.spreadplayers.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 6) {
|
||||
throw new WrongUsageException("commands.spreadplayers.usage", new Object[0]);
|
||||
} else {
|
||||
int i = 0;
|
||||
BlockPos blockpos = parICommandSender.getPosition();
|
||||
double d0 = parseDouble((double) blockpos.getX(), parArrayOfString[i++], true);
|
||||
double d1 = parseDouble((double) blockpos.getZ(), parArrayOfString[i++], true);
|
||||
double d2 = parseDouble(parArrayOfString[i++], 0.0D);
|
||||
double d3 = parseDouble(parArrayOfString[i++], d2 + 1.0D);
|
||||
boolean flag = parseBoolean(parArrayOfString[i++]);
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
|
||||
while (i < parArrayOfString.length) {
|
||||
String s = parArrayOfString[i++];
|
||||
if (PlayerSelector.hasArguments(s)) {
|
||||
List list = PlayerSelector.matchEntities(parICommandSender, s, Entity.class);
|
||||
if (list.size() == 0) {
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
|
||||
arraylist.addAll(list);
|
||||
} else {
|
||||
EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager()
|
||||
.getPlayerByUsername(s);
|
||||
if (entityplayermp == null) {
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
arraylist.add(entityplayermp);
|
||||
}
|
||||
}
|
||||
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, arraylist.size());
|
||||
if (arraylist.isEmpty()) {
|
||||
throw new EntityNotFoundException();
|
||||
} else {
|
||||
parICommandSender.addChatMessage(
|
||||
new ChatComponentTranslation("commands.spreadplayers.spreading." + (flag ? "teams" : "players"),
|
||||
new Object[] { Integer.valueOf(arraylist.size()), Double.valueOf(d3),
|
||||
Double.valueOf(d0), Double.valueOf(d1), Double.valueOf(d2) }));
|
||||
this.func_110669_a(parICommandSender, arraylist, new CommandSpreadPlayers.Position(d0, d1), d2, d3,
|
||||
((Entity) arraylist.get(0)).worldObj, flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void func_110669_a(ICommandSender worldIn, List<Entity> parList, CommandSpreadPlayers.Position parPosition,
|
||||
double parDouble1, double parDouble2, World parWorld, boolean parFlag) throws CommandException {
|
||||
EaglercraftRandom random = new EaglercraftRandom();
|
||||
double d0 = parPosition.field_111101_a - parDouble2;
|
||||
double d1 = parPosition.field_111100_b - parDouble2;
|
||||
double d2 = parPosition.field_111101_a + parDouble2;
|
||||
double d3 = parPosition.field_111100_b + parDouble2;
|
||||
CommandSpreadPlayers.Position[] acommandspreadplayers$position = this.func_110670_a(random,
|
||||
parFlag ? this.func_110667_a(parList) : parList.size(), d0, d1, d2, d3);
|
||||
int i = this.func_110668_a(parPosition, parDouble1, parWorld, random, d0, d1, d2, d3,
|
||||
acommandspreadplayers$position, parFlag);
|
||||
double d4 = this.func_110671_a(parList, parWorld, acommandspreadplayers$position, parFlag);
|
||||
notifyOperators(worldIn, this, "commands.spreadplayers.success." + (parFlag ? "teams" : "players"),
|
||||
new Object[] { Integer.valueOf(acommandspreadplayers$position.length),
|
||||
Double.valueOf(parPosition.field_111101_a), Double.valueOf(parPosition.field_111100_b) });
|
||||
if (acommandspreadplayers$position.length > 1) {
|
||||
worldIn.addChatMessage(new ChatComponentTranslation(
|
||||
"commands.spreadplayers.info." + (parFlag ? "teams" : "players"),
|
||||
new Object[] { HString.format("%.2f", new Object[] { Double.valueOf(d4) }), Integer.valueOf(i) }));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int func_110667_a(List<Entity> parList) {
|
||||
HashSet hashset = Sets.newHashSet();
|
||||
|
||||
for (Entity entity : parList) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
hashset.add(((EntityPlayer) entity).getTeam());
|
||||
} else {
|
||||
hashset.add((Object) null);
|
||||
}
|
||||
}
|
||||
|
||||
return hashset.size();
|
||||
}
|
||||
|
||||
private int func_110668_a(CommandSpreadPlayers.Position worldIn, double parDouble1, World parWorld,
|
||||
EaglercraftRandom parRandom, double parDouble2, double parDouble3, double parDouble4, double parDouble5,
|
||||
CommandSpreadPlayers.Position[] parArrayOfPosition, boolean parFlag) throws CommandException {
|
||||
boolean flag = true;
|
||||
double d0 = 3.4028234663852886E38D;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 10000 && flag; ++i) {
|
||||
flag = false;
|
||||
d0 = 3.4028234663852886E38D;
|
||||
|
||||
for (int j = 0; j < parArrayOfPosition.length; ++j) {
|
||||
CommandSpreadPlayers.Position commandspreadplayers$position = parArrayOfPosition[j];
|
||||
int k = 0;
|
||||
CommandSpreadPlayers.Position commandspreadplayers$position1 = new CommandSpreadPlayers.Position();
|
||||
|
||||
for (int l = 0; l < parArrayOfPosition.length; ++l) {
|
||||
if (j != l) {
|
||||
CommandSpreadPlayers.Position commandspreadplayers$position2 = parArrayOfPosition[l];
|
||||
double d1 = commandspreadplayers$position.func_111099_a(commandspreadplayers$position2);
|
||||
d0 = Math.min(d1, d0);
|
||||
if (d1 < parDouble1) {
|
||||
++k;
|
||||
commandspreadplayers$position1.field_111101_a += commandspreadplayers$position2.field_111101_a
|
||||
- commandspreadplayers$position.field_111101_a;
|
||||
commandspreadplayers$position1.field_111100_b += commandspreadplayers$position2.field_111100_b
|
||||
- commandspreadplayers$position.field_111100_b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (k > 0) {
|
||||
commandspreadplayers$position1.field_111101_a /= (double) k;
|
||||
commandspreadplayers$position1.field_111100_b /= (double) k;
|
||||
double d2 = (double) commandspreadplayers$position1.func_111096_b();
|
||||
if (d2 > 0.0D) {
|
||||
commandspreadplayers$position1.func_111095_a();
|
||||
commandspreadplayers$position.func_111094_b(commandspreadplayers$position1);
|
||||
} else {
|
||||
commandspreadplayers$position.func_111097_a(parRandom, parDouble2, parDouble3, parDouble4,
|
||||
parDouble5);
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (commandspreadplayers$position.func_111093_a(parDouble2, parDouble3, parDouble4, parDouble5)) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
for (CommandSpreadPlayers.Position commandspreadplayers$position3 : parArrayOfPosition) {
|
||||
if (!commandspreadplayers$position3.func_111098_b(parWorld)) {
|
||||
commandspreadplayers$position3.func_111097_a(parRandom, parDouble2, parDouble3, parDouble4,
|
||||
parDouble5);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= 10000) {
|
||||
throw new CommandException("commands.spreadplayers.failure." + (parFlag ? "teams" : "players"),
|
||||
new Object[] { Integer.valueOf(parArrayOfPosition.length), Double.valueOf(worldIn.field_111101_a),
|
||||
Double.valueOf(worldIn.field_111100_b),
|
||||
HString.format("%.2f", new Object[] { Double.valueOf(d0) }) });
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
private double func_110671_a(List<Entity> worldIn, World parWorld,
|
||||
CommandSpreadPlayers.Position[] parArrayOfPosition, boolean parFlag) {
|
||||
double d0 = 0.0D;
|
||||
int i = 0;
|
||||
HashMap hashmap = Maps.newHashMap();
|
||||
|
||||
for (int j = 0; j < worldIn.size(); ++j) {
|
||||
Entity entity = (Entity) worldIn.get(j);
|
||||
CommandSpreadPlayers.Position commandspreadplayers$position;
|
||||
if (parFlag) {
|
||||
Team team = entity instanceof EntityPlayer ? ((EntityPlayer) entity).getTeam() : null;
|
||||
if (!hashmap.containsKey(team)) {
|
||||
hashmap.put(team, parArrayOfPosition[i++]);
|
||||
}
|
||||
|
||||
commandspreadplayers$position = (CommandSpreadPlayers.Position) hashmap.get(team);
|
||||
} else {
|
||||
commandspreadplayers$position = parArrayOfPosition[i++];
|
||||
}
|
||||
|
||||
entity.setPositionAndUpdate(
|
||||
(double) ((float) MathHelper.floor_double(commandspreadplayers$position.field_111101_a) + 0.5F),
|
||||
(double) commandspreadplayers$position.func_111092_a(parWorld),
|
||||
(double) MathHelper.floor_double(commandspreadplayers$position.field_111100_b) + 0.5D);
|
||||
double d2 = Double.MAX_VALUE;
|
||||
|
||||
for (int k = 0; k < parArrayOfPosition.length; ++k) {
|
||||
if (commandspreadplayers$position != parArrayOfPosition[k]) {
|
||||
double d1 = commandspreadplayers$position.func_111099_a(parArrayOfPosition[k]);
|
||||
d2 = Math.min(d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
d0 += d2;
|
||||
}
|
||||
|
||||
d0 = d0 / (double) worldIn.size();
|
||||
return d0;
|
||||
}
|
||||
|
||||
private CommandSpreadPlayers.Position[] func_110670_a(EaglercraftRandom parRandom, int parInt1, double parDouble1,
|
||||
double parDouble2, double parDouble3, double parDouble4) {
|
||||
CommandSpreadPlayers.Position[] acommandspreadplayers$position = new CommandSpreadPlayers.Position[parInt1];
|
||||
|
||||
for (int i = 0; i < acommandspreadplayers$position.length; ++i) {
|
||||
CommandSpreadPlayers.Position commandspreadplayers$position = new CommandSpreadPlayers.Position();
|
||||
commandspreadplayers$position.func_111097_a(parRandom, parDouble1, parDouble2, parDouble3, parDouble4);
|
||||
acommandspreadplayers$position[i] = commandspreadplayers$position;
|
||||
}
|
||||
|
||||
return acommandspreadplayers$position;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length >= 1 && astring.length <= 2 ? func_181043_b(astring, 0, blockpos) : null;
|
||||
}
|
||||
|
||||
static class Position {
|
||||
double field_111101_a;
|
||||
double field_111100_b;
|
||||
|
||||
Position() {
|
||||
}
|
||||
|
||||
Position(double parDouble1, double parDouble2) {
|
||||
this.field_111101_a = parDouble1;
|
||||
this.field_111100_b = parDouble2;
|
||||
}
|
||||
|
||||
double func_111099_a(CommandSpreadPlayers.Position parPosition) {
|
||||
double d0 = this.field_111101_a - parPosition.field_111101_a;
|
||||
double d1 = this.field_111100_b - parPosition.field_111100_b;
|
||||
return Math.sqrt(d0 * d0 + d1 * d1);
|
||||
}
|
||||
|
||||
void func_111095_a() {
|
||||
double d0 = (double) this.func_111096_b();
|
||||
this.field_111101_a /= d0;
|
||||
this.field_111100_b /= d0;
|
||||
}
|
||||
|
||||
float func_111096_b() {
|
||||
return MathHelper
|
||||
.sqrt_double(this.field_111101_a * this.field_111101_a + this.field_111100_b * this.field_111100_b);
|
||||
}
|
||||
|
||||
public void func_111094_b(CommandSpreadPlayers.Position parPosition) {
|
||||
this.field_111101_a -= parPosition.field_111101_a;
|
||||
this.field_111100_b -= parPosition.field_111100_b;
|
||||
}
|
||||
|
||||
public boolean func_111093_a(double parDouble1, double parDouble2, double parDouble3, double parDouble4) {
|
||||
boolean flag = false;
|
||||
if (this.field_111101_a < parDouble1) {
|
||||
this.field_111101_a = parDouble1;
|
||||
flag = true;
|
||||
} else if (this.field_111101_a > parDouble3) {
|
||||
this.field_111101_a = parDouble3;
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (this.field_111100_b < parDouble2) {
|
||||
this.field_111100_b = parDouble2;
|
||||
flag = true;
|
||||
} else if (this.field_111100_b > parDouble4) {
|
||||
this.field_111100_b = parDouble4;
|
||||
flag = true;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public int func_111092_a(World worldIn) {
|
||||
BlockPos blockpos = new BlockPos(this.field_111101_a, 256.0D, this.field_111100_b);
|
||||
|
||||
while (blockpos.getY() > 0) {
|
||||
blockpos = blockpos.down();
|
||||
if (worldIn.getBlockState(blockpos).getBlock().getMaterial() != Material.air) {
|
||||
return blockpos.getY() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 257;
|
||||
}
|
||||
|
||||
public boolean func_111098_b(World worldIn) {
|
||||
BlockPos blockpos = new BlockPos(this.field_111101_a, 256.0D, this.field_111100_b);
|
||||
|
||||
while (blockpos.getY() > 0) {
|
||||
blockpos = blockpos.down();
|
||||
Material material = worldIn.getBlockState(blockpos).getBlock().getMaterial();
|
||||
if (material != Material.air) {
|
||||
return !material.isLiquid() && material != Material.fire;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void func_111097_a(EaglercraftRandom parRandom, double parDouble1, double parDouble2, double parDouble3,
|
||||
double parDouble4) {
|
||||
this.field_111101_a = MathHelper.getRandomDoubleInRange(parRandom, parDouble1, parDouble3);
|
||||
this.field_111100_b = MathHelper.getRandomDoubleInRange(parRandom, parDouble2, parDouble4);
|
||||
}
|
||||
}
|
||||
}
|
||||
230
src/main/java/net/minecraft/command/CommandStats.java
Executable file
230
src/main/java/net/minecraft/command/CommandStats.java
Executable file
|
|
@ -0,0 +1,230 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityCommandBlock;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandStats extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "stats";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.stats.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 1) {
|
||||
throw new WrongUsageException("commands.stats.usage", new Object[0]);
|
||||
} else {
|
||||
boolean flag;
|
||||
if (parArrayOfString[0].equals("entity")) {
|
||||
flag = false;
|
||||
} else {
|
||||
if (!parArrayOfString[0].equals("block")) {
|
||||
throw new WrongUsageException("commands.stats.usage", new Object[0]);
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
|
||||
int i;
|
||||
if (flag) {
|
||||
if (parArrayOfString.length < 5) {
|
||||
throw new WrongUsageException("commands.stats.block.usage", new Object[0]);
|
||||
}
|
||||
|
||||
i = 4;
|
||||
} else {
|
||||
if (parArrayOfString.length < 3) {
|
||||
throw new WrongUsageException("commands.stats.entity.usage", new Object[0]);
|
||||
}
|
||||
|
||||
i = 2;
|
||||
}
|
||||
|
||||
String s = parArrayOfString[i++];
|
||||
if ("set".equals(s)) {
|
||||
if (parArrayOfString.length < i + 3) {
|
||||
if (i == 5) {
|
||||
throw new WrongUsageException("commands.stats.block.set.usage", new Object[0]);
|
||||
}
|
||||
|
||||
throw new WrongUsageException("commands.stats.entity.set.usage", new Object[0]);
|
||||
}
|
||||
} else {
|
||||
if (!"clear".equals(s)) {
|
||||
throw new WrongUsageException("commands.stats.usage", new Object[0]);
|
||||
}
|
||||
|
||||
if (parArrayOfString.length < i + 1) {
|
||||
if (i == 5) {
|
||||
throw new WrongUsageException("commands.stats.block.clear.usage", new Object[0]);
|
||||
}
|
||||
|
||||
throw new WrongUsageException("commands.stats.entity.clear.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
CommandResultStats.Type commandresultstats$type = CommandResultStats.Type
|
||||
.getTypeByName(parArrayOfString[i++]);
|
||||
if (commandresultstats$type == null) {
|
||||
throw new CommandException("commands.stats.failed", new Object[0]);
|
||||
} else {
|
||||
World world = parICommandSender.getEntityWorld();
|
||||
CommandResultStats commandresultstats;
|
||||
if (flag) {
|
||||
BlockPos blockpos = parseBlockPos(parICommandSender, parArrayOfString, 1, false);
|
||||
TileEntity tileentity = world.getTileEntity(blockpos);
|
||||
if (tileentity == null) {
|
||||
throw new CommandException("commands.stats.noCompatibleBlock",
|
||||
new Object[] { Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()),
|
||||
Integer.valueOf(blockpos.getZ()) });
|
||||
}
|
||||
|
||||
if (tileentity instanceof TileEntityCommandBlock) {
|
||||
commandresultstats = ((TileEntityCommandBlock) tileentity).getCommandResultStats();
|
||||
} else {
|
||||
if (!(tileentity instanceof TileEntitySign)) {
|
||||
throw new CommandException("commands.stats.noCompatibleBlock",
|
||||
new Object[] { Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()),
|
||||
Integer.valueOf(blockpos.getZ()) });
|
||||
}
|
||||
|
||||
commandresultstats = ((TileEntitySign) tileentity).getStats();
|
||||
}
|
||||
} else {
|
||||
Entity entity = func_175768_b(parICommandSender, parArrayOfString[1]);
|
||||
commandresultstats = entity.getCommandStats();
|
||||
}
|
||||
|
||||
if ("set".equals(s)) {
|
||||
String s1 = parArrayOfString[i++];
|
||||
String s2 = parArrayOfString[i];
|
||||
if (s1.length() == 0 || s2.length() == 0) {
|
||||
throw new CommandException("commands.stats.failed", new Object[0]);
|
||||
}
|
||||
|
||||
CommandResultStats.func_179667_a(commandresultstats, commandresultstats$type, s1, s2);
|
||||
notifyOperators(parICommandSender, this, "commands.stats.success",
|
||||
new Object[] { commandresultstats$type.getTypeName(), s2, s1 });
|
||||
} else if ("clear".equals(s)) {
|
||||
CommandResultStats.func_179667_a(commandresultstats, commandresultstats$type, (String) null,
|
||||
(String) null);
|
||||
notifyOperators(parICommandSender, this, "commands.stats.cleared",
|
||||
new Object[] { commandresultstats$type.getTypeName() });
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
BlockPos blockpos1 = parseBlockPos(parICommandSender, parArrayOfString, 1, false);
|
||||
TileEntity tileentity1 = world.getTileEntity(blockpos1);
|
||||
tileentity1.markDirty();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length == 1 ? getListOfStringsMatchingLastWord(astring, new String[] { "entity", "block" })
|
||||
: (astring.length == 2 && astring[0].equals("entity")
|
||||
? getListOfStringsMatchingLastWord(astring, this.func_175776_d())
|
||||
: (astring.length >= 2 && astring.length <= 4 && astring[0].equals("block")
|
||||
? func_175771_a(astring, 1, blockpos)
|
||||
: ((astring.length != 3 || !astring[0].equals("entity"))
|
||||
&& (astring.length != 5 || !astring[0].equals("block"))
|
||||
? ((astring.length != 4 || !astring[0].equals("entity"))
|
||||
&& (astring.length != 6 || !astring[0].equals("block"))
|
||||
? ((astring.length != 6 || !astring[0].equals("entity"))
|
||||
&& (astring.length != 8
|
||||
|| !astring[0].equals("block"))
|
||||
? null
|
||||
: getListOfStringsMatchingLastWord(
|
||||
astring,
|
||||
this.func_175777_e()))
|
||||
: getListOfStringsMatchingLastWord(astring,
|
||||
CommandResultStats.Type.getTypeNames()))
|
||||
: getListOfStringsMatchingLastWord(astring,
|
||||
new String[] { "set", "clear" }))));
|
||||
}
|
||||
|
||||
protected String[] func_175776_d() {
|
||||
return MinecraftServer.getServer().getAllUsernames();
|
||||
}
|
||||
|
||||
protected List<String> func_175777_e() {
|
||||
Collection collection = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard()
|
||||
.getScoreObjectives();
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
|
||||
for (ScoreObjective scoreobjective : (Collection<ScoreObjective>) collection) {
|
||||
if (!scoreobjective.getCriteria().isReadOnly()) {
|
||||
arraylist.add(scoreobjective.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] astring, int i) {
|
||||
return astring.length > 0 && astring[0].equals("entity") && i == 1;
|
||||
}
|
||||
}
|
||||
137
src/main/java/net/minecraft/command/CommandTime.java
Executable file
137
src/main/java/net/minecraft/command/CommandTime.java
Executable file
|
|
@ -0,0 +1,137 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandTime extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "time";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.time.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length > 1) {
|
||||
if (parArrayOfString[0].equals("set")) {
|
||||
int l;
|
||||
if (parArrayOfString[1].equals("day")) {
|
||||
l = 1000;
|
||||
} else if (parArrayOfString[1].equals("night")) {
|
||||
l = 13000;
|
||||
} else {
|
||||
l = parseInt(parArrayOfString[1], 0);
|
||||
}
|
||||
|
||||
this.setTime(parICommandSender, l);
|
||||
notifyOperators(parICommandSender, this, "commands.time.set", new Object[] { Integer.valueOf(l) });
|
||||
return;
|
||||
}
|
||||
|
||||
if (parArrayOfString[0].equals("add")) {
|
||||
int k = parseInt(parArrayOfString[1], 0);
|
||||
this.addTime(parICommandSender, k);
|
||||
notifyOperators(parICommandSender, this, "commands.time.added", new Object[] { Integer.valueOf(k) });
|
||||
return;
|
||||
}
|
||||
|
||||
if (parArrayOfString[0].equals("query")) {
|
||||
if (parArrayOfString[1].equals("daytime")) {
|
||||
int j = (int) (parICommandSender.getEntityWorld().getWorldTime() % 2147483647L);
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, j);
|
||||
notifyOperators(parICommandSender, this, "commands.time.query",
|
||||
new Object[] { Integer.valueOf(j) });
|
||||
return;
|
||||
}
|
||||
|
||||
if (parArrayOfString[1].equals("gametime")) {
|
||||
int i = (int) (parICommandSender.getEntityWorld().getTotalWorldTime() % 2147483647L);
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, i);
|
||||
notifyOperators(parICommandSender, this, "commands.time.query",
|
||||
new Object[] { Integer.valueOf(i) });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new WrongUsageException("commands.time.usage", new Object[0]);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1 ? getListOfStringsMatchingLastWord(astring, new String[] { "set", "add", "query" })
|
||||
: (astring.length == 2 && astring[0].equals("set")
|
||||
? getListOfStringsMatchingLastWord(astring, new String[] { "day", "night" })
|
||||
: (astring.length == 2 && astring[0].equals("query")
|
||||
? getListOfStringsMatchingLastWord(astring, new String[] { "daytime", "gametime" })
|
||||
: null));
|
||||
}
|
||||
|
||||
/**+
|
||||
* Set the time in the server object.
|
||||
*/
|
||||
protected void setTime(ICommandSender parICommandSender, int parInt1) {
|
||||
for (int i = 0; i < MinecraftServer.getServer().worldServers.length; ++i) {
|
||||
MinecraftServer.getServer().worldServers[i].setWorldTime((long) parInt1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**+
|
||||
* Adds (or removes) time in the server object.
|
||||
*/
|
||||
protected void addTime(ICommandSender parICommandSender, int parInt1) {
|
||||
for (int i = 0; i < MinecraftServer.getServer().worldServers.length; ++i) {
|
||||
WorldServer worldserver = MinecraftServer.getServer().worldServers[i];
|
||||
worldserver.setWorldTime(worldserver.getWorldTime() + (long) parInt1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
144
src/main/java/net/minecraft/command/CommandTitle.java
Executable file
144
src/main/java/net/minecraft/command/CommandTitle.java
Executable file
|
|
@ -0,0 +1,144 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.SyntaxErrorException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.play.server.S45PacketTitle;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentProcessor;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.lax1dude.eaglercraft.v1_8.ExceptionUtils;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandTitle extends CommandBase {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "title";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.title.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 2) {
|
||||
throw new WrongUsageException("commands.title.usage", new Object[0]);
|
||||
} else {
|
||||
if (parArrayOfString.length < 3) {
|
||||
if ("title".equals(parArrayOfString[1]) || "subtitle".equals(parArrayOfString[1])) {
|
||||
throw new WrongUsageException("commands.title.usage.title", new Object[0]);
|
||||
}
|
||||
|
||||
if ("times".equals(parArrayOfString[1])) {
|
||||
throw new WrongUsageException("commands.title.usage.times", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
EntityPlayerMP entityplayermp = getPlayer(parICommandSender, parArrayOfString[0]);
|
||||
S45PacketTitle.Type s45packettitle$type = S45PacketTitle.Type.byName(parArrayOfString[1]);
|
||||
if (s45packettitle$type != S45PacketTitle.Type.CLEAR && s45packettitle$type != S45PacketTitle.Type.RESET) {
|
||||
if (s45packettitle$type == S45PacketTitle.Type.TIMES) {
|
||||
if (parArrayOfString.length != 5) {
|
||||
throw new WrongUsageException("commands.title.usage", new Object[0]);
|
||||
} else {
|
||||
int i = parseInt(parArrayOfString[2]);
|
||||
int j = parseInt(parArrayOfString[3]);
|
||||
int k = parseInt(parArrayOfString[4]);
|
||||
S45PacketTitle s45packettitle2 = new S45PacketTitle(i, j, k);
|
||||
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle2);
|
||||
notifyOperators(parICommandSender, this, "commands.title.success", new Object[0]);
|
||||
}
|
||||
} else if (parArrayOfString.length < 3) {
|
||||
throw new WrongUsageException("commands.title.usage", new Object[0]);
|
||||
} else {
|
||||
String s = buildString(parArrayOfString, 2);
|
||||
|
||||
IChatComponent ichatcomponent;
|
||||
try {
|
||||
ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
|
||||
} catch (JSONException jsonparseexception) {
|
||||
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
|
||||
throw new SyntaxErrorException("commands.tellraw.jsonException",
|
||||
new Object[] { throwable == null ? "" : throwable.getMessage() });
|
||||
}
|
||||
|
||||
S45PacketTitle s45packettitle1 = new S45PacketTitle(s45packettitle$type,
|
||||
ChatComponentProcessor.processComponent(parICommandSender, ichatcomponent, entityplayermp));
|
||||
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle1);
|
||||
notifyOperators(parICommandSender, this, "commands.title.success", new Object[0]);
|
||||
}
|
||||
} else if (parArrayOfString.length != 2) {
|
||||
throw new WrongUsageException("commands.title.usage", new Object[0]);
|
||||
} else {
|
||||
S45PacketTitle s45packettitle = new S45PacketTitle(s45packettitle$type, (IChatComponent) null);
|
||||
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle);
|
||||
notifyOperators(parICommandSender, this, "commands.title.success", new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1
|
||||
? getListOfStringsMatchingLastWord(astring, MinecraftServer.getServer().getAllUsernames())
|
||||
: (astring.length == 2 ? getListOfStringsMatchingLastWord(astring, S45PacketTitle.Type.getNames())
|
||||
: null);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return whether the specified command parameter index is a
|
||||
* username parameter.
|
||||
*/
|
||||
public boolean isUsernameIndex(String[] var1, int i) {
|
||||
return i == 0;
|
||||
}
|
||||
}
|
||||
67
src/main/java/net/minecraft/command/CommandToggleDownfall.java
Executable file
67
src/main/java/net/minecraft/command/CommandToggleDownfall.java
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandToggleDownfall extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "toggledownfall";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.downfall.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
this.toggleDownfall();
|
||||
notifyOperators(parICommandSender, this, "commands.downfall.success", new Object[0]);
|
||||
}
|
||||
|
||||
/**+
|
||||
* Toggle rain and enable thundering.
|
||||
*/
|
||||
protected void toggleDownfall() {
|
||||
WorldInfo worldinfo = MinecraftServer.getServer().worldServers[0].getWorldInfo();
|
||||
worldinfo.setRaining(!worldinfo.isRaining());
|
||||
}
|
||||
}
|
||||
139
src/main/java/net/minecraft/command/CommandTrigger.java
Executable file
139
src/main/java/net/minecraft/command/CommandTrigger.java
Executable file
|
|
@ -0,0 +1,139 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.scoreboard.IScoreObjectiveCriteria;
|
||||
import net.minecraft.scoreboard.Score;
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
import net.minecraft.scoreboard.Scoreboard;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandTrigger extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "trigger";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.trigger.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 3) {
|
||||
throw new WrongUsageException("commands.trigger.usage", new Object[0]);
|
||||
} else {
|
||||
EntityPlayerMP entityplayermp;
|
||||
if (parICommandSender instanceof EntityPlayerMP) {
|
||||
entityplayermp = (EntityPlayerMP) parICommandSender;
|
||||
} else {
|
||||
Entity entity = parICommandSender.getCommandSenderEntity();
|
||||
if (!(entity instanceof EntityPlayerMP)) {
|
||||
throw new CommandException("commands.trigger.invalidPlayer", new Object[0]);
|
||||
}
|
||||
|
||||
entityplayermp = (EntityPlayerMP) entity;
|
||||
}
|
||||
|
||||
Scoreboard scoreboard = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard();
|
||||
ScoreObjective scoreobjective = scoreboard.getObjective(parArrayOfString[0]);
|
||||
if (scoreobjective != null && scoreobjective.getCriteria() == IScoreObjectiveCriteria.TRIGGER) {
|
||||
int i = parseInt(parArrayOfString[2]);
|
||||
if (!scoreboard.entityHasObjective(entityplayermp.getName(), scoreobjective)) {
|
||||
throw new CommandException("commands.trigger.invalidObjective",
|
||||
new Object[] { parArrayOfString[0] });
|
||||
} else {
|
||||
Score score = scoreboard.getValueFromObjective(entityplayermp.getName(), scoreobjective);
|
||||
if (score.isLocked()) {
|
||||
throw new CommandException("commands.trigger.disabled", new Object[] { parArrayOfString[0] });
|
||||
} else {
|
||||
if ("set".equals(parArrayOfString[1])) {
|
||||
score.setScorePoints(i);
|
||||
} else {
|
||||
if (!"add".equals(parArrayOfString[1])) {
|
||||
throw new CommandException("commands.trigger.invalidMode",
|
||||
new Object[] { parArrayOfString[1] });
|
||||
}
|
||||
|
||||
score.increseScore(i);
|
||||
}
|
||||
|
||||
score.setLocked(true);
|
||||
if (entityplayermp.theItemInWorldManager.isCreative()) {
|
||||
notifyOperators(parICommandSender, this, "commands.trigger.success",
|
||||
new Object[] { parArrayOfString[0], parArrayOfString[1], parArrayOfString[2] });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CommandException("commands.trigger.invalidObjective", new Object[] { parArrayOfString[0] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
if (astring.length == 1) {
|
||||
Scoreboard scoreboard = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard();
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
|
||||
for (ScoreObjective scoreobjective : scoreboard.getScoreObjectives()) {
|
||||
if (scoreobjective.getCriteria() == IScoreObjectiveCriteria.TRIGGER) {
|
||||
arraylist.add(scoreobjective.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return getListOfStringsMatchingLastWord(astring,
|
||||
(String[]) arraylist.toArray(new String[arraylist.size()]));
|
||||
} else {
|
||||
return astring.length == 2 ? getListOfStringsMatchingLastWord(astring, new String[] { "add", "set" })
|
||||
: null;
|
||||
}
|
||||
}
|
||||
}
|
||||
109
src/main/java/net/minecraft/command/CommandWeather.java
Executable file
109
src/main/java/net/minecraft/command/CommandWeather.java
Executable file
|
|
@ -0,0 +1,109 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandWeather extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "weather";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.weather.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length >= 1 && parArrayOfString.length <= 2) {
|
||||
int i = (300 + (new EaglercraftRandom()).nextInt(600)) * 20 * 2;
|
||||
if (parArrayOfString.length >= 2) {
|
||||
i = parseInt(parArrayOfString[1], 1, 1000000) * 20;
|
||||
}
|
||||
|
||||
WorldServer worldserver = MinecraftServer.getServer().worldServers[0];
|
||||
WorldInfo worldinfo = worldserver.getWorldInfo();
|
||||
if ("clear".equalsIgnoreCase(parArrayOfString[0])) {
|
||||
worldinfo.setCleanWeatherTime(i);
|
||||
worldinfo.setRainTime(0);
|
||||
worldinfo.setThunderTime(0);
|
||||
worldinfo.setRaining(false);
|
||||
worldinfo.setThundering(false);
|
||||
notifyOperators(parICommandSender, this, "commands.weather.clear", new Object[0]);
|
||||
} else if ("rain".equalsIgnoreCase(parArrayOfString[0])) {
|
||||
worldinfo.setCleanWeatherTime(0);
|
||||
worldinfo.setRainTime(i);
|
||||
worldinfo.setThunderTime(i);
|
||||
worldinfo.setRaining(true);
|
||||
worldinfo.setThundering(false);
|
||||
notifyOperators(parICommandSender, this, "commands.weather.rain", new Object[0]);
|
||||
} else {
|
||||
if (!"thunder".equalsIgnoreCase(parArrayOfString[0])) {
|
||||
throw new WrongUsageException("commands.weather.usage", new Object[0]);
|
||||
}
|
||||
|
||||
worldinfo.setCleanWeatherTime(0);
|
||||
worldinfo.setRainTime(i);
|
||||
worldinfo.setThunderTime(i);
|
||||
worldinfo.setRaining(true);
|
||||
worldinfo.setThundering(true);
|
||||
notifyOperators(parICommandSender, this, "commands.weather.thunder", new Object[0]);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new WrongUsageException("commands.weather.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos var3) {
|
||||
return astring.length == 1
|
||||
? getListOfStringsMatchingLastWord(astring, new String[] { "clear", "rain", "thunder" })
|
||||
: null;
|
||||
}
|
||||
}
|
||||
223
src/main/java/net/minecraft/command/CommandWorldBorder.java
Executable file
223
src/main/java/net/minecraft/command/CommandWorldBorder.java
Executable file
|
|
@ -0,0 +1,223 @@
|
|||
package net.minecraft.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.HString;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandResultStats;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.border.WorldBorder;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||||
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||
*
|
||||
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CommandWorldBorder extends CommandBase {
|
||||
|
||||
/**+
|
||||
* Gets the name of the command
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return "worldborder";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**+
|
||||
* Gets the usage string for the command.
|
||||
*/
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "commands.worldborder.usage";
|
||||
}
|
||||
|
||||
/**+
|
||||
* Callback when the command is invoked
|
||||
*/
|
||||
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
|
||||
if (parArrayOfString.length < 1) {
|
||||
throw new WrongUsageException("commands.worldborder.usage", new Object[0]);
|
||||
} else {
|
||||
WorldBorder worldborder = this.getWorldBorder();
|
||||
if (parArrayOfString[0].equals("set")) {
|
||||
if (parArrayOfString.length != 2 && parArrayOfString.length != 3) {
|
||||
throw new WrongUsageException("commands.worldborder.set.usage", new Object[0]);
|
||||
}
|
||||
|
||||
double d0 = worldborder.getTargetSize();
|
||||
double d2 = parseDouble(parArrayOfString[1], 1.0D, 6.0E7D);
|
||||
long i = parArrayOfString.length > 2 ? parseLong(parArrayOfString[2], 0L, 9223372036854775L) * 1000L
|
||||
: 0L;
|
||||
if (i > 0L) {
|
||||
worldborder.setTransition(d0, d2, i);
|
||||
if (d0 > d2) {
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.setSlowly.shrink.success",
|
||||
new Object[] { HString.format("%.1f", new Object[] { Double.valueOf(d2) }),
|
||||
HString.format("%.1f", new Object[] { Double.valueOf(d0) }),
|
||||
Long.toString(i / 1000L) });
|
||||
} else {
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.setSlowly.grow.success",
|
||||
new Object[] { HString.format("%.1f", new Object[] { Double.valueOf(d2) }),
|
||||
HString.format("%.1f", new Object[] { Double.valueOf(d0) }),
|
||||
Long.toString(i / 1000L) });
|
||||
}
|
||||
} else {
|
||||
worldborder.setTransition(d2);
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.set.success",
|
||||
new Object[] { HString.format("%.1f", new Object[] { Double.valueOf(d2) }),
|
||||
HString.format("%.1f", new Object[] { Double.valueOf(d0) }) });
|
||||
}
|
||||
} else if (parArrayOfString[0].equals("add")) {
|
||||
if (parArrayOfString.length != 2 && parArrayOfString.length != 3) {
|
||||
throw new WrongUsageException("commands.worldborder.add.usage", new Object[0]);
|
||||
}
|
||||
|
||||
double d4 = worldborder.getDiameter();
|
||||
double d8 = d4 + parseDouble(parArrayOfString[1], -d4, 6.0E7D - d4);
|
||||
long i1 = worldborder.getTimeUntilTarget()
|
||||
+ (parArrayOfString.length > 2 ? parseLong(parArrayOfString[2], 0L, 9223372036854775L) * 1000L
|
||||
: 0L);
|
||||
if (i1 > 0L) {
|
||||
worldborder.setTransition(d4, d8, i1);
|
||||
if (d4 > d8) {
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.setSlowly.shrink.success",
|
||||
new Object[] { HString.format("%.1f", new Object[] { Double.valueOf(d8) }),
|
||||
HString.format("%.1f", new Object[] { Double.valueOf(d4) }),
|
||||
Long.toString(i1 / 1000L) });
|
||||
} else {
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.setSlowly.grow.success",
|
||||
new Object[] { HString.format("%.1f", new Object[] { Double.valueOf(d8) }),
|
||||
HString.format("%.1f", new Object[] { Double.valueOf(d4) }),
|
||||
Long.toString(i1 / 1000L) });
|
||||
}
|
||||
} else {
|
||||
worldborder.setTransition(d8);
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.set.success",
|
||||
new Object[] { HString.format("%.1f", new Object[] { Double.valueOf(d8) }),
|
||||
HString.format("%.1f", new Object[] { Double.valueOf(d4) }) });
|
||||
}
|
||||
} else if (parArrayOfString[0].equals("center")) {
|
||||
if (parArrayOfString.length != 3) {
|
||||
throw new WrongUsageException("commands.worldborder.center.usage", new Object[0]);
|
||||
}
|
||||
|
||||
BlockPos blockpos = parICommandSender.getPosition();
|
||||
double d1 = parseDouble((double) blockpos.getX() + 0.5D, parArrayOfString[1], true);
|
||||
double d3 = parseDouble((double) blockpos.getZ() + 0.5D, parArrayOfString[2], true);
|
||||
worldborder.setCenter(d1, d3);
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.center.success",
|
||||
new Object[] { Double.valueOf(d1), Double.valueOf(d3) });
|
||||
} else if (parArrayOfString[0].equals("damage")) {
|
||||
if (parArrayOfString.length < 2) {
|
||||
throw new WrongUsageException("commands.worldborder.damage.usage", new Object[0]);
|
||||
}
|
||||
|
||||
if (parArrayOfString[1].equals("buffer")) {
|
||||
if (parArrayOfString.length != 3) {
|
||||
throw new WrongUsageException("commands.worldborder.damage.buffer.usage", new Object[0]);
|
||||
}
|
||||
|
||||
double d5 = parseDouble(parArrayOfString[2], 0.0D);
|
||||
double d9 = worldborder.getDamageBuffer();
|
||||
worldborder.setDamageBuffer(d5);
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.damage.buffer.success",
|
||||
new Object[] { HString.format("%.1f", new Object[] { Double.valueOf(d5) }),
|
||||
HString.format("%.1f", new Object[] { Double.valueOf(d9) }) });
|
||||
} else if (parArrayOfString[1].equals("amount")) {
|
||||
if (parArrayOfString.length != 3) {
|
||||
throw new WrongUsageException("commands.worldborder.damage.amount.usage", new Object[0]);
|
||||
}
|
||||
|
||||
double d6 = parseDouble(parArrayOfString[2], 0.0D);
|
||||
double d10 = worldborder.getDamageAmount();
|
||||
worldborder.setDamageAmount(d6);
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.damage.amount.success",
|
||||
new Object[] { HString.format("%.2f", new Object[] { Double.valueOf(d6) }),
|
||||
HString.format("%.2f", new Object[] { Double.valueOf(d10) }) });
|
||||
}
|
||||
} else if (parArrayOfString[0].equals("warning")) {
|
||||
if (parArrayOfString.length < 2) {
|
||||
throw new WrongUsageException("commands.worldborder.warning.usage", new Object[0]);
|
||||
}
|
||||
|
||||
int j = parseInt(parArrayOfString[2], 0);
|
||||
if (parArrayOfString[1].equals("time")) {
|
||||
if (parArrayOfString.length != 3) {
|
||||
throw new WrongUsageException("commands.worldborder.warning.time.usage", new Object[0]);
|
||||
}
|
||||
|
||||
int k = worldborder.getWarningTime();
|
||||
worldborder.setWarningTime(j);
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.warning.time.success",
|
||||
new Object[] { Integer.valueOf(j), Integer.valueOf(k) });
|
||||
} else if (parArrayOfString[1].equals("distance")) {
|
||||
if (parArrayOfString.length != 3) {
|
||||
throw new WrongUsageException("commands.worldborder.warning.distance.usage", new Object[0]);
|
||||
}
|
||||
|
||||
int l = worldborder.getWarningDistance();
|
||||
worldborder.setWarningDistance(j);
|
||||
notifyOperators(parICommandSender, this, "commands.worldborder.warning.distance.success",
|
||||
new Object[] { Integer.valueOf(j), Integer.valueOf(l) });
|
||||
}
|
||||
} else {
|
||||
if (!parArrayOfString[0].equals("get")) {
|
||||
throw new WrongUsageException("commands.worldborder.usage", new Object[0]);
|
||||
}
|
||||
|
||||
double d7 = worldborder.getDiameter();
|
||||
parICommandSender.setCommandStat(CommandResultStats.Type.QUERY_RESULT,
|
||||
MathHelper.floor_double(d7 + 0.5D));
|
||||
parICommandSender.addChatMessage(new ChatComponentTranslation("commands.worldborder.get.success",
|
||||
new Object[] { HString.format("%.0f", new Object[] { Double.valueOf(d7) }) }));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected WorldBorder getWorldBorder() {
|
||||
return MinecraftServer.getServer().worldServers[0].getWorldBorder();
|
||||
}
|
||||
|
||||
/**+
|
||||
* Return a list of options when the user types TAB
|
||||
*/
|
||||
public List<String> addTabCompletionOptions(ICommandSender var1, String[] astring, BlockPos blockpos) {
|
||||
return astring.length == 1
|
||||
? getListOfStringsMatchingLastWord(astring,
|
||||
new String[] { "set", "center", "damage", "warning", "add", "get" })
|
||||
: (astring.length == 2 && astring[0].equals("damage")
|
||||
? getListOfStringsMatchingLastWord(astring, new String[] { "buffer", "amount" })
|
||||
: (astring.length >= 2 && astring.length <= 3 && astring[0].equals("center")
|
||||
? func_181043_b(astring, 1, blockpos)
|
||||
: (astring.length == 2 && astring[0].equals("warning")
|
||||
? getListOfStringsMatchingLastWord(astring, new String[] { "time", "distance" })
|
||||
: null)));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue