This commit is contained in:
eaglercraft
2024-02-19 02:02:25 -08:00
parent 2ebb5d6da9
commit 401ebe2324
1261 changed files with 12766 additions and 138431 deletions

View File

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

View File

@@ -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
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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) {

View File

@@ -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) {

View File

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

View File

@@ -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.
*/

View File

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

View File

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

View File

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

View File

@@ -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()) {

View File

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

View File

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

View File

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

View File

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

View File

@@ -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;
}
}
/**+

View File

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

View File

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

View File

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

View File

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

View File

@@ -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) {

View File

@@ -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.
*/

View File

@@ -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;
}
}
/**+

View File

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

View File

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

View File

@@ -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) {

View File

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

View File

@@ -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) {

View File

@@ -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.
*/

View File

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

View File

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

View File

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

View File

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

View File

@@ -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) {

View File

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

View File

@@ -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() {

View File

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

View File

@@ -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.
*/

View File

@@ -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.
*/

View File

@@ -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
*/

View File

@@ -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) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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.
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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) {