import code
This commit is contained in:
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||||
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
## IDEA ##
|
||||||
|
.idea/
|
||||||
|
out/
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
*.ids
|
||||||
|
|
||||||
|
## GRADLE ##
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
17
README.MD
Normal file
17
README.MD
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Minecraft 1.8.8
|
||||||
|
|
||||||
|
- MCP decompile
|
||||||
|
- port to Gradle
|
||||||
|
- use Java 8
|
||||||
|
|
||||||
|
## Run Client
|
||||||
|
|
||||||
|
```shell
|
||||||
|
gradle client:run
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run Server
|
||||||
|
|
||||||
|
```shell
|
||||||
|
gradle client:run
|
||||||
|
```
|
||||||
62
client/build.gradle
Normal file
62
client/build.gradle
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
apply plugin: 'java'
|
||||||
|
apply plugin: 'application'
|
||||||
|
|
||||||
|
group = 'minecraft'
|
||||||
|
version = '1.8.8'
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
sourceCompatibility = targetCompatibility = 1.8
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClassName = 'net.minecraft.client.main.Main'
|
||||||
|
}
|
||||||
|
|
||||||
|
run {
|
||||||
|
workingDir = new File(buildDir, 'run')
|
||||||
|
if (!workingDir.exists()) {
|
||||||
|
workingDir.mkdir()
|
||||||
|
}
|
||||||
|
|
||||||
|
systemProperty 'java.library.path', file("$buildDir/natives/windows")
|
||||||
|
args '--version', '1.8.8', '--accessToken', '0', '--assetsDir', 'assets', '--assetIndex', "1.8", '--userProperties', '{}'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
flatDir { dirs '../libs' }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile name: 'com/mojang/authlib/1.5.21/authlib-1.5.21'
|
||||||
|
compile name: 'tv/twitch/twitch/6.5/twitch-6.5'
|
||||||
|
compile name: 'com/paulscode/soundsystem/20120107/soundsystem-20120107'
|
||||||
|
compile name: 'com/paulscode/codecjorbis/20101023/codecjorbis-20101023'
|
||||||
|
compile name: 'com/paulscode/librarylwjglopenal/20100824/librarylwjglopenal-20100824'
|
||||||
|
compile name: 'oshi-project/oshi-core/1.1/oshi-core-1.1'
|
||||||
|
|
||||||
|
compile 'org.lwjgl.lwjgl:lwjgl:2.9.3'
|
||||||
|
compile 'org.lwjgl.lwjgl:lwjgl_util:2.9.3'
|
||||||
|
compile 'com.ibm.icu:icu4j:52.2'
|
||||||
|
compile 'net.sf.jopt-simple:jopt-simple:4.6'
|
||||||
|
compile 'org.apache.commons:commons-lang3:3.3.2'
|
||||||
|
compile 'com.google.guava:guava:17.0'
|
||||||
|
compile 'org.apache.logging.log4j:log4j-core:2.0-beta9'
|
||||||
|
compile 'io.netty:netty-all:4.0.23.Final'
|
||||||
|
compile 'com.google.code.gson:gson:2.2.4'
|
||||||
|
compile 'commons-io:commons-io:2.4'
|
||||||
|
}
|
||||||
|
|
||||||
|
task copyNativesWindows {
|
||||||
|
doLast {
|
||||||
|
copy {
|
||||||
|
def resolvedArtifacts = configurations.compile.resolvedConfiguration.resolvedArtifacts
|
||||||
|
def matches = resolvedArtifacts.findAll { it.classifier == 'natives-windows' }
|
||||||
|
from matches.collect { it.file }.collect { zipTree(it) }
|
||||||
|
into "$buildDir/natives/windows"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
20
client/src/main/java/Start.java
Normal file
20
client/src/main/java/Start.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.minecraft.client.main.Main;
|
||||||
|
|
||||||
|
public class Start
|
||||||
|
{
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
Main.main(concat(new String[] {"--version", "mcp", "--accessToken", "0", "--assetsDir", "assets", "--assetIndex", "1.8", "--userProperties", "{}"}, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T[] concat(T[] first, T[] second)
|
||||||
|
{
|
||||||
|
T[] result = Arrays.copyOf(first, first.length + second.length);
|
||||||
|
System.arraycopy(second, 0, result, first.length, second.length);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
1545
client/src/main/java/net/minecraft/block/Block.java
Normal file
1545
client/src/main/java/net/minecraft/block/Block.java
Normal file
File diff suppressed because it is too large
Load Diff
56
client/src/main/java/net/minecraft/block/BlockAir.java
Normal file
56
client/src/main/java/net/minecraft/block/BlockAir.java
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockAir extends Block
|
||||||
|
{
|
||||||
|
protected BlockAir()
|
||||||
|
{
|
||||||
|
super(Material.air);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this Block can be replaced directly by other blocks (true for e.g. tall grass)
|
||||||
|
*/
|
||||||
|
public boolean isReplaceable(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
190
client/src/main/java/net/minecraft/block/BlockAnvil.java
Normal file
190
client/src/main/java/net/minecraft/block/BlockAnvil.java
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.item.EntityFallingBlock;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.ContainerRepair;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.IInteractionObject;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockAnvil extends BlockFalling
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
public static final PropertyInteger DAMAGE = PropertyInteger.create("damage", 0, 2);
|
||||||
|
|
||||||
|
protected BlockAnvil()
|
||||||
|
{
|
||||||
|
super(Material.anvil);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(DAMAGE, Integer.valueOf(0)));
|
||||||
|
this.setLightOpacity(0);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = placer.getHorizontalFacing().rotateY();
|
||||||
|
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).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 the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(DAMAGE)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
|
||||||
|
|
||||||
|
if (enumfacing.getAxis() == EnumFacing.Axis.X)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.125F, 1.0F, 1.0F, 0.875F);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.125F, 0.0F, 0.0F, 0.875F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, 0));
|
||||||
|
list.add(new ItemStack(itemIn, 1, 1));
|
||||||
|
list.add(new ItemStack(itemIn, 1, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onStartFalling(EntityFallingBlock fallingEntity)
|
||||||
|
{
|
||||||
|
fallingEntity.setHurtEntities(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEndFalling(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
worldIn.playAuxSFX(1022, pos, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
|
||||||
|
*/
|
||||||
|
public IBlockState getStateForEntityRender(IBlockState state)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta & 3)).withProperty(DAMAGE, Integer.valueOf((meta & 15) >> 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
|
||||||
|
i = i | ((Integer)state.getValue(DAMAGE)).intValue() << 2;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, DAMAGE});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Anvil implements IInteractionObject
|
||||||
|
{
|
||||||
|
private final World world;
|
||||||
|
private final BlockPos position;
|
||||||
|
|
||||||
|
public Anvil(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.world = worldIn;
|
||||||
|
this.position = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return "anvil";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasCustomName()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IChatComponent getDisplayName()
|
||||||
|
{
|
||||||
|
return new ChatComponentTranslation(Blocks.anvil.getUnlocalizedName() + ".name", new Object[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||||
|
{
|
||||||
|
return new ContainerRepair(playerInventory, this.world, this.position, playerIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGuiID()
|
||||||
|
{
|
||||||
|
return "minecraft:anvil";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
253
client/src/main/java/net/minecraft/block/BlockBanner.java
Normal file
253
client/src/main/java/net/minecraft/block/BlockBanner.java
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityBanner;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockBanner extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
public static final PropertyInteger ROTATION = PropertyInteger.create("rotation", 0, 15);
|
||||||
|
|
||||||
|
protected BlockBanner()
|
||||||
|
{
|
||||||
|
super(Material.wood);
|
||||||
|
float f = 0.25F;
|
||||||
|
float f1 = 1.0F;
|
||||||
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the localized name of this block. Used for the statistics page.
|
||||||
|
*/
|
||||||
|
public String getLocalizedName()
|
||||||
|
{
|
||||||
|
return StatCollector.translateToLocal("item.banner.white.name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
return super.getSelectedBoundingBox(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean func_181623_g()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityBanner();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Items.banner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Items.banner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityBanner)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = new ItemStack(Items.banner, 1, ((TileEntityBanner)tileentity).getBaseColor());
|
||||||
|
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||||
|
tileentity.writeToNBT(nbttagcompound);
|
||||||
|
nbttagcompound.removeTag("x");
|
||||||
|
nbttagcompound.removeTag("y");
|
||||||
|
nbttagcompound.removeTag("z");
|
||||||
|
nbttagcompound.removeTag("id");
|
||||||
|
itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
|
||||||
|
spawnAsEntity(worldIn, pos, itemstack);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return !this.func_181087_e(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
|
||||||
|
{
|
||||||
|
if (te instanceof TileEntityBanner)
|
||||||
|
{
|
||||||
|
TileEntityBanner tileentitybanner = (TileEntityBanner)te;
|
||||||
|
ItemStack itemstack = new ItemStack(Items.banner, 1, ((TileEntityBanner)te).getBaseColor());
|
||||||
|
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||||
|
TileEntityBanner.func_181020_a(nbttagcompound, tileentitybanner.getBaseColor(), tileentitybanner.func_181021_d());
|
||||||
|
itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
|
||||||
|
spawnAsEntity(worldIn, pos, itemstack);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
super.harvestBlock(worldIn, player, pos, state, (TileEntity)null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BlockBannerHanging extends BlockBanner
|
||||||
|
{
|
||||||
|
public BlockBannerHanging()
|
||||||
|
{
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
|
||||||
|
float f = 0.0F;
|
||||||
|
float f1 = 0.78125F;
|
||||||
|
float f2 = 0.0F;
|
||||||
|
float f3 = 1.0F;
|
||||||
|
float f4 = 0.125F;
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
|
switch (enumfacing)
|
||||||
|
{
|
||||||
|
case NORTH:
|
||||||
|
default:
|
||||||
|
this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
this.setBlockBounds(f2, f, 0.0F, f3, f1, f4);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EAST:
|
||||||
|
this.setBlockBounds(0.0F, f, f2, f4, f1, f3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
|
||||||
|
if (!worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock().getMaterial().isSolid())
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = EnumFacing.getFront(meta);
|
||||||
|
|
||||||
|
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
|
||||||
|
{
|
||||||
|
enumfacing = EnumFacing.NORTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState().withProperty(FACING, enumfacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BlockBannerStanding extends BlockBanner
|
||||||
|
{
|
||||||
|
public BlockBannerStanding()
|
||||||
|
{
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(ROTATION, Integer.valueOf(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid())
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(ROTATION, Integer.valueOf(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(ROTATION)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {ROTATION});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
49
client/src/main/java/net/minecraft/block/BlockBarrier.java
Normal file
49
client/src/main/java/net/minecraft/block/BlockBarrier.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockBarrier extends Block
|
||||||
|
{
|
||||||
|
protected BlockBarrier()
|
||||||
|
{
|
||||||
|
super(Material.barrier);
|
||||||
|
this.setBlockUnbreakable();
|
||||||
|
this.setResistance(6000001.0F);
|
||||||
|
this.disableStats();
|
||||||
|
this.translucent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default ambient occlusion value based on block opacity
|
||||||
|
*/
|
||||||
|
public float getAmbientOcclusionLightValue()
|
||||||
|
{
|
||||||
|
return 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
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;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public abstract class BlockBasePressurePlate extends Block
|
||||||
|
{
|
||||||
|
protected BlockBasePressurePlate(Material materialIn)
|
||||||
|
{
|
||||||
|
this(materialIn, materialIn.getMaterialMapColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockBasePressurePlate(Material p_i46401_1_, MapColor p_i46401_2_)
|
||||||
|
{
|
||||||
|
super(p_i46401_1_, p_i46401_2_);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState0(worldIn.getBlockState(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setBlockBoundsBasedOnState0(IBlockState state)
|
||||||
|
{
|
||||||
|
boolean flag = this.getRedstoneStrength(state) > 0;
|
||||||
|
float f = 0.0625F;
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.03125F, 0.9375F);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.0625F, 0.9375F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many world ticks before ticking
|
||||||
|
*/
|
||||||
|
public int tickRate(World worldIn)
|
||||||
|
{
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean func_181623_g()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return this.canBePlacedOn(worldIn, pos.down());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!this.canBePlacedOn(worldIn, pos.down()))
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canBePlacedOn(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return World.doesBlockHaveSolidTopSurface(worldIn, pos) || worldIn.getBlockState(pos).getBlock() instanceof BlockFence;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.)
|
||||||
|
*/
|
||||||
|
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the pressure plate when stepped on
|
||||||
|
*/
|
||||||
|
protected void updateState(World worldIn, BlockPos pos, IBlockState state, int oldRedstoneStrength)
|
||||||
|
{
|
||||||
|
int i = this.computeRedstoneStrength(worldIn, pos);
|
||||||
|
boolean flag = oldRedstoneStrength > 0;
|
||||||
|
boolean flag1 = i > 0;
|
||||||
|
|
||||||
|
if (oldRedstoneStrength != i)
|
||||||
|
{
|
||||||
|
state = this.setRedstoneStrength(state, i);
|
||||||
|
worldIn.setBlockState(pos, state, 2);
|
||||||
|
this.updateNeighbors(worldIn, pos);
|
||||||
|
worldIn.markBlockRangeForRenderUpdate(pos, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flag1 && flag)
|
||||||
|
{
|
||||||
|
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.1D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
|
||||||
|
}
|
||||||
|
else if (flag1 && !flag)
|
||||||
|
{
|
||||||
|
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.1D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag1)
|
||||||
|
{
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the cubic AABB inset by 1/8 on all sides
|
||||||
|
*/
|
||||||
|
protected AxisAlignedBB getSensitiveAABB(BlockPos pos)
|
||||||
|
{
|
||||||
|
float f = 0.125F;
|
||||||
|
return new AxisAlignedBB((double)((float)pos.getX() + 0.125F), (double)pos.getY(), (double)((float)pos.getZ() + 0.125F), (double)((float)(pos.getX() + 1) - 0.125F), (double)pos.getY() + 0.25D, (double)((float)(pos.getZ() + 1) - 0.125F));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (this.getRedstoneStrength(state) > 0)
|
||||||
|
{
|
||||||
|
this.updateNeighbors(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify block and block below of changes
|
||||||
|
*/
|
||||||
|
protected void updateNeighbors(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
worldIn.notifyNeighborsOfStateChange(pos, this);
|
||||||
|
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
return this.getRedstoneStrength(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
return side == EnumFacing.UP ? this.getRedstoneStrength(state) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||||
|
*/
|
||||||
|
public boolean canProvidePower()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
float f = 0.5F;
|
||||||
|
float f1 = 0.125F;
|
||||||
|
float f2 = 0.5F;
|
||||||
|
this.setBlockBounds(0.0F, 0.375F, 0.0F, 1.0F, 0.625F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMobilityFlag()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract int computeRedstoneStrength(World worldIn, BlockPos pos);
|
||||||
|
|
||||||
|
protected abstract int getRedstoneStrength(IBlockState state);
|
||||||
|
|
||||||
|
protected abstract IBlockState setRedstoneStrength(IBlockState state, int strength);
|
||||||
|
}
|
||||||
156
client/src/main/java/net/minecraft/block/BlockBeacon.java
Normal file
156
client/src/main/java/net/minecraft/block/BlockBeacon.java
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
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.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.util.HttpUtil;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
|
public class BlockBeacon extends BlockContainer
|
||||||
|
{
|
||||||
|
public BlockBeacon()
|
||||||
|
{
|
||||||
|
super(Material.glass, MapColor.diamondColor);
|
||||||
|
this.setHardness(3.0F);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabMisc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityBeacon();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityBeacon)
|
||||||
|
{
|
||||||
|
playerIn.displayGUIChest((TileEntityBeacon)tileentity);
|
||||||
|
playerIn.triggerAchievement(StatList.field_181730_N);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
|
||||||
|
|
||||||
|
if (stack.hasDisplayName())
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityBeacon)
|
||||||
|
{
|
||||||
|
((TileEntityBeacon)tileentity).setName(stack.getDisplayName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityBeacon)
|
||||||
|
{
|
||||||
|
((TileEntityBeacon)tileentity).updateBeacon();
|
||||||
|
worldIn.addBlockEvent(pos, this, 1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updateColorAsync(final World worldIn, final BlockPos glassPos)
|
||||||
|
{
|
||||||
|
HttpUtil.field_180193_a.submit(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
336
client/src/main/java/net/minecraft/block/BlockBed.java
Normal file
336
client/src/main/java/net/minecraft/block/BlockBed.java
Normal file
@@ -0,0 +1,336 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
public class BlockBed extends BlockDirectional
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockBed.EnumPartType> PART = PropertyEnum.<BlockBed.EnumPartType>create("part", BlockBed.EnumPartType.class);
|
||||||
|
public static final PropertyBool OCCUPIED = PropertyBool.create("occupied");
|
||||||
|
|
||||||
|
public BlockBed()
|
||||||
|
{
|
||||||
|
super(Material.cloth);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(PART, BlockBed.EnumPartType.FOOT).withProperty(OCCUPIED, Boolean.valueOf(false)));
|
||||||
|
this.setBedBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (state.getValue(PART) != BlockBed.EnumPartType.HEAD)
|
||||||
|
{
|
||||||
|
pos = pos.offset((EnumFacing)state.getValue(FACING));
|
||||||
|
state = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (state.getBlock() != this)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.provider.canRespawnHere() && worldIn.getBiomeGenForCoords(pos) != BiomeGenBase.hell)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(OCCUPIED)).booleanValue())
|
||||||
|
{
|
||||||
|
EntityPlayer entityplayer = this.getPlayerInBed(worldIn, pos);
|
||||||
|
|
||||||
|
if (entityplayer != null)
|
||||||
|
{
|
||||||
|
playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.occupied", new Object[0]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = state.withProperty(OCCUPIED, Boolean.valueOf(false));
|
||||||
|
worldIn.setBlockState(pos, state, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityPlayer.EnumStatus entityplayer$enumstatus = playerIn.trySleep(pos);
|
||||||
|
|
||||||
|
if (entityplayer$enumstatus == EntityPlayer.EnumStatus.OK)
|
||||||
|
{
|
||||||
|
state = state.withProperty(OCCUPIED, Boolean.valueOf(true));
|
||||||
|
worldIn.setBlockState(pos, state, 4);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW)
|
||||||
|
{
|
||||||
|
playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep", new Object[0]));
|
||||||
|
}
|
||||||
|
else if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_SAFE)
|
||||||
|
{
|
||||||
|
playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe", new Object[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(blockpos).getBlock() == this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(blockpos);
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.newExplosion((Entity)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.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()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBedBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
|
||||||
|
if (state.getValue(PART) == BlockBed.EnumPartType.HEAD)
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock() != this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() != this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return state.getValue(PART) == BlockBed.EnumPartType.HEAD ? null : Items.bed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBedBounds()
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5625F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a safe BlockPos to disembark the bed
|
||||||
|
*/
|
||||||
|
public static BlockPos getSafeExitLocation(World worldIn, BlockPos pos, int tries)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
|
||||||
|
int i = pos.getX();
|
||||||
|
int j = pos.getY();
|
||||||
|
int k = pos.getZ();
|
||||||
|
|
||||||
|
for (int l = 0; l <= 1; ++l)
|
||||||
|
{
|
||||||
|
int i1 = i - enumfacing.getFrontOffsetX() * l - 1;
|
||||||
|
int j1 = k - enumfacing.getFrontOffsetZ() * l - 1;
|
||||||
|
int k1 = i1 + 2;
|
||||||
|
int l1 = j1 + 2;
|
||||||
|
|
||||||
|
for (int i2 = i1; i2 <= k1; ++i2)
|
||||||
|
{
|
||||||
|
for (int j2 = j1; j2 <= l1; ++j2)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = new BlockPos(i2, j, j2);
|
||||||
|
|
||||||
|
if (hasRoomForPlayer(worldIn, blockpos))
|
||||||
|
{
|
||||||
|
if (tries <= 0)
|
||||||
|
{
|
||||||
|
return blockpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
--tries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean hasRoomForPlayer(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !worldIn.getBlockState(pos).getBlock().getMaterial().isSolid() && !worldIn.getBlockState(pos.up()).getBlock().getMaterial().isSolid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
if (state.getValue(PART) == BlockBed.EnumPartType.FOOT)
|
||||||
|
{
|
||||||
|
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMobilityFlag()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Items.bed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
|
||||||
|
{
|
||||||
|
if (player.capabilities.isCreativeMode && state.getValue(PART) == BlockBed.EnumPartType.HEAD)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(blockpos).getBlock() == this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(blockpos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = EnumFacing.getHorizontal(meta);
|
||||||
|
return (meta & 8) > 0 ? this.getDefaultState().withProperty(PART, BlockBed.EnumPartType.HEAD).withProperty(FACING, enumfacing).withProperty(OCCUPIED, Boolean.valueOf((meta & 4) > 0)) : this.getDefaultState().withProperty(PART, BlockBed.EnumPartType.FOOT).withProperty(FACING, enumfacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (state.getValue(PART) == BlockBed.EnumPartType.FOOT)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos.offset((EnumFacing)state.getValue(FACING)));
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
state = state.withProperty(OCCUPIED, iblockstate.getValue(OCCUPIED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
|
||||||
|
|
||||||
|
if (state.getValue(PART) == BlockBed.EnumPartType.HEAD)
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(OCCUPIED)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, PART, OCCUPIED});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumPartType implements IStringSerializable
|
||||||
|
{
|
||||||
|
HEAD("head"),
|
||||||
|
FOOT("foot");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private EnumPartType(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
client/src/main/java/net/minecraft/block/BlockBookshelf.java
Normal file
33
client/src/main/java/net/minecraft/block/BlockBookshelf.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
public class BlockBookshelf extends Block
|
||||||
|
{
|
||||||
|
public BlockBookshelf()
|
||||||
|
{
|
||||||
|
super(Material.wood);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Items.book;
|
||||||
|
}
|
||||||
|
}
|
||||||
54
client/src/main/java/net/minecraft/block/BlockBreakable.java
Normal file
54
client/src/main/java/net/minecraft/block/BlockBreakable.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
|
public class BlockBreakable extends Block
|
||||||
|
{
|
||||||
|
private boolean ignoreSimilarity;
|
||||||
|
|
||||||
|
protected BlockBreakable(Material materialIn, boolean ignoreSimilarityIn)
|
||||||
|
{
|
||||||
|
this(materialIn, ignoreSimilarityIn, materialIn.getMaterialMapColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockBreakable(Material p_i46393_1_, boolean p_i46393_2_, MapColor p_i46393_3_)
|
||||||
|
{
|
||||||
|
super(p_i46393_1_, p_i46393_3_);
|
||||||
|
this.ignoreSimilarity = p_i46393_2_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
Block block = iblockstate.getBlock();
|
||||||
|
|
||||||
|
if (this == Blocks.glass || this == Blocks.stained_glass)
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(pos.offset(side.getOpposite())) != iblockstate)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block == this)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return !this.ignoreSimilarity && block == this ? false : super.shouldSideBeRendered(worldIn, pos, side);
|
||||||
|
}
|
||||||
|
}
|
||||||
216
client/src/main/java/net/minecraft/block/BlockBrewingStand.java
Normal file
216
client/src/main/java/net/minecraft/block/BlockBrewingStand.java
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
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;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockBrewingStand extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyBool[] HAS_BOTTLE = new PropertyBool[] {PropertyBool.create("has_bottle_0"), PropertyBool.create("has_bottle_1"), PropertyBool.create("has_bottle_2")};
|
||||||
|
|
||||||
|
public BlockBrewingStand()
|
||||||
|
{
|
||||||
|
super(Material.iron);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(HAS_BOTTLE[0], Boolean.valueOf(false)).withProperty(HAS_BOTTLE[1], Boolean.valueOf(false)).withProperty(HAS_BOTTLE[2], Boolean.valueOf(false)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the localized name of this block. Used for the statistics page.
|
||||||
|
*/
|
||||||
|
public String getLocalizedName()
|
||||||
|
{
|
||||||
|
return StatCollector.translateToLocal("item.brewingStand.name");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityBrewingStand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.875F, 0.5625F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBoundsForItemRender();
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityBrewingStand)
|
||||||
|
{
|
||||||
|
playerIn.displayGUIChest((TileEntityBrewingStand)tileentity);
|
||||||
|
playerIn.triggerAchievement(StatList.field_181729_M);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
if (stack.hasDisplayName())
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityBrewingStand)
|
||||||
|
{
|
||||||
|
((TileEntityBrewingStand)tileentity).setName(stack.getDisplayName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
double d0 = (double)((float)pos.getX() + 0.4F + rand.nextFloat() * 0.2F);
|
||||||
|
double d1 = (double)((float)pos.getY() + 0.7F + rand.nextFloat() * 0.3F);
|
||||||
|
double d2 = (double)((float)pos.getZ() + 0.4F + rand.nextFloat() * 0.2F);
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityBrewingStand)
|
||||||
|
{
|
||||||
|
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityBrewingStand)tileentity);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Items.brewing_stand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Items.brewing_stand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Container.calcRedstone(worldIn.getTileEntity(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = this.getDefaultState();
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
iblockstate = iblockstate.withProperty(HAS_BOTTLE[i], Boolean.valueOf((meta & 1 << i) > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return iblockstate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (int j = 0; j < 3; ++j)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(HAS_BOTTLE[j])).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 1 << j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {HAS_BOTTLE[0], HAS_BOTTLE[1], HAS_BOTTLE[2]});
|
||||||
|
}
|
||||||
|
}
|
||||||
98
client/src/main/java/net/minecraft/block/BlockBush.java
Normal file
98
client/src/main/java/net/minecraft/block/BlockBush.java
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
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.init.Blocks;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockBush extends Block
|
||||||
|
{
|
||||||
|
protected BlockBush()
|
||||||
|
{
|
||||||
|
this(Material.plants);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockBush(Material materialIn)
|
||||||
|
{
|
||||||
|
this(materialIn, materialIn.getMaterialMapColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockBush(Material p_i46452_1_, MapColor p_i46452_2_)
|
||||||
|
{
|
||||||
|
super(p_i46452_1_, p_i46452_2_);
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
float f = 0.2F;
|
||||||
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return super.canPlaceBlockAt(worldIn, pos) && this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is the block grass, dirt or farmland
|
||||||
|
*/
|
||||||
|
protected boolean canPlaceBlockOn(Block ground)
|
||||||
|
{
|
||||||
|
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
|
||||||
|
this.checkAndDropBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
this.checkAndDropBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (!this.canBlockStay(worldIn, pos, state))
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockState(pos, Blocks.air.getDefaultState(), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
386
client/src/main/java/net/minecraft/block/BlockButton.java
Normal file
386
client/src/main/java/net/minecraft/block/BlockButton.java
Normal file
@@ -0,0 +1,386 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.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;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public abstract class BlockButton extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing");
|
||||||
|
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||||
|
private final boolean wooden;
|
||||||
|
|
||||||
|
protected BlockButton(boolean wooden)
|
||||||
|
{
|
||||||
|
super(Material.circuits);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(POWERED, Boolean.valueOf(false)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||||
|
this.wooden = wooden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many world ticks before ticking
|
||||||
|
*/
|
||||||
|
public int tickRate(World worldIn)
|
||||||
|
{
|
||||||
|
return this.wooden ? 30 : 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether this Block can be placed on the given side
|
||||||
|
*/
|
||||||
|
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return func_181088_a(worldIn, pos, side.getOpposite());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.values())
|
||||||
|
{
|
||||||
|
if (func_181088_a(worldIn, pos, enumfacing))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean func_181088_a(World p_181088_0_, BlockPos p_181088_1_, EnumFacing p_181088_2_)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = p_181088_1_.offset(p_181088_2_);
|
||||||
|
return p_181088_2_ == EnumFacing.DOWN ? World.doesBlockHaveSolidTopSurface(p_181088_0_, blockpos) : p_181088_0_.getBlockState(blockpos).getBlock().isNormalCube();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return func_181088_a(worldIn, pos, facing.getOpposite()) ? this.getDefaultState().withProperty(FACING, facing).withProperty(POWERED, Boolean.valueOf(false)) : this.getDefaultState().withProperty(FACING, EnumFacing.DOWN).withProperty(POWERED, Boolean.valueOf(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (this.checkForDrop(worldIn, pos, state) && !func_181088_a(worldIn, pos, ((EnumFacing)state.getValue(FACING)).getOpposite()))
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (this.canPlaceBlockAt(worldIn, pos))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.updateBlockBounds(worldIn.getBlockState(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBlockBounds(IBlockState state)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
|
||||||
|
float f = 0.25F;
|
||||||
|
float f1 = 0.375F;
|
||||||
|
float f2 = (float)(flag ? 1 : 2) / 16.0F;
|
||||||
|
float f3 = 0.125F;
|
||||||
|
float f4 = 0.1875F;
|
||||||
|
|
||||||
|
switch (enumfacing)
|
||||||
|
{
|
||||||
|
case EAST:
|
||||||
|
this.setBlockBounds(0.0F, 0.375F, 0.3125F, f2, 0.625F, 0.6875F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
this.setBlockBounds(1.0F - f2, 0.375F, 0.3125F, 1.0F, 0.625F, 0.6875F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
this.setBlockBounds(0.3125F, 0.375F, 0.0F, 0.6875F, 0.625F, f2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
this.setBlockBounds(0.3125F, 0.375F, 1.0F - f2, 0.6875F, 0.625F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UP:
|
||||||
|
this.setBlockBounds(0.3125F, 0.0F, 0.375F, 0.6875F, 0.0F + f2, 0.625F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DOWN:
|
||||||
|
this.setBlockBounds(0.3125F, 1.0F - f2, 0.375F, 0.6875F, 1.0F, 0.625F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
|
||||||
|
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);
|
||||||
|
this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
return ((Boolean)state.getValue(POWERED)).booleanValue() ? 15 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
return !((Boolean)state.getValue(POWERED)).booleanValue() ? 0 : (state.getValue(FACING) == side ? 15 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||||
|
*/
|
||||||
|
public boolean canProvidePower()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.)
|
||||||
|
*/
|
||||||
|
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
if (this.wooden)
|
||||||
|
{
|
||||||
|
this.checkForArrows(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
|
||||||
|
this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
|
||||||
|
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
|
||||||
|
worldIn.markBlockRangeForRenderUpdate(pos, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
float f = 0.1875F;
|
||||||
|
float f1 = 0.125F;
|
||||||
|
float f2 = 0.125F;
|
||||||
|
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 worldIn, BlockPos pos, IBlockState state, Entity entityIn)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
if (this.wooden)
|
||||||
|
{
|
||||||
|
if (!((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
this.checkForArrows(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.updateBlockBounds(state);
|
||||||
|
List <? extends Entity > list = worldIn.<Entity>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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing;
|
||||||
|
|
||||||
|
switch (meta & 7)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
enumfacing = EnumFacing.DOWN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
enumfacing = EnumFacing.EAST;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
enumfacing = EnumFacing.WEST;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
enumfacing = EnumFacing.SOUTH;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
enumfacing = EnumFacing.NORTH;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
default:
|
||||||
|
enumfacing = EnumFacing.UP;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState().withProperty(FACING, enumfacing).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
switch ((EnumFacing)state.getValue(FACING))
|
||||||
|
{
|
||||||
|
case EAST:
|
||||||
|
i = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
i = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
i = 3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
i = 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UP:
|
||||||
|
default:
|
||||||
|
i = 5;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DOWN:
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, POWERED});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
public class BlockButtonStone extends BlockButton
|
||||||
|
{
|
||||||
|
protected BlockButtonStone()
|
||||||
|
{
|
||||||
|
super(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
public class BlockButtonWood extends BlockButton
|
||||||
|
{
|
||||||
|
protected BlockButtonWood()
|
||||||
|
{
|
||||||
|
super(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
151
client/src/main/java/net/minecraft/block/BlockCactus.java
Normal file
151
client/src/main/java/net/minecraft/block/BlockCactus.java
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.DamageSource;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockCactus extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15);
|
||||||
|
|
||||||
|
protected BlockCactus()
|
||||||
|
{
|
||||||
|
super(Material.cactus);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.up();
|
||||||
|
|
||||||
|
if (worldIn.isAirBlock(blockpos))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 1; worldIn.getBlockState(pos.down(i)).getBlock() == this; ++i)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < 3)
|
||||||
|
{
|
||||||
|
int j = ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
|
||||||
|
if (j == 15)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos, this.getDefaultState());
|
||||||
|
IBlockState iblockstate = state.withProperty(AGE, Integer.valueOf(0));
|
||||||
|
worldIn.setBlockState(pos, iblockstate, 4);
|
||||||
|
this.onNeighborBlockChange(worldIn, blockpos, iblockstate, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
float f = 0.0625F;
|
||||||
|
return new AxisAlignedBB((double)((float)pos.getX() + f), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)((float)(pos.getY() + 1) - f), (double)((float)(pos.getZ() + 1) - f));
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
float f = 0.0625F;
|
||||||
|
return new AxisAlignedBB((double)((float)pos.getX() + f), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)(pos.getY() + 1), (double)((float)(pos.getZ() + 1) - f));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return super.canPlaceBlockAt(worldIn, pos) ? this.canBlockStay(worldIn, pos) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!this.canBlockStay(worldIn, pos))
|
||||||
|
{
|
||||||
|
worldIn.destroyBlock(pos, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBlockStay(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getMaterial().isSolid())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = worldIn.getBlockState(pos.down()).getBlock();
|
||||||
|
return block == Blocks.cactus || block == Blocks.sand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called When an Entity Collided with the Block
|
||||||
|
*/
|
||||||
|
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
|
||||||
|
{
|
||||||
|
entityIn.attackEntityFrom(DamageSource.cactus, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {AGE});
|
||||||
|
}
|
||||||
|
}
|
||||||
182
client/src/main/java/net/minecraft/block/BlockCake.java
Normal file
182
client/src/main/java/net/minecraft/block/BlockCake.java
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.stats.StatList;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockCake extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyInteger BITES = PropertyInteger.create("bites", 0, 6);
|
||||||
|
|
||||||
|
protected BlockCake()
|
||||||
|
{
|
||||||
|
super(Material.cake);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(BITES, Integer.valueOf(0)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
float f = 0.0625F;
|
||||||
|
float f1 = (float)(1 + ((Integer)worldIn.getBlockState(pos).getValue(BITES)).intValue() * 2) / 16.0F;
|
||||||
|
float f2 = 0.5F;
|
||||||
|
this.setBlockBounds(f1, 0.0F, f, 1.0F - f, f2, 1.0F - f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
float f = 0.0625F;
|
||||||
|
float f1 = 0.5F;
|
||||||
|
this.setBlockBounds(f, 0.0F, f, 1.0F - f, f1, 1.0F - f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
float f = 0.0625F;
|
||||||
|
float f1 = (float)(1 + ((Integer)state.getValue(BITES)).intValue() * 2) / 16.0F;
|
||||||
|
float f2 = 0.5F;
|
||||||
|
return new AxisAlignedBB((double)((float)pos.getX() + f1), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)((float)pos.getY() + f2), (double)((float)(pos.getZ() + 1) - f));
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return this.getCollisionBoundingBox(worldIn, pos, worldIn.getBlockState(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
this.eatCake(worldIn, pos, state, playerIn);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn)
|
||||||
|
{
|
||||||
|
this.eatCake(worldIn, pos, worldIn.getBlockState(pos), playerIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void eatCake(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
|
||||||
|
{
|
||||||
|
if (player.canEat(false))
|
||||||
|
{
|
||||||
|
player.triggerAchievement(StatList.field_181724_H);
|
||||||
|
player.getFoodStats().addStats(2, 0.1F);
|
||||||
|
int i = ((Integer)state.getValue(BITES)).intValue();
|
||||||
|
|
||||||
|
if (i < 6)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return super.canPlaceBlockAt(worldIn, pos) ? this.canBlockStay(worldIn, pos) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!this.canBlockStay(worldIn, pos))
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canBlockStay(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Items.cake;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(BITES, Integer.valueOf(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(BITES)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {BITES});
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return (7 - ((Integer)worldIn.getBlockState(pos).getValue(BITES)).intValue()) * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
151
client/src/main/java/net/minecraft/block/BlockCarpet.java
Normal file
151
client/src/main/java/net/minecraft/block/BlockCarpet.java
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.item.EnumDyeColor;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockCarpet extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<EnumDyeColor> COLOR = PropertyEnum.<EnumDyeColor>create("color", EnumDyeColor.class);
|
||||||
|
|
||||||
|
protected BlockCarpet()
|
||||||
|
{
|
||||||
|
super(Material.carpet);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumDyeColor.WHITE));
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
this.setBlockBoundsFromMeta(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumDyeColor)state.getValue(COLOR)).getMapColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
this.setBlockBoundsFromMeta(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsFromMeta(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setBlockBoundsFromMeta(int meta)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
float f = (float)(1 * (1 + i)) / 16.0F;
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return super.canPlaceBlockAt(worldIn, pos) && this.canBlockStay(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
this.checkForDrop(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (!this.canBlockStay(worldIn, pos))
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canBlockStay(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return !worldIn.isAirBlock(pos.down());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return side == EnumFacing.UP ? true : super.shouldSideBeRendered(worldIn, pos, side);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumDyeColor)state.getValue(COLOR)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 16; ++i)
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumDyeColor)state.getValue(COLOR)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {COLOR});
|
||||||
|
}
|
||||||
|
}
|
||||||
17
client/src/main/java/net/minecraft/block/BlockCarrot.java
Normal file
17
client/src/main/java/net/minecraft/block/BlockCarrot.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
public class BlockCarrot extends BlockCrops
|
||||||
|
{
|
||||||
|
protected Item getSeed()
|
||||||
|
{
|
||||||
|
return Items.carrot;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Item getCrop()
|
||||||
|
{
|
||||||
|
return Items.carrot;
|
||||||
|
}
|
||||||
|
}
|
||||||
283
client/src/main/java/net/minecraft/block/BlockCauldron.java
Normal file
283
client/src/main/java/net/minecraft/block/BlockCauldron.java
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.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;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockCauldron extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 3);
|
||||||
|
|
||||||
|
public BlockCauldron()
|
||||||
|
{
|
||||||
|
super(Material.iron, MapColor.stoneColor);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(LEVEL, Integer.valueOf(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
float f = 0.125F;
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBoundsForItemRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called When an Entity Collided with the Block
|
||||||
|
*/
|
||||||
|
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(LEVEL)).intValue();
|
||||||
|
float f = (float)pos.getY() + (6.0F + (float)(3 * i)) / 16.0F;
|
||||||
|
|
||||||
|
if (!worldIn.isRemote && entityIn.isBurning() && i > 0 && entityIn.getEntityBoundingBox().minY <= (double)f)
|
||||||
|
{
|
||||||
|
entityIn.extinguish();
|
||||||
|
this.setWaterLevel(worldIn, pos, state, i - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ItemStack itemstack = playerIn.inventory.getCurrentItem();
|
||||||
|
|
||||||
|
if (itemstack == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(LEVEL)).intValue();
|
||||||
|
Item item = itemstack.getItem();
|
||||||
|
|
||||||
|
if (item == Items.water_bucket)
|
||||||
|
{
|
||||||
|
if (i < 3)
|
||||||
|
{
|
||||||
|
if (!playerIn.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
|
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, new ItemStack(Items.bucket));
|
||||||
|
}
|
||||||
|
|
||||||
|
playerIn.triggerAchievement(StatList.field_181725_I);
|
||||||
|
this.setWaterLevel(worldIn, pos, state, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item == Items.glass_bottle)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
if (!playerIn.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
|
ItemStack itemstack2 = new ItemStack(Items.potionitem, 1, 0);
|
||||||
|
|
||||||
|
if (!playerIn.inventory.addItemStackToInventory(itemstack2))
|
||||||
|
{
|
||||||
|
worldIn.spawnEntityInWorld(new EntityItem(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 1.5D, (double)pos.getZ() + 0.5D, itemstack2));
|
||||||
|
}
|
||||||
|
else if (playerIn instanceof EntityPlayerMP)
|
||||||
|
{
|
||||||
|
((EntityPlayerMP)playerIn).sendContainerToPlayer(playerIn.inventoryContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerIn.triggerAchievement(StatList.field_181726_J);
|
||||||
|
--itemstack.stackSize;
|
||||||
|
|
||||||
|
if (itemstack.stackSize <= 0)
|
||||||
|
{
|
||||||
|
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setWaterLevel(worldIn, pos, state, 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(worldIn, pos, state, i - 1);
|
||||||
|
playerIn.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 && !playerIn.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
|
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, itemstack1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!playerIn.inventory.addItemStackToInventory(itemstack1))
|
||||||
|
{
|
||||||
|
worldIn.spawnEntityInWorld(new EntityItem(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 1.5D, (double)pos.getZ() + 0.5D, itemstack1));
|
||||||
|
}
|
||||||
|
else if (playerIn instanceof EntityPlayerMP)
|
||||||
|
{
|
||||||
|
((EntityPlayerMP)playerIn).sendContainerToPlayer(playerIn.inventoryContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerIn.triggerAchievement(StatList.field_181728_L);
|
||||||
|
|
||||||
|
if (!playerIn.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
|
--itemstack.stackSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!playerIn.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
|
this.setWaterLevel(worldIn, pos, state, i - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWaterLevel(World worldIn, BlockPos pos, IBlockState state, int level)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(LEVEL, Integer.valueOf(MathHelper.clamp_int(level, 0, 3))), 2);
|
||||||
|
worldIn.updateComparatorOutputLevel(pos, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called similar to random ticks, but only when it is raining.
|
||||||
|
*/
|
||||||
|
public void fillWithRain(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (worldIn.rand.nextInt(20) == 1)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (((Integer)iblockstate.getValue(LEVEL)).intValue() < 3)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, iblockstate.cycleProperty(LEVEL), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Items.cauldron;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Items.cauldron;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return ((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(LEVEL, Integer.valueOf(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(LEVEL)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {LEVEL});
|
||||||
|
}
|
||||||
|
}
|
||||||
609
client/src/main/java/net/minecraft/block/BlockChest.java
Normal file
609
client/src/main/java/net/minecraft/block/BlockChest.java
Normal file
@@ -0,0 +1,609 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.passive.EntityOcelot;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
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;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.ILockableContainer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockChest extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
|
||||||
|
/** 0 : Normal chest, 1 : Trapped chest */
|
||||||
|
public final int chestType;
|
||||||
|
|
||||||
|
protected BlockChest(int type)
|
||||||
|
{
|
||||||
|
super(Material.wood);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||||
|
this.chestType = type;
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(pos.north()).getBlock() == this)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
|
||||||
|
}
|
||||||
|
else if (worldIn.getBlockState(pos.south()).getBlock() == this)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
|
||||||
|
}
|
||||||
|
else if (worldIn.getBlockState(pos.west()).getBlock() == this)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||||
|
}
|
||||||
|
else if (worldIn.getBlockState(pos.east()).getBlock() == this)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.checkForSurroundingChests(worldIn, pos, state);
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.offset(enumfacing);
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
this.checkForSurroundingChests(worldIn, blockpos, iblockstate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = EnumFacing.getHorizontal(MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3).getOpposite();
|
||||||
|
state = state.withProperty(FACING, enumfacing);
|
||||||
|
BlockPos blockpos = pos.north();
|
||||||
|
BlockPos blockpos1 = pos.south();
|
||||||
|
BlockPos blockpos2 = pos.west();
|
||||||
|
BlockPos blockpos3 = pos.east();
|
||||||
|
boolean flag = this == worldIn.getBlockState(blockpos).getBlock();
|
||||||
|
boolean flag1 = this == worldIn.getBlockState(blockpos1).getBlock();
|
||||||
|
boolean flag2 = this == worldIn.getBlockState(blockpos2).getBlock();
|
||||||
|
boolean flag3 = this == worldIn.getBlockState(blockpos3).getBlock();
|
||||||
|
|
||||||
|
if (!flag && !flag1 && !flag2 && !flag3)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state, 3);
|
||||||
|
}
|
||||||
|
else if (enumfacing.getAxis() != EnumFacing.Axis.X || !flag && !flag1)
|
||||||
|
{
|
||||||
|
if (enumfacing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3))
|
||||||
|
{
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos2, state, 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos3, state, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.setBlockState(pos, state, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos, state, 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos1, state, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.setBlockState(pos, state, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.hasDisplayName())
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityChest)
|
||||||
|
{
|
||||||
|
((TileEntityChest)tileentity).setCustomName(stack.getDisplayName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockState checkForSurroundingChests(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockState correctFacing(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = null;
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos.offset(enumfacing1));
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iblockstate.getBlock().isFullBlock())
|
||||||
|
{
|
||||||
|
if (enumfacing != null)
|
||||||
|
{
|
||||||
|
enumfacing = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
enumfacing = enumfacing1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enumfacing != null)
|
||||||
|
{
|
||||||
|
return state.withProperty(FACING, enumfacing.getOpposite());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing2 = (EnumFacing)state.getValue(FACING);
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
|
||||||
|
{
|
||||||
|
enumfacing2 = enumfacing2.getOpposite();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
|
||||||
|
{
|
||||||
|
enumfacing2 = enumfacing2.rotateY();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
|
||||||
|
{
|
||||||
|
enumfacing2 = enumfacing2.getOpposite();
|
||||||
|
}
|
||||||
|
|
||||||
|
return state.withProperty(FACING, enumfacing2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
BlockPos blockpos = pos.west();
|
||||||
|
BlockPos blockpos1 = pos.east();
|
||||||
|
BlockPos blockpos2 = pos.north();
|
||||||
|
BlockPos blockpos3 = pos.south();
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(blockpos).getBlock() == this)
|
||||||
|
{
|
||||||
|
if (this.isDoubleChest(worldIn, blockpos))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(blockpos1).getBlock() == this)
|
||||||
|
{
|
||||||
|
if (this.isDoubleChest(worldIn, blockpos1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(blockpos2).getBlock() == this)
|
||||||
|
{
|
||||||
|
if (this.isDoubleChest(worldIn, blockpos2))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(blockpos3).getBlock() == this)
|
||||||
|
{
|
||||||
|
if (this.isDoubleChest(worldIn, blockpos3))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i <= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isDoubleChest(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(pos).getBlock() != this)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() == this)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityChest)
|
||||||
|
{
|
||||||
|
tileentity.updateContainingBlockInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof IInventory)
|
||||||
|
{
|
||||||
|
InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity);
|
||||||
|
worldIn.updateComparatorOutputLevel(pos, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
|
||||||
|
|
||||||
|
if (ilockablecontainer != null)
|
||||||
|
{
|
||||||
|
playerIn.displayGUIChest(ilockablecontainer);
|
||||||
|
|
||||||
|
if (this.chestType == 0)
|
||||||
|
{
|
||||||
|
playerIn.triggerAchievement(StatList.field_181723_aa);
|
||||||
|
}
|
||||||
|
else if (this.chestType == 1)
|
||||||
|
{
|
||||||
|
playerIn.triggerAchievement(StatList.field_181737_U);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILockableContainer getLockableContainer(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (!(tileentity instanceof TileEntityChest))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ILockableContainer ilockablecontainer = (TileEntityChest)tileentity;
|
||||||
|
|
||||||
|
if (this.isBlocked(worldIn, pos))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.offset(enumfacing);
|
||||||
|
Block block = worldIn.getBlockState(blockpos).getBlock();
|
||||||
|
|
||||||
|
if (block == this)
|
||||||
|
{
|
||||||
|
if (this.isBlocked(worldIn, blockpos))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
TileEntity tileentity1 = worldIn.getTileEntity(blockpos);
|
||||||
|
|
||||||
|
if (tileentity1 instanceof TileEntityChest)
|
||||||
|
{
|
||||||
|
if (enumfacing != EnumFacing.WEST && enumfacing != EnumFacing.NORTH)
|
||||||
|
{
|
||||||
|
ilockablecontainer = new InventoryLargeChest("container.chestDouble", ilockablecontainer, (TileEntityChest)tileentity1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ilockablecontainer = new InventoryLargeChest("container.chestDouble", (TileEntityChest)tileentity1, ilockablecontainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ilockablecontainer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityChest();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||||
|
*/
|
||||||
|
public boolean canProvidePower()
|
||||||
|
{
|
||||||
|
return this.chestType == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
if (!this.canProvidePower())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityChest)
|
||||||
|
{
|
||||||
|
i = ((TileEntityChest)tileentity).numPlayersUsing;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MathHelper.clamp_int(i, 0, 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
return side == EnumFacing.UP ? this.getWeakPower(worldIn, pos, state, side) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isBlocked(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return this.isBelowSolidBlock(worldIn, pos) || this.isOcelotSittingOnChest(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isBelowSolidBlock(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos.up()).getBlock().isNormalCube();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isOcelotSittingOnChest(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
for (Entity entity : worldIn.getEntitiesWithinAABB(EntityOcelot.class, new AxisAlignedBB((double)pos.getX(), (double)(pos.getY() + 1), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 2), (double)(pos.getZ() + 1))))
|
||||||
|
{
|
||||||
|
EntityOcelot entityocelot = (EntityOcelot)entity;
|
||||||
|
|
||||||
|
if (entityocelot.isSitting())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Container.calcRedstoneFromInventory(this.getLockableContainer(worldIn, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = EnumFacing.getFront(meta);
|
||||||
|
|
||||||
|
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
|
||||||
|
{
|
||||||
|
enumfacing = EnumFacing.NORTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState().withProperty(FACING, enumfacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING});
|
||||||
|
}
|
||||||
|
}
|
||||||
33
client/src/main/java/net/minecraft/block/BlockClay.java
Normal file
33
client/src/main/java/net/minecraft/block/BlockClay.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
public class BlockClay extends Block
|
||||||
|
{
|
||||||
|
public BlockClay()
|
||||||
|
{
|
||||||
|
super(Material.clay);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Items.clay_ball;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
226
client/src/main/java/net/minecraft/block/BlockCocoa.java
Normal file
226
client/src/main/java/net/minecraft/block/BlockCocoa.java
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.EnumDyeColor;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockCocoa extends BlockDirectional implements IGrowable
|
||||||
|
{
|
||||||
|
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 2);
|
||||||
|
|
||||||
|
public BlockCocoa()
|
||||||
|
{
|
||||||
|
super(Material.plants);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(AGE, Integer.valueOf(0)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (!this.canBlockStay(worldIn, pos, state))
|
||||||
|
{
|
||||||
|
this.dropBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
else if (worldIn.rand.nextInt(5) == 0)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
|
||||||
|
if (i < 2)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i + 1)), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
pos = pos.offset((EnumFacing)state.getValue(FACING));
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
return iblockstate.getBlock() == Blocks.log && iblockstate.getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
return super.getCollisionBoundingBox(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
return super.getSelectedBoundingBox(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("incomplete-switch")
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
EnumFacing enumfacing = (EnumFacing)iblockstate.getValue(FACING);
|
||||||
|
int i = ((Integer)iblockstate.getValue(AGE)).intValue();
|
||||||
|
int j = 4 + i * 2;
|
||||||
|
int k = 5 + i * 2;
|
||||||
|
float f = (float)j / 2.0F;
|
||||||
|
|
||||||
|
switch (enumfacing)
|
||||||
|
{
|
||||||
|
case SOUTH:
|
||||||
|
this.setBlockBounds((8.0F - f) / 16.0F, (12.0F - (float)k) / 16.0F, (15.0F - (float)j) / 16.0F, (8.0F + f) / 16.0F, 0.75F, 0.9375F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
this.setBlockBounds((8.0F - f) / 16.0F, (12.0F - (float)k) / 16.0F, 0.0625F, (8.0F + f) / 16.0F, 0.75F, (1.0F + (float)j) / 16.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
this.setBlockBounds(0.0625F, (12.0F - (float)k) / 16.0F, (8.0F - f) / 16.0F, (1.0F + (float)j) / 16.0F, 0.75F, (8.0F + f) / 16.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EAST:
|
||||||
|
this.setBlockBounds((15.0F - (float)j) / 16.0F, (12.0F - (float)k) / 16.0F, (8.0F - f) / 16.0F, 0.9375F, 0.75F, (8.0F + f) / 16.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = EnumFacing.fromAngle((double)placer.rotationYaw);
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
if (!facing.getAxis().isHorizontal())
|
||||||
|
{
|
||||||
|
facing = EnumFacing.NORTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState().withProperty(FACING, facing.getOpposite()).withProperty(AGE, Integer.valueOf(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!this.canBlockStay(worldIn, pos, state))
|
||||||
|
{
|
||||||
|
this.dropBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dropBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.air.getDefaultState(), 3);
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
int j = 1;
|
||||||
|
|
||||||
|
if (i >= 2)
|
||||||
|
{
|
||||||
|
j = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k = 0; k < j; ++k)
|
||||||
|
{
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(Items.dye, 1, EnumDyeColor.BROWN.getDyeDamage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Items.dye;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDamageValue(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return EnumDyeColor.BROWN.getDyeDamage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this IGrowable can grow
|
||||||
|
*/
|
||||||
|
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(AGE)).intValue() < 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(((Integer)state.getValue(AGE)).intValue() + 1)), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(AGE, Integer.valueOf((meta & 15) >> 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
|
||||||
|
i = i | ((Integer)state.getValue(AGE)).intValue() << 2;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, AGE});
|
||||||
|
}
|
||||||
|
}
|
||||||
74
client/src/main/java/net/minecraft/block/BlockColored.java
Normal file
74
client/src/main/java/net/minecraft/block/BlockColored.java
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.item.EnumDyeColor;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class BlockColored extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<EnumDyeColor> COLOR = PropertyEnum.<EnumDyeColor>create("color", EnumDyeColor.class);
|
||||||
|
|
||||||
|
public BlockColored(Material materialIn)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumDyeColor.WHITE));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumDyeColor)state.getValue(COLOR)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
for (EnumDyeColor enumdyecolor : EnumDyeColor.values())
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, enumdyecolor.getMetadata()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumDyeColor)state.getValue(COLOR)).getMapColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumDyeColor)state.getValue(COLOR)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {COLOR});
|
||||||
|
}
|
||||||
|
}
|
||||||
171
client/src/main/java/net/minecraft/block/BlockCommandBlock.java
Normal file
171
client/src/main/java/net/minecraft/block/BlockCommandBlock.java
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.command.server.CommandBlockLogic;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityCommandBlock;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockCommandBlock extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyBool TRIGGERED = PropertyBool.create("triggered");
|
||||||
|
|
||||||
|
public BlockCommandBlock()
|
||||||
|
{
|
||||||
|
super(Material.iron, MapColor.adobeColor);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(TRIGGERED, Boolean.valueOf(false)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityCommandBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
boolean flag = worldIn.isBlockPowered(pos);
|
||||||
|
boolean flag1 = ((Boolean)state.getValue(TRIGGERED)).booleanValue();
|
||||||
|
|
||||||
|
if (flag && !flag1)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||||
|
}
|
||||||
|
else if (!flag && flag1)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityCommandBlock)
|
||||||
|
{
|
||||||
|
((TileEntityCommandBlock)tileentity).getCommandBlockLogic().trigger(worldIn);
|
||||||
|
worldIn.updateComparatorOutputLevel(pos, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many world ticks before ticking
|
||||||
|
*/
|
||||||
|
public int tickRate(World worldIn)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
return tileentity instanceof TileEntityCommandBlock ? ((TileEntityCommandBlock)tileentity).getCommandBlockLogic().tryOpenEditCommandBlock(playerIn) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
return tileentity instanceof TileEntityCommandBlock ? ((TileEntityCommandBlock)tileentity).getCommandBlockLogic().getSuccessCount() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityCommandBlock)
|
||||||
|
{
|
||||||
|
CommandBlockLogic commandblocklogic = ((TileEntityCommandBlock)tileentity).getCommandBlockLogic();
|
||||||
|
|
||||||
|
if (stack.hasDisplayName())
|
||||||
|
{
|
||||||
|
commandblocklogic.setName(stack.getDisplayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
commandblocklogic.setTrackOutput(worldIn.getGameRules().getBoolean("sendCommandFeedback"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(TRIGGERED, Boolean.valueOf((meta & 1) > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(TRIGGERED)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {TRIGGERED});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(TRIGGERED, Boolean.valueOf(false));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
|
public class BlockCompressedPowered extends Block
|
||||||
|
{
|
||||||
|
public BlockCompressedPowered(Material p_i46386_1_, MapColor p_i46386_2_)
|
||||||
|
{
|
||||||
|
super(p_i46386_1_, p_i46386_2_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||||
|
*/
|
||||||
|
public boolean canProvidePower()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
57
client/src/main/java/net/minecraft/block/BlockContainer.java
Normal file
57
client/src/main/java/net/minecraft/block/BlockContainer.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public abstract class BlockContainer extends Block implements ITileEntityProvider
|
||||||
|
{
|
||||||
|
protected BlockContainer(Material materialIn)
|
||||||
|
{
|
||||||
|
this(materialIn, materialIn.getMaterialMapColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockContainer(Material p_i46402_1_, MapColor p_i46402_2_)
|
||||||
|
{
|
||||||
|
super(p_i46402_1_, p_i46402_2_);
|
||||||
|
this.isBlockContainer = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean func_181086_a(World p_181086_1_, BlockPos p_181086_2_, EnumFacing p_181086_3_)
|
||||||
|
{
|
||||||
|
return p_181086_1_.getBlockState(p_181086_2_.offset(p_181086_3_)).getBlock().getMaterial() == Material.cactus;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean func_181087_e(World p_181087_1_, BlockPos p_181087_2_)
|
||||||
|
{
|
||||||
|
return this.func_181086_a(p_181087_1_, p_181087_2_, EnumFacing.NORTH) || this.func_181086_a(p_181087_1_, p_181087_2_, EnumFacing.SOUTH) || this.func_181086_a(p_181087_1_, p_181087_2_, EnumFacing.WEST) || this.func_181086_a(p_181087_1_, p_181087_2_, EnumFacing.EAST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
worldIn.removeTileEntity(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on both Client and Server when World#addBlockEvent is called
|
||||||
|
*/
|
||||||
|
public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam)
|
||||||
|
{
|
||||||
|
super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam);
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
220
client/src/main/java/net/minecraft/block/BlockCrops.java
Normal file
220
client/src/main/java/net/minecraft/block/BlockCrops.java
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.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;
|
||||||
|
|
||||||
|
public class BlockCrops extends BlockBush implements IGrowable
|
||||||
|
{
|
||||||
|
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 7);
|
||||||
|
|
||||||
|
protected BlockCrops()
|
||||||
|
{
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
float f = 0.5F;
|
||||||
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
|
||||||
|
this.setCreativeTab((CreativeTabs)null);
|
||||||
|
this.setHardness(0.0F);
|
||||||
|
this.setStepSound(soundTypeGrass);
|
||||||
|
this.disableStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is the block grass, dirt or farmland
|
||||||
|
*/
|
||||||
|
protected boolean canPlaceBlockOn(Block ground)
|
||||||
|
{
|
||||||
|
return ground == Blocks.farmland;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
super.updateTick(worldIn, pos, state, rand);
|
||||||
|
|
||||||
|
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
|
||||||
|
if (i < 7)
|
||||||
|
{
|
||||||
|
float f = getGrowthChance(this, worldIn, pos);
|
||||||
|
|
||||||
|
if (rand.nextInt((int)(25.0F / f) + 1) == 0)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i + 1)), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void grow(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(AGE)).intValue() + MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
|
||||||
|
|
||||||
|
if (i > 7)
|
||||||
|
{
|
||||||
|
i = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i)), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
float f = 1.0F;
|
||||||
|
BlockPos blockpos = pos.down();
|
||||||
|
|
||||||
|
for (int i = -1; i <= 1; ++i)
|
||||||
|
{
|
||||||
|
for (int j = -1; j <= 1; ++j)
|
||||||
|
{
|
||||||
|
float f1 = 0.0F;
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == Blocks.farmland)
|
||||||
|
{
|
||||||
|
f1 = 1.0F;
|
||||||
|
|
||||||
|
if (((Integer)iblockstate.getValue(BlockFarmland.MOISTURE)).intValue() > 0)
|
||||||
|
{
|
||||||
|
f1 = 3.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != 0 || j != 0)
|
||||||
|
{
|
||||||
|
f1 /= 4.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
f += f1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockPos blockpos1 = pos.north();
|
||||||
|
BlockPos blockpos2 = pos.south();
|
||||||
|
BlockPos blockpos3 = pos.west();
|
||||||
|
BlockPos blockpos4 = pos.east();
|
||||||
|
boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock();
|
||||||
|
boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock();
|
||||||
|
|
||||||
|
if (flag && flag1)
|
||||||
|
{
|
||||||
|
f /= 2.0F;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();
|
||||||
|
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
f /= 2.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Item getSeed()
|
||||||
|
{
|
||||||
|
return Items.wheat_seeds;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Item getCrop()
|
||||||
|
{
|
||||||
|
return Items.wheat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, 0);
|
||||||
|
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
|
||||||
|
if (i >= 7)
|
||||||
|
{
|
||||||
|
int j = 3 + fortune;
|
||||||
|
|
||||||
|
for (int k = 0; k < j; ++k)
|
||||||
|
{
|
||||||
|
if (worldIn.rand.nextInt(15) <= i)
|
||||||
|
{
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(this.getSeed(), 1, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(AGE)).intValue() == 7 ? this.getCrop() : this.getSeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return this.getSeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this IGrowable can grow
|
||||||
|
*/
|
||||||
|
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(AGE)).intValue() < 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.grow(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {AGE});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityDaylightDetector;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.EnumSkyBlock;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockDaylightDetector extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 15);
|
||||||
|
private final boolean inverted;
|
||||||
|
|
||||||
|
public BlockDaylightDetector(boolean inverted)
|
||||||
|
{
|
||||||
|
super(Material.wood);
|
||||||
|
this.inverted = inverted;
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(POWER, Integer.valueOf(0)));
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||||
|
this.setHardness(0.2F);
|
||||||
|
this.setStepSound(soundTypeWood);
|
||||||
|
this.setUnlocalizedName("daylightDetector");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(POWER)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePower(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (!worldIn.provider.getHasNoSky())
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted();
|
||||||
|
float f = worldIn.getCelestialAngleRadians(1.0F);
|
||||||
|
float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
|
||||||
|
f = f + (f1 - f) * 0.2F;
|
||||||
|
i = Math.round((float)i * MathHelper.cos(f));
|
||||||
|
i = MathHelper.clamp_int(i, 0, 15);
|
||||||
|
|
||||||
|
if (this.inverted)
|
||||||
|
{
|
||||||
|
i = 15 - i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((Integer)iblockstate.getValue(POWER)).intValue() != i)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (playerIn.isAllowEdit())
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this.inverted)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.daylight_detector.getDefaultState().withProperty(POWER, state.getValue(POWER)), 4);
|
||||||
|
Blocks.daylight_detector.updatePower(worldIn, pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.daylight_detector_inverted.getDefaultState().withProperty(POWER, state.getValue(POWER)), 4);
|
||||||
|
Blocks.daylight_detector_inverted.updatePower(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(Blocks.daylight_detector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(Blocks.daylight_detector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||||
|
*/
|
||||||
|
public boolean canProvidePower()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityDaylightDetector();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(POWER, Integer.valueOf(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(POWER)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {POWER});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
if (!this.inverted)
|
||||||
|
{
|
||||||
|
super.getSubBlocks(itemIn, tab, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
70
client/src/main/java/net/minecraft/block/BlockDeadBush.java
Normal file
70
client/src/main/java/net/minecraft/block/BlockDeadBush.java
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class BlockDeadBush extends BlockBush
|
||||||
|
{
|
||||||
|
protected BlockDeadBush()
|
||||||
|
{
|
||||||
|
super(Material.vine);
|
||||||
|
float f = 0.4F;
|
||||||
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return MapColor.woodColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is the block grass, dirt or farmland
|
||||||
|
*/
|
||||||
|
protected boolean canPlaceBlockOn(Block ground)
|
||||||
|
{
|
||||||
|
return ground == Blocks.sand || ground == Blocks.hardened_clay || ground == Blocks.stained_hardened_clay || ground == Blocks.dirt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this Block can be replaced directly by other blocks (true for e.g. tall grass)
|
||||||
|
*/
|
||||||
|
public boolean isReplaceable(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
|
||||||
|
{
|
||||||
|
player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(Blocks.deadbush, 1, 0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
super.harvestBlock(worldIn, player, pos, state, te);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
|
public abstract class BlockDirectional extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
|
||||||
|
protected BlockDirectional(Material materialIn)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockDirectional(Material p_i46398_1_, MapColor p_i46398_2_)
|
||||||
|
{
|
||||||
|
super(p_i46398_1_, p_i46398_2_);
|
||||||
|
}
|
||||||
|
}
|
||||||
175
client/src/main/java/net/minecraft/block/BlockDirt.java
Normal file
175
client/src/main/java/net/minecraft/block/BlockDirt.java
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
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.IStringSerializable;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockDirt extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockDirt.DirtType> VARIANT = PropertyEnum.<BlockDirt.DirtType>create("variant", BlockDirt.DirtType.class);
|
||||||
|
public static final PropertyBool SNOWY = PropertyBool.create("snowy");
|
||||||
|
|
||||||
|
protected BlockDirt()
|
||||||
|
{
|
||||||
|
super(Material.ground);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockDirt.DirtType.DIRT).withProperty(SNOWY, Boolean.valueOf(false)));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockDirt.DirtType)state.getValue(VARIANT)).func_181066_d();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (state.getValue(VARIANT) == BlockDirt.DirtType.PODZOL)
|
||||||
|
{
|
||||||
|
Block block = worldIn.getBlockState(pos.up()).getBlock();
|
||||||
|
state = state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer));
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(this, 1, BlockDirt.DirtType.DIRT.getMetadata()));
|
||||||
|
list.add(new ItemStack(this, 1, BlockDirt.DirtType.COARSE_DIRT.getMetadata()));
|
||||||
|
list.add(new ItemStack(this, 1, BlockDirt.DirtType.PODZOL.getMetadata()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDamageValue(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
return iblockstate.getBlock() != this ? 0 : ((BlockDirt.DirtType)iblockstate.getValue(VARIANT)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(VARIANT, BlockDirt.DirtType.byMetadata(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockDirt.DirtType)state.getValue(VARIANT)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {VARIANT, SNOWY});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
BlockDirt.DirtType blockdirt$dirttype = (BlockDirt.DirtType)state.getValue(VARIANT);
|
||||||
|
|
||||||
|
if (blockdirt$dirttype == BlockDirt.DirtType.PODZOL)
|
||||||
|
{
|
||||||
|
blockdirt$dirttype = BlockDirt.DirtType.DIRT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return blockdirt$dirttype.getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum DirtType implements IStringSerializable
|
||||||
|
{
|
||||||
|
DIRT(0, "dirt", "default", MapColor.dirtColor),
|
||||||
|
COARSE_DIRT(1, "coarse_dirt", "coarse", MapColor.dirtColor),
|
||||||
|
PODZOL(2, "podzol", MapColor.obsidianColor);
|
||||||
|
|
||||||
|
private static final BlockDirt.DirtType[] METADATA_LOOKUP = new BlockDirt.DirtType[values().length];
|
||||||
|
private final int metadata;
|
||||||
|
private final String name;
|
||||||
|
private final String unlocalizedName;
|
||||||
|
private final MapColor field_181067_h;
|
||||||
|
|
||||||
|
private DirtType(int p_i46396_3_, String p_i46396_4_, MapColor p_i46396_5_)
|
||||||
|
{
|
||||||
|
this(p_i46396_3_, p_i46396_4_, p_i46396_4_, p_i46396_5_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DirtType(int p_i46397_3_, String p_i46397_4_, String p_i46397_5_, MapColor p_i46397_6_)
|
||||||
|
{
|
||||||
|
this.metadata = p_i46397_3_;
|
||||||
|
this.name = p_i46397_4_;
|
||||||
|
this.unlocalizedName = p_i46397_5_;
|
||||||
|
this.field_181067_h = p_i46397_6_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMetadata()
|
||||||
|
{
|
||||||
|
return this.metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnlocalizedName()
|
||||||
|
{
|
||||||
|
return this.unlocalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapColor func_181066_d()
|
||||||
|
{
|
||||||
|
return this.field_181067_h;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockDirt.DirtType byMetadata(int metadata)
|
||||||
|
{
|
||||||
|
if (metadata < 0 || metadata >= METADATA_LOOKUP.length)
|
||||||
|
{
|
||||||
|
metadata = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return METADATA_LOOKUP[metadata];
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (BlockDirt.DirtType blockdirt$dirttype : values())
|
||||||
|
{
|
||||||
|
METADATA_LOOKUP[blockdirt$dirttype.getMetadata()] = blockdirt$dirttype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
303
client/src/main/java/net/minecraft/block/BlockDispenser.java
Normal file
303
client/src/main/java/net/minecraft/block/BlockDispenser.java
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||||
|
import net.minecraft.dispenser.IBehaviorDispenseItem;
|
||||||
|
import net.minecraft.dispenser.IBlockSource;
|
||||||
|
import net.minecraft.dispenser.IPosition;
|
||||||
|
import net.minecraft.dispenser.PositionImpl;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
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;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockDispenser extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing");
|
||||||
|
public static final PropertyBool TRIGGERED = PropertyBool.create("triggered");
|
||||||
|
public static final RegistryDefaulted<Item, IBehaviorDispenseItem> dispenseBehaviorRegistry = new RegistryDefaulted(new BehaviorDefaultDispenseItem());
|
||||||
|
protected Random rand = new Random();
|
||||||
|
|
||||||
|
protected BlockDispenser()
|
||||||
|
{
|
||||||
|
super(Material.rock);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(TRIGGERED, Boolean.valueOf(false)));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many world ticks before ticking
|
||||||
|
*/
|
||||||
|
public int tickRate(World worldIn)
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
super.onBlockAdded(worldIn, pos, state);
|
||||||
|
this.setDefaultDirection(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityDispenser)
|
||||||
|
{
|
||||||
|
playerIn.displayGUIChest((TileEntityDispenser)tileentity);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityDropper)
|
||||||
|
{
|
||||||
|
playerIn.triggerAchievement(StatList.field_181731_O);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerIn.triggerAchievement(StatList.field_181733_Q);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dispense(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
|
||||||
|
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
|
||||||
|
|
||||||
|
if (tileentitydispenser != null)
|
||||||
|
{
|
||||||
|
int i = tileentitydispenser.getDispenseSlot();
|
||||||
|
|
||||||
|
if (i < 0)
|
||||||
|
{
|
||||||
|
worldIn.playAuxSFX(1001, pos, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
|
||||||
|
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);
|
||||||
|
|
||||||
|
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
|
||||||
|
{
|
||||||
|
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
|
||||||
|
tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IBehaviorDispenseItem getBehavior(ItemStack stack)
|
||||||
|
{
|
||||||
|
return (IBehaviorDispenseItem)dispenseBehaviorRegistry.getObject(stack == null ? null : stack.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up());
|
||||||
|
boolean flag1 = ((Boolean)state.getValue(TRIGGERED)).booleanValue();
|
||||||
|
|
||||||
|
if (flag && !flag1)
|
||||||
|
{
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
|
||||||
|
}
|
||||||
|
else if (!flag && flag1)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
this.dispense(worldIn, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityDispenser();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)).withProperty(TRIGGERED, Boolean.valueOf(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)), 2);
|
||||||
|
|
||||||
|
if (stack.hasDisplayName())
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityDispenser)
|
||||||
|
{
|
||||||
|
((TileEntityDispenser)tileentity).setCustomName(stack.getDisplayName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityDispenser)
|
||||||
|
{
|
||||||
|
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityDispenser)tileentity);
|
||||||
|
worldIn.updateComparatorOutputLevel(pos, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the position where the dispenser at the given Coordinates should dispense to.
|
||||||
|
*/
|
||||||
|
public static IPosition getDispensePosition(IBlockSource coords)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = getFacing(coords.getBlockMetadata());
|
||||||
|
double d0 = coords.getX() + 0.7D * (double)enumfacing.getFrontOffsetX();
|
||||||
|
double d1 = coords.getY() + 0.7D * (double)enumfacing.getFrontOffsetY();
|
||||||
|
double d2 = coords.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ();
|
||||||
|
return new PositionImpl(d0, d1, d2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the facing of a dispenser with the given metadata
|
||||||
|
*/
|
||||||
|
public static EnumFacing getFacing(int meta)
|
||||||
|
{
|
||||||
|
return EnumFacing.getFront(meta & 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Container.calcRedstone(worldIn.getTileEntity(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
|
||||||
|
*/
|
||||||
|
public IBlockState getStateForEntityRender(IBlockState state)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, getFacing(meta)).withProperty(TRIGGERED, Boolean.valueOf((meta & 8) > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(TRIGGERED)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, TRIGGERED});
|
||||||
|
}
|
||||||
|
}
|
||||||
477
client/src/main/java/net/minecraft/block/BlockDoor.java
Normal file
477
client/src/main/java/net/minecraft/block/BlockDoor.java
Normal file
@@ -0,0 +1,477 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.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.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockDoor extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
public static final PropertyBool OPEN = PropertyBool.create("open");
|
||||||
|
public static final PropertyEnum<BlockDoor.EnumHingePosition> HINGE = PropertyEnum.<BlockDoor.EnumHingePosition>create("hinge", BlockDoor.EnumHingePosition.class);
|
||||||
|
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||||
|
public static final PropertyEnum<BlockDoor.EnumDoorHalf> HALF = PropertyEnum.<BlockDoor.EnumDoorHalf>create("half", BlockDoor.EnumDoorHalf.class);
|
||||||
|
|
||||||
|
protected BlockDoor(Material materialIn)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(OPEN, Boolean.valueOf(false)).withProperty(HINGE, BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf(false)).withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the localized name of this block. Used for the statistics page.
|
||||||
|
*/
|
||||||
|
public String getLocalizedName()
|
||||||
|
{
|
||||||
|
return StatCollector.translateToLocal((this.getUnlocalizedName() + ".name").replaceAll("tile", "item"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return isOpen(combineMetadata(worldIn, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
return super.getSelectedBoundingBox(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
return super.getCollisionBoundingBox(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBoundBasedOnMeta(combineMetadata(worldIn, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBoundBasedOnMeta(int combinedMeta)
|
||||||
|
{
|
||||||
|
float f = 0.1875F;
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
|
||||||
|
EnumFacing enumfacing = getFacing(combinedMeta);
|
||||||
|
boolean flag = isOpen(combinedMeta);
|
||||||
|
boolean flag1 = isHingeLeft(combinedMeta);
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
if (enumfacing == EnumFacing.EAST)
|
||||||
|
{
|
||||||
|
if (!flag1)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (enumfacing == EnumFacing.SOUTH)
|
||||||
|
{
|
||||||
|
if (!flag1)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (enumfacing == EnumFacing.WEST)
|
||||||
|
{
|
||||||
|
if (!flag1)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (enumfacing == EnumFacing.NORTH)
|
||||||
|
{
|
||||||
|
if (!flag1)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (enumfacing == EnumFacing.EAST)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
else if (enumfacing == EnumFacing.SOUTH)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
|
||||||
|
}
|
||||||
|
else if (enumfacing == EnumFacing.WEST)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
else if (enumfacing == EnumFacing.NORTH)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (this.blockMaterial == Material.iron)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
|
||||||
|
IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() != this)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state = iblockstate.cycleProperty(OPEN);
|
||||||
|
worldIn.setBlockState(blockpos, state, 2);
|
||||||
|
worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
|
||||||
|
worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleDoor(World worldIn, BlockPos pos, boolean open)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = iblockstate.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
|
||||||
|
IBlockState iblockstate1 = pos == blockpos ? iblockstate : worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (iblockstate1.getBlock() == this && ((Boolean)iblockstate1.getValue(OPEN)).booleanValue() != open)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos, iblockstate1.withProperty(OPEN, Boolean.valueOf(open)), 2);
|
||||||
|
worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
|
||||||
|
worldIn.playAuxSFXAtEntity((EntityPlayer)null, open ? 1003 : 1006, pos, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.down();
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() != this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
else if (neighborBlock != this)
|
||||||
|
{
|
||||||
|
this.onNeighborBlockChange(worldIn, blockpos, iblockstate, neighborBlock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boolean flag1 = false;
|
||||||
|
BlockPos blockpos1 = pos.up();
|
||||||
|
IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);
|
||||||
|
|
||||||
|
if (iblockstate1.getBlock() != this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
flag1 = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
flag1 = true;
|
||||||
|
|
||||||
|
if (iblockstate1.getBlock() == this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(blockpos1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag1)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos1);
|
||||||
|
|
||||||
|
if ((flag || neighborBlock.canProvidePower()) && neighborBlock != this && flag != ((Boolean)iblockstate1.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos1, iblockstate1.withProperty(POWERED, Boolean.valueOf(flag)), 2);
|
||||||
|
|
||||||
|
if (flag != ((Boolean)state.getValue(OPEN)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
|
||||||
|
worldIn.markBlockRangeForRenderUpdate(pos, pos);
|
||||||
|
worldIn.playAuxSFXAtEntity((EntityPlayer)null, flag ? 1003 : 1006, pos, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? null : this.getItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
|
||||||
|
*/
|
||||||
|
public MovingObjectPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
return super.collisionRayTrace(worldIn, pos, start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return pos.getY() >= 255 ? false : World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && super.canPlaceBlockAt(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos.up());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMobilityFlag()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int combineMetadata(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
int i = iblockstate.getBlock().getMetaFromState(iblockstate);
|
||||||
|
boolean flag = isTop(i);
|
||||||
|
IBlockState iblockstate1 = worldIn.getBlockState(pos.down());
|
||||||
|
int j = iblockstate1.getBlock().getMetaFromState(iblockstate1);
|
||||||
|
int k = flag ? j : i;
|
||||||
|
IBlockState iblockstate2 = worldIn.getBlockState(pos.up());
|
||||||
|
int l = iblockstate2.getBlock().getMetaFromState(iblockstate2);
|
||||||
|
int i1 = flag ? i : l;
|
||||||
|
boolean flag1 = (i1 & 1) != 0;
|
||||||
|
boolean flag2 = (i1 & 2) != 0;
|
||||||
|
return removeHalfBit(k) | (flag ? 8 : 0) | (flag1 ? 16 : 0) | (flag2 ? 32 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return this.getItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Item getItem()
|
||||||
|
{
|
||||||
|
return this == Blocks.iron_door ? Items.iron_door : (this == Blocks.spruce_door ? Items.spruce_door : (this == Blocks.birch_door ? Items.birch_door : (this == Blocks.jungle_door ? Items.jungle_door : (this == Blocks.acacia_door ? Items.acacia_door : (this == Blocks.dark_oak_door ? Items.dark_oak_door : Items.oak_door)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.down();
|
||||||
|
|
||||||
|
if (player.capabilities.isCreativeMode && state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER && worldIn.getBlockState(blockpos).getBlock() == this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(blockpos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos.up());
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
state = state.withProperty(HINGE, iblockstate.getValue(HINGE)).withProperty(POWERED, iblockstate.getValue(POWERED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IBlockState iblockstate1 = worldIn.getBlockState(pos.down());
|
||||||
|
|
||||||
|
if (iblockstate1.getBlock() == this)
|
||||||
|
{
|
||||||
|
state = state.withProperty(FACING, iblockstate1.getValue(FACING)).withProperty(OPEN, iblockstate1.getValue(OPEN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return (meta & 8) > 0 ? this.getDefaultState().withProperty(HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(HINGE, (meta & 1) > 0 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf((meta & 2) > 0)) : this.getDefaultState().withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER).withProperty(FACING, EnumFacing.getHorizontal(meta & 3).rotateYCCW()).withProperty(OPEN, Boolean.valueOf((meta & 4) > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
|
||||||
|
{
|
||||||
|
i = i | 8;
|
||||||
|
|
||||||
|
if (state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT)
|
||||||
|
{
|
||||||
|
i |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).rotateY().getHorizontalIndex();
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(OPEN)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static int removeHalfBit(int meta)
|
||||||
|
{
|
||||||
|
return meta & 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isOpen(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return isOpen(combineMetadata(worldIn, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumFacing getFacing(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return getFacing(combineMetadata(worldIn, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumFacing getFacing(int combinedMeta)
|
||||||
|
{
|
||||||
|
return EnumFacing.getHorizontal(combinedMeta & 3).rotateYCCW();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean isOpen(int combinedMeta)
|
||||||
|
{
|
||||||
|
return (combinedMeta & 4) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean isTop(int meta)
|
||||||
|
{
|
||||||
|
return (meta & 8) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean isHingeLeft(int combinedMeta)
|
||||||
|
{
|
||||||
|
return (combinedMeta & 16) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {HALF, FACING, OPEN, HINGE, POWERED});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumDoorHalf implements IStringSerializable
|
||||||
|
{
|
||||||
|
UPPER,
|
||||||
|
LOWER;
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this == UPPER ? "upper" : "lower";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumHingePosition implements IStringSerializable
|
||||||
|
{
|
||||||
|
LEFT,
|
||||||
|
RIGHT;
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this == LEFT ? "left" : "right";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
402
client/src/main/java/net/minecraft/block/BlockDoublePlant.java
Normal file
402
client/src/main/java/net/minecraft/block/BlockDoublePlant.java
Normal file
@@ -0,0 +1,402 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.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.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.biome.BiomeColorHelper;
|
||||||
|
|
||||||
|
public class BlockDoublePlant extends BlockBush implements IGrowable
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockDoublePlant.EnumPlantType> VARIANT = PropertyEnum.<BlockDoublePlant.EnumPlantType>create("variant", BlockDoublePlant.EnumPlantType.class);
|
||||||
|
public static final PropertyEnum<BlockDoublePlant.EnumBlockHalf> HALF = PropertyEnum.<BlockDoublePlant.EnumBlockHalf>create("half", BlockDoublePlant.EnumBlockHalf.class);
|
||||||
|
public static final PropertyEnum<EnumFacing> field_181084_N = BlockDirectional.FACING;
|
||||||
|
|
||||||
|
public BlockDoublePlant()
|
||||||
|
{
|
||||||
|
super(Material.vine);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockDoublePlant.EnumPlantType.SUNFLOWER).withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(field_181084_N, EnumFacing.NORTH));
|
||||||
|
this.setHardness(0.0F);
|
||||||
|
this.setStepSound(soundTypeGrass);
|
||||||
|
this.setUnlocalizedName("doublePlant");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockDoublePlant.EnumPlantType getVariant(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
iblockstate = this.getActualState(iblockstate, worldIn, pos);
|
||||||
|
return (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BlockDoublePlant.EnumPlantType.FERN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return super.canPlaceBlockAt(worldIn, pos) && worldIn.isAirBlock(pos.up());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this Block can be replaced directly by other blocks (true for e.g. tall grass)
|
||||||
|
*/
|
||||||
|
public boolean isReplaceable(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() != this)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)this.getActualState(iblockstate, worldIn, pos).getValue(VARIANT);
|
||||||
|
return blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN || blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (!this.canBlockStay(worldIn, pos, state))
|
||||||
|
{
|
||||||
|
boolean flag = state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER;
|
||||||
|
BlockPos blockpos = flag ? pos : pos.up();
|
||||||
|
BlockPos blockpos1 = flag ? pos.down() : pos;
|
||||||
|
Block block = (Block)(flag ? this : worldIn.getBlockState(blockpos).getBlock());
|
||||||
|
Block block1 = (Block)(flag ? worldIn.getBlockState(blockpos1).getBlock() : this);
|
||||||
|
|
||||||
|
if (block == this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos, Blocks.air.getDefaultState(), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block1 == this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos1, Blocks.air.getDefaultState(), 3);
|
||||||
|
|
||||||
|
if (!flag)
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, blockpos1, state, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos.down()).getBlock() == this;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos.up());
|
||||||
|
return iblockstate.getBlock() == this && super.canBlockStay(worldIn, pos, iblockstate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(VARIANT);
|
||||||
|
return blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN ? null : (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS ? (rand.nextInt(8) == 0 ? Items.wheat_seeds : null) : Item.getItemFromBlock(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return state.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.UPPER && state.getValue(VARIANT) != BlockDoublePlant.EnumPlantType.GRASS ? ((BlockDoublePlant.EnumPlantType)state.getValue(VARIANT)).getMeta() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||||
|
{
|
||||||
|
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
|
||||||
|
return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? 16777215 : BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void placeAt(World worldIn, BlockPos lowerPos, BlockDoublePlant.EnumPlantType variant, int flags)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(lowerPos, this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(VARIANT, variant), flags);
|
||||||
|
worldIn.setBlockState(lowerPos.up(), this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER), flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote || player.getCurrentEquippedItem() == null || player.getCurrentEquippedItem().getItem() != Items.shears || state.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.LOWER || !this.onHarvest(worldIn, pos, state, player))
|
||||||
|
{
|
||||||
|
super.harvestBlock(worldIn, player, pos, state, te);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
|
||||||
|
{
|
||||||
|
if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(pos.down()).getBlock() == this)
|
||||||
|
{
|
||||||
|
if (!player.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos.down());
|
||||||
|
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);
|
||||||
|
|
||||||
|
if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
|
||||||
|
{
|
||||||
|
worldIn.destroyBlock(pos.down(), true);
|
||||||
|
}
|
||||||
|
else if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
|
||||||
|
{
|
||||||
|
this.onHarvest(worldIn, pos, iblockstate, player);
|
||||||
|
worldIn.setBlockToAir(pos.down());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.destroyBlock(pos.down(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos.down());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos.down());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (player.capabilities.isCreativeMode && worldIn.getBlockState(pos.up()).getBlock() == this)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos.up(), Blocks.air.getDefaultState(), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onBlockHarvested(worldIn, pos, state, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
for (BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype : BlockDoublePlant.EnumPlantType.values())
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, blockdoubleplant$enumplanttype.getMeta()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDamageValue(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return this.getVariant(worldIn, pos).getMeta();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this IGrowable can grow
|
||||||
|
*/
|
||||||
|
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
|
||||||
|
{
|
||||||
|
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
|
||||||
|
return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(this, 1, this.getVariant(worldIn, pos).getMeta()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return (meta & 8) > 0 ? this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER) : this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(VARIANT, BlockDoublePlant.EnumPlantType.byMetadata(meta & 7));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos.down());
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
state = state.withProperty(VARIANT, iblockstate.getValue(VARIANT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 | ((EnumFacing)state.getValue(field_181084_N)).getHorizontalIndex() : ((BlockDoublePlant.EnumPlantType)state.getValue(VARIANT)).getMeta();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {HALF, VARIANT, field_181084_N});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the OffsetType for this Block. Determines if the model is rendered slightly offset.
|
||||||
|
*/
|
||||||
|
public Block.EnumOffsetType getOffsetType()
|
||||||
|
{
|
||||||
|
return Block.EnumOffsetType.XZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumBlockHalf implements IStringSerializable
|
||||||
|
{
|
||||||
|
UPPER,
|
||||||
|
LOWER;
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this == UPPER ? "upper" : "lower";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumPlantType implements IStringSerializable
|
||||||
|
{
|
||||||
|
SUNFLOWER(0, "sunflower"),
|
||||||
|
SYRINGA(1, "syringa"),
|
||||||
|
GRASS(2, "double_grass", "grass"),
|
||||||
|
FERN(3, "double_fern", "fern"),
|
||||||
|
ROSE(4, "double_rose", "rose"),
|
||||||
|
PAEONIA(5, "paeonia");
|
||||||
|
|
||||||
|
private static final BlockDoublePlant.EnumPlantType[] META_LOOKUP = new BlockDoublePlant.EnumPlantType[values().length];
|
||||||
|
private final int meta;
|
||||||
|
private final String name;
|
||||||
|
private final String unlocalizedName;
|
||||||
|
|
||||||
|
private EnumPlantType(int meta, String name)
|
||||||
|
{
|
||||||
|
this(meta, name, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EnumPlantType(int meta, String name, String unlocalizedName)
|
||||||
|
{
|
||||||
|
this.meta = meta;
|
||||||
|
this.name = name;
|
||||||
|
this.unlocalizedName = unlocalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMeta()
|
||||||
|
{
|
||||||
|
return this.meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockDoublePlant.EnumPlantType byMetadata(int meta)
|
||||||
|
{
|
||||||
|
if (meta < 0 || meta >= META_LOOKUP.length)
|
||||||
|
{
|
||||||
|
meta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return META_LOOKUP[meta];
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnlocalizedName()
|
||||||
|
{
|
||||||
|
return this.unlocalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype : values())
|
||||||
|
{
|
||||||
|
META_LOOKUP[blockdoubleplant$enumplanttype.getMeta()] = blockdoubleplant$enumplanttype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
public class BlockDoubleStoneSlab extends BlockStoneSlab
|
||||||
|
{
|
||||||
|
public boolean isDouble()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
public class BlockDoubleStoneSlabNew extends BlockStoneSlabNew
|
||||||
|
{
|
||||||
|
public boolean isDouble()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
public class BlockDoubleWoodSlab extends BlockWoodSlab
|
||||||
|
{
|
||||||
|
public boolean isDouble()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
149
client/src/main/java/net/minecraft/block/BlockDragonEgg.java
Normal file
149
client/src/main/java/net/minecraft/block/BlockDragonEgg.java
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.item.EntityFallingBlock;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockDragonEgg extends Block
|
||||||
|
{
|
||||||
|
public BlockDragonEgg()
|
||||||
|
{
|
||||||
|
super(Material.dragonEgg, MapColor.blackColor);
|
||||||
|
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
this.checkFall(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkFall(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (BlockFalling.canFallInto(worldIn, pos.down()) && pos.getY() >= 0)
|
||||||
|
{
|
||||||
|
int i = 32;
|
||||||
|
|
||||||
|
if (!BlockFalling.fallInstantly && worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i)))
|
||||||
|
{
|
||||||
|
worldIn.spawnEntityInWorld(new EntityFallingBlock(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), this.getDefaultState()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
BlockPos blockpos;
|
||||||
|
|
||||||
|
for (blockpos = pos; BlockFalling.canFallInto(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down())
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockpos.getY() > 0)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos, this.getDefaultState(), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
this.teleport(worldIn, pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn)
|
||||||
|
{
|
||||||
|
this.teleport(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void teleport(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 1000; ++i)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.add(worldIn.rand.nextInt(16) - worldIn.rand.nextInt(16), worldIn.rand.nextInt(8) - worldIn.rand.nextInt(8), worldIn.rand.nextInt(16) - worldIn.rand.nextInt(16));
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(blockpos).getBlock().blockMaterial == Material.air)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many world ticks before ticking
|
||||||
|
*/
|
||||||
|
public int tickRate(World worldIn)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
89
client/src/main/java/net/minecraft/block/BlockDropper.java
Normal file
89
client/src/main/java/net/minecraft/block/BlockDropper.java
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||||
|
import net.minecraft.dispenser.IBehaviorDispenseItem;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityDispenser;
|
||||||
|
import net.minecraft.tileentity.TileEntityDropper;
|
||||||
|
import net.minecraft.tileentity.TileEntityHopper;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockDropper extends BlockDispenser
|
||||||
|
{
|
||||||
|
private final IBehaviorDispenseItem dropBehavior = new BehaviorDefaultDispenseItem();
|
||||||
|
|
||||||
|
protected IBehaviorDispenseItem getBehavior(ItemStack stack)
|
||||||
|
{
|
||||||
|
return this.dropBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityDropper();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dispense(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
|
||||||
|
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
|
||||||
|
|
||||||
|
if (tileentitydispenser != null)
|
||||||
|
{
|
||||||
|
int i = tileentitydispenser.getDispenseSlot();
|
||||||
|
|
||||||
|
if (i < 0)
|
||||||
|
{
|
||||||
|
worldIn.playAuxSFX(1001, pos, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
|
||||||
|
|
||||||
|
if (itemstack != null)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
|
||||||
|
BlockPos blockpos = pos.offset(enumfacing);
|
||||||
|
IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
|
||||||
|
ItemStack itemstack1;
|
||||||
|
|
||||||
|
if (iinventory == null)
|
||||||
|
{
|
||||||
|
itemstack1 = this.dropBehavior.dispense(blocksourceimpl, itemstack);
|
||||||
|
|
||||||
|
if (itemstack1 != null && itemstack1.stackSize <= 0)
|
||||||
|
{
|
||||||
|
itemstack1 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().splitStack(1), enumfacing.getOpposite());
|
||||||
|
|
||||||
|
if (itemstack1 == null)
|
||||||
|
{
|
||||||
|
itemstack1 = itemstack.copy();
|
||||||
|
|
||||||
|
if (--itemstack1.stackSize <= 0)
|
||||||
|
{
|
||||||
|
itemstack1 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemstack1 = itemstack.copy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tileentitydispenser.setInventorySlotContents(i, itemstack1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
293
client/src/main/java/net/minecraft/block/BlockDynamicLiquid.java
Normal file
293
client/src/main/java/net/minecraft/block/BlockDynamicLiquid.java
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockDynamicLiquid extends BlockLiquid
|
||||||
|
{
|
||||||
|
int adjacentSourceBlocks;
|
||||||
|
|
||||||
|
protected BlockDynamicLiquid(Material materialIn)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void placeStaticBlock(World worldIn, BlockPos pos, IBlockState currentState)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, getStaticBlock(this.blockMaterial).getDefaultState().withProperty(LEVEL, currentState.getValue(LEVEL)), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(LEVEL)).intValue();
|
||||||
|
int j = 1;
|
||||||
|
|
||||||
|
if (this.blockMaterial == Material.lava && !worldIn.provider.doesWaterVaporize())
|
||||||
|
{
|
||||||
|
j = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int k = this.tickRate(worldIn);
|
||||||
|
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
int l = -100;
|
||||||
|
this.adjacentSourceBlocks = 0;
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
l = this.checkAdjacentBlock(worldIn, pos.offset(enumfacing), l);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i1 = l + j;
|
||||||
|
|
||||||
|
if (i1 >= 8 || l < 0)
|
||||||
|
{
|
||||||
|
i1 = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getLevel(worldIn, pos.up()) >= 0)
|
||||||
|
{
|
||||||
|
int j1 = this.getLevel(worldIn, pos.up());
|
||||||
|
|
||||||
|
if (j1 >= 8)
|
||||||
|
{
|
||||||
|
i1 = j1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i1 = j1 + 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.adjacentSourceBlocks >= 2 && this.blockMaterial == Material.water)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate1 = worldIn.getBlockState(pos.down());
|
||||||
|
|
||||||
|
if (iblockstate1.getBlock().getMaterial().isSolid())
|
||||||
|
{
|
||||||
|
i1 = 0;
|
||||||
|
}
|
||||||
|
else if (iblockstate1.getBlock().getMaterial() == this.blockMaterial && ((Integer)iblockstate1.getValue(LEVEL)).intValue() == 0)
|
||||||
|
{
|
||||||
|
i1 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.blockMaterial == Material.lava && i < 8 && i1 < 8 && i1 > i && rand.nextInt(4) != 0)
|
||||||
|
{
|
||||||
|
k *= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i1 == i)
|
||||||
|
{
|
||||||
|
this.placeStaticBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = i1;
|
||||||
|
|
||||||
|
if (i1 < 0)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state = state.withProperty(LEVEL, Integer.valueOf(i1));
|
||||||
|
worldIn.setBlockState(pos, state, 2);
|
||||||
|
worldIn.scheduleUpdate(pos, this, k);
|
||||||
|
worldIn.notifyNeighborsOfStateChange(pos, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.placeStaticBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos.down());
|
||||||
|
|
||||||
|
if (this.canFlowInto(worldIn, pos.down(), iblockstate))
|
||||||
|
{
|
||||||
|
if (this.blockMaterial == Material.lava && worldIn.getBlockState(pos.down()).getBlock().getMaterial() == Material.water)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos.down(), Blocks.stone.getDefaultState());
|
||||||
|
this.triggerMixEffects(worldIn, pos.down());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= 8)
|
||||||
|
{
|
||||||
|
this.tryFlowInto(worldIn, pos.down(), iblockstate, i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.tryFlowInto(worldIn, pos.down(), iblockstate, i + 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i >= 0 && (i == 0 || this.isBlocked(worldIn, pos.down(), iblockstate)))
|
||||||
|
{
|
||||||
|
Set<EnumFacing> set = this.getPossibleFlowDirections(worldIn, pos);
|
||||||
|
int k1 = i + j;
|
||||||
|
|
||||||
|
if (i >= 8)
|
||||||
|
{
|
||||||
|
k1 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k1 >= 8)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing1 : set)
|
||||||
|
{
|
||||||
|
this.tryFlowInto(worldIn, pos.offset(enumfacing1), worldIn.getBlockState(pos.offset(enumfacing1)), k1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryFlowInto(World worldIn, BlockPos pos, IBlockState state, int level)
|
||||||
|
{
|
||||||
|
if (this.canFlowInto(worldIn, pos, state))
|
||||||
|
{
|
||||||
|
if (state.getBlock() != Blocks.air)
|
||||||
|
{
|
||||||
|
if (this.blockMaterial == Material.lava)
|
||||||
|
{
|
||||||
|
this.triggerMixEffects(worldIn, pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state.getBlock().dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(level)), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int func_176374_a(World worldIn, BlockPos pos, int distance, EnumFacing calculateFlowCost)
|
||||||
|
{
|
||||||
|
int i = 1000;
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
if (enumfacing != calculateFlowCost)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.offset(enumfacing);
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (!this.isBlocked(worldIn, blockpos, iblockstate) && (iblockstate.getBlock().getMaterial() != this.blockMaterial || ((Integer)iblockstate.getValue(LEVEL)).intValue() > 0))
|
||||||
|
{
|
||||||
|
if (!this.isBlocked(worldIn, blockpos.down(), iblockstate))
|
||||||
|
{
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distance < 4)
|
||||||
|
{
|
||||||
|
int j = this.func_176374_a(worldIn, blockpos, distance + 1, enumfacing.getOpposite());
|
||||||
|
|
||||||
|
if (j < i)
|
||||||
|
{
|
||||||
|
i = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<EnumFacing> getPossibleFlowDirections(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
int i = 1000;
|
||||||
|
Set<EnumFacing> set = EnumSet.<EnumFacing>noneOf(EnumFacing.class);
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.offset(enumfacing);
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (!this.isBlocked(worldIn, blockpos, iblockstate) && (iblockstate.getBlock().getMaterial() != this.blockMaterial || ((Integer)iblockstate.getValue(LEVEL)).intValue() > 0))
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
|
if (this.isBlocked(worldIn, blockpos.down(), worldIn.getBlockState(blockpos.down())))
|
||||||
|
{
|
||||||
|
j = this.func_176374_a(worldIn, blockpos, 1, enumfacing.getOpposite());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j < i)
|
||||||
|
{
|
||||||
|
set.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j <= i)
|
||||||
|
{
|
||||||
|
set.add(enumfacing);
|
||||||
|
i = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isBlocked(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
Block block = worldIn.getBlockState(pos).getBlock();
|
||||||
|
return !(block instanceof BlockDoor) && block != Blocks.standing_sign && block != Blocks.ladder && block != Blocks.reeds ? (block.blockMaterial == Material.portal ? true : block.blockMaterial.blocksMovement()) : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int checkAdjacentBlock(World worldIn, BlockPos pos, int currentMinLevel)
|
||||||
|
{
|
||||||
|
int i = this.getLevel(worldIn, pos);
|
||||||
|
|
||||||
|
if (i < 0)
|
||||||
|
{
|
||||||
|
return currentMinLevel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
++this.adjacentSourceBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= 8)
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentMinLevel >= 0 && i >= currentMinLevel ? currentMinLevel : i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canFlowInto(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
Material material = state.getBlock().getMaterial();
|
||||||
|
return material != this.blockMaterial && material != Material.lava && !this.isBlocked(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (!this.checkForMixing(worldIn, pos, state))
|
||||||
|
{
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
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.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityEnchantmentTable;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockEnchantmentTable extends BlockContainer
|
||||||
|
{
|
||||||
|
protected BlockEnchantmentTable()
|
||||||
|
{
|
||||||
|
super(Material.rock, MapColor.redColor);
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F);
|
||||||
|
this.setLightOpacity(0);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
super.randomDisplayTick(worldIn, pos, state, rand);
|
||||||
|
|
||||||
|
for (int i = -2; i <= 2; ++i)
|
||||||
|
{
|
||||||
|
for (int j = -2; j <= 2; ++j)
|
||||||
|
{
|
||||||
|
if (i > -2 && i < 2 && j == -1)
|
||||||
|
{
|
||||||
|
j = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rand.nextInt(16) == 0)
|
||||||
|
{
|
||||||
|
for (int k = 0; k <= 1; ++k)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.add(i, k, j);
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(blockpos).getBlock() == Blocks.bookshelf)
|
||||||
|
{
|
||||||
|
if (!worldIn.isAirBlock(pos.add(i / 2, 0, j / 2)))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, (double)pos.getX() + 0.5D, (double)pos.getY() + 2.0D, (double)pos.getZ() + 0.5D, (double)((float)i + rand.nextFloat()) - 0.5D, (double)((float)k - rand.nextFloat() - 1.0F), (double)((float)j + rand.nextFloat()) - 0.5D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityEnchantmentTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityEnchantmentTable)
|
||||||
|
{
|
||||||
|
playerIn.displayGui((TileEntityEnchantmentTable)tileentity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
|
||||||
|
|
||||||
|
if (stack.hasDisplayName())
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityEnchantmentTable)
|
||||||
|
{
|
||||||
|
((TileEntityEnchantmentTable)tileentity).setCustomName(stack.getDisplayName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
108
client/src/main/java/net/minecraft/block/BlockEndPortal.java
Normal file
108
client/src/main/java/net/minecraft/block/BlockEndPortal.java
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityEndPortal;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockEndPortal extends BlockContainer
|
||||||
|
{
|
||||||
|
protected BlockEndPortal(Material materialIn)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
this.setLightLevel(1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityEndPortal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
float f = 0.0625F;
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return side == EnumFacing.DOWN ? super.shouldSideBeRendered(worldIn, pos, side) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called When an Entity Collided with the Block
|
||||||
|
*/
|
||||||
|
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
|
||||||
|
{
|
||||||
|
if (entityIn.ridingEntity == null && entityIn.riddenByEntity == null && !worldIn.isRemote)
|
||||||
|
{
|
||||||
|
entityIn.travelToDimension(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
double d0 = (double)((float)pos.getX() + rand.nextFloat());
|
||||||
|
double d1 = (double)((float)pos.getY() + 0.8F);
|
||||||
|
double d2 = (double)((float)pos.getZ() + rand.nextFloat());
|
||||||
|
double d3 = 0.0D;
|
||||||
|
double d4 = 0.0D;
|
||||||
|
double d5 = 0.0D;
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return MapColor.blackColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockEndPortalFrame extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
public static final PropertyBool EYE = PropertyBool.create("eye");
|
||||||
|
|
||||||
|
public BlockEndPortalFrame()
|
||||||
|
{
|
||||||
|
super(Material.rock, MapColor.greenColor);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(EYE, Boolean.valueOf(false)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
|
||||||
|
if (((Boolean)worldIn.getBlockState(pos).getValue(EYE)).booleanValue())
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.3125F, 0.8125F, 0.3125F, 0.6875F, 1.0F, 0.6875F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setBlockBoundsForItemRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(EYE, Boolean.valueOf(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return ((Boolean)worldIn.getBlockState(pos).getValue(EYE)).booleanValue() ? 15 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(EYE, Boolean.valueOf((meta & 4) != 0)).withProperty(FACING, EnumFacing.getHorizontal(meta & 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(EYE)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, EYE});
|
||||||
|
}
|
||||||
|
}
|
||||||
175
client/src/main/java/net/minecraft/block/BlockEnderChest.java
Normal file
175
client/src/main/java/net/minecraft/block/BlockEnderChest.java
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.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;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockEnderChest extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
|
||||||
|
protected BlockEnderChest()
|
||||||
|
{
|
||||||
|
super(Material.rock);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(Blocks.obsidian);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canSilkHarvest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
InventoryEnderChest inventoryenderchest = playerIn.getInventoryEnderChest();
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (inventoryenderchest != null && tileentity instanceof TileEntityEnderChest)
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(pos.up()).getBlock().isNormalCube())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inventoryenderchest.setChestTileEntity((TileEntityEnderChest)tileentity);
|
||||||
|
playerIn.displayGUIChest(inventoryenderchest);
|
||||||
|
playerIn.triggerAchievement(StatList.field_181738_V);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityEnderChest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
int j = rand.nextInt(2) * 2 - 1;
|
||||||
|
int k = rand.nextInt(2) * 2 - 1;
|
||||||
|
double d0 = (double)pos.getX() + 0.5D + 0.25D * (double)j;
|
||||||
|
double d1 = (double)((float)pos.getY() + rand.nextFloat());
|
||||||
|
double d2 = (double)pos.getZ() + 0.5D + 0.25D * (double)k;
|
||||||
|
double d3 = (double)(rand.nextFloat() * (float)j);
|
||||||
|
double d4 = ((double)rand.nextFloat() - 0.5D) * 0.125D;
|
||||||
|
double d5 = (double)(rand.nextFloat() * (float)k);
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = EnumFacing.getFront(meta);
|
||||||
|
|
||||||
|
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
|
||||||
|
{
|
||||||
|
enumfacing = EnumFacing.NORTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState().withProperty(FACING, enumfacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING});
|
||||||
|
}
|
||||||
|
}
|
||||||
62
client/src/main/java/net/minecraft/block/BlockEventData.java
Normal file
62
client/src/main/java/net/minecraft/block/BlockEventData.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
|
||||||
|
public class BlockEventData
|
||||||
|
{
|
||||||
|
private BlockPos position;
|
||||||
|
private Block blockType;
|
||||||
|
|
||||||
|
/** Different for each blockID */
|
||||||
|
private int eventID;
|
||||||
|
private int eventParameter;
|
||||||
|
|
||||||
|
public BlockEventData(BlockPos pos, Block blockType, int eventId, int p_i45756_4_)
|
||||||
|
{
|
||||||
|
this.position = pos;
|
||||||
|
this.eventID = eventId;
|
||||||
|
this.eventParameter = p_i45756_4_;
|
||||||
|
this.blockType = blockType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPos getPosition()
|
||||||
|
{
|
||||||
|
return this.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Event ID (different for each BlockID)
|
||||||
|
*/
|
||||||
|
public int getEventID()
|
||||||
|
{
|
||||||
|
return this.eventID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEventParameter()
|
||||||
|
{
|
||||||
|
return this.eventParameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block getBlock()
|
||||||
|
{
|
||||||
|
return this.blockType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object p_equals_1_)
|
||||||
|
{
|
||||||
|
if (!(p_equals_1_ instanceof BlockEventData))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BlockEventData blockeventdata = (BlockEventData)p_equals_1_;
|
||||||
|
return this.position.equals(blockeventdata.position) && this.eventID == blockeventdata.eventID && this.eventParameter == blockeventdata.eventParameter && this.blockType == blockeventdata.blockType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "TE(" + this.position + ")," + this.eventID + "," + this.eventParameter + "," + this.blockType;
|
||||||
|
}
|
||||||
|
}
|
||||||
103
client/src/main/java/net/minecraft/block/BlockFalling.java
Normal file
103
client/src/main/java/net/minecraft/block/BlockFalling.java
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.item.EntityFallingBlock;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockFalling extends Block
|
||||||
|
{
|
||||||
|
public static boolean fallInstantly;
|
||||||
|
|
||||||
|
public BlockFalling()
|
||||||
|
{
|
||||||
|
super(Material.sand);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFalling(Material materialIn)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
this.checkFallable(worldIn, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkFallable(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (canFallInto(worldIn, pos.down()) && pos.getY() >= 0)
|
||||||
|
{
|
||||||
|
int i = 32;
|
||||||
|
|
||||||
|
if (!fallInstantly && worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i)))
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
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 fallingEntity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many world ticks before ticking
|
||||||
|
*/
|
||||||
|
public int tickRate(World worldIn)
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canFallInto(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
Block block = worldIn.getBlockState(pos).getBlock();
|
||||||
|
Material material = block.blockMaterial;
|
||||||
|
return block == Blocks.fire || material == Material.air || material == Material.water || material == Material.lava;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEndFalling(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
177
client/src/main/java/net/minecraft/block/BlockFarmland.java
Normal file
177
client/src/main/java/net/minecraft/block/BlockFarmland.java
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.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;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockFarmland extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyInteger MOISTURE = PropertyInteger.create("moisture", 0, 7);
|
||||||
|
|
||||||
|
protected BlockFarmland()
|
||||||
|
{
|
||||||
|
super(Material.ground);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(MOISTURE, Integer.valueOf(0)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
|
||||||
|
this.setLightOpacity(255);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 1), (double)(pos.getZ() + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(MOISTURE)).intValue();
|
||||||
|
|
||||||
|
if (!this.hasWater(worldIn, pos) && !worldIn.canLightningStrike(pos.up()))
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(i - 1)), 2);
|
||||||
|
}
|
||||||
|
else if (!this.hasCrops(worldIn, pos))
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i < 7)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(7)), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block's chance to react to a living entity falling on it.
|
||||||
|
*/
|
||||||
|
public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
|
||||||
|
{
|
||||||
|
if (entityIn instanceof EntityLivingBase)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote && worldIn.rand.nextFloat() < fallDistance - 0.5F)
|
||||||
|
{
|
||||||
|
if (!(entityIn instanceof EntityPlayer) && !worldIn.getGameRules().getBoolean("mobGriefing"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasCrops(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
Block block = worldIn.getBlockState(pos.up()).getBlock();
|
||||||
|
return block instanceof BlockCrops || block instanceof BlockStem;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasWater(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(pos.add(-4, 0, -4), pos.add(4, 1, 4)))
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(blockpos$mutableblockpos).getBlock().getMaterial() == Material.water)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(pos.up()).getBlock().getMaterial().isSolid())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
switch (side)
|
||||||
|
{
|
||||||
|
case UP:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
case SOUTH:
|
||||||
|
case WEST:
|
||||||
|
case EAST:
|
||||||
|
Block block = worldIn.getBlockState(pos).getBlock();
|
||||||
|
return !block.isOpaqueCube() && block != Blocks.farmland;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return super.shouldSideBeRendered(worldIn, pos, side);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Blocks.dirt.getItemDropped(Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(Blocks.dirt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(MOISTURE, Integer.valueOf(meta & 7));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(MOISTURE)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {MOISTURE});
|
||||||
|
}
|
||||||
|
}
|
||||||
198
client/src/main/java/net/minecraft/block/BlockFence.java
Normal file
198
client/src/main/java/net/minecraft/block/BlockFence.java
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
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;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockFence extends Block
|
||||||
|
{
|
||||||
|
/** Whether this fence connects in the northern direction */
|
||||||
|
public static final PropertyBool NORTH = PropertyBool.create("north");
|
||||||
|
|
||||||
|
/** Whether this fence connects in the eastern direction */
|
||||||
|
public static final PropertyBool EAST = PropertyBool.create("east");
|
||||||
|
|
||||||
|
/** Whether this fence connects in the southern direction */
|
||||||
|
public static final PropertyBool SOUTH = PropertyBool.create("south");
|
||||||
|
|
||||||
|
/** Whether this fence connects in the western direction */
|
||||||
|
public static final PropertyBool WEST = PropertyBool.create("west");
|
||||||
|
|
||||||
|
public BlockFence(Material materialIn)
|
||||||
|
{
|
||||||
|
this(materialIn, materialIn.getMaterialMapColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFence(Material p_i46395_1_, MapColor p_i46395_2_)
|
||||||
|
{
|
||||||
|
super(p_i46395_1_, p_i46395_2_);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
boolean flag = this.canConnectTo(worldIn, pos.north());
|
||||||
|
boolean flag1 = this.canConnectTo(worldIn, pos.south());
|
||||||
|
boolean flag2 = this.canConnectTo(worldIn, pos.west());
|
||||||
|
boolean flag3 = this.canConnectTo(worldIn, pos.east());
|
||||||
|
float f = 0.375F;
|
||||||
|
float f1 = 0.625F;
|
||||||
|
float f2 = 0.375F;
|
||||||
|
float f3 = 0.625F;
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
f2 = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag1)
|
||||||
|
{
|
||||||
|
f3 = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag || flag1)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
f2 = 0.375F;
|
||||||
|
f3 = 0.625F;
|
||||||
|
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
f = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag3)
|
||||||
|
{
|
||||||
|
f1 = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag2 || flag3 || !flag && !flag1)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
f2 = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag1)
|
||||||
|
{
|
||||||
|
f3 = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
boolean flag = this.canConnectTo(worldIn, pos.north());
|
||||||
|
boolean flag1 = this.canConnectTo(worldIn, pos.south());
|
||||||
|
boolean flag2 = this.canConnectTo(worldIn, pos.west());
|
||||||
|
boolean flag3 = this.canConnectTo(worldIn, pos.east());
|
||||||
|
float f = 0.375F;
|
||||||
|
float f1 = 0.625F;
|
||||||
|
float f2 = 0.375F;
|
||||||
|
float f3 = 0.625F;
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
f2 = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag1)
|
||||||
|
{
|
||||||
|
f3 = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
f = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag3)
|
||||||
|
{
|
||||||
|
f1 = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
Block block = worldIn.getBlockState(pos).getBlock();
|
||||||
|
return block == Blocks.barrier ? false : ((!(block instanceof BlockFence) || block.blockMaterial != this.blockMaterial) && !(block instanceof BlockFenceGate) ? (block.blockMaterial.isOpaque() && block.isFullCube() ? block.blockMaterial != Material.gourd : false) : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
return worldIn.isRemote ? true : ItemLead.attachToFence(playerIn, worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return state.withProperty(NORTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canConnectTo(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canConnectTo(worldIn, pos.west())));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {NORTH, EAST, WEST, SOUTH});
|
||||||
|
}
|
||||||
|
}
|
||||||
197
client/src/main/java/net/minecraft/block/BlockFenceGate.java
Normal file
197
client/src/main/java/net/minecraft/block/BlockFenceGate.java
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockFenceGate extends BlockDirectional
|
||||||
|
{
|
||||||
|
public static final PropertyBool OPEN = PropertyBool.create("open");
|
||||||
|
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||||
|
public static final PropertyBool IN_WALL = PropertyBool.create("in_wall");
|
||||||
|
|
||||||
|
public BlockFenceGate(BlockPlanks.EnumType p_i46394_1_)
|
||||||
|
{
|
||||||
|
super(Material.wood, p_i46394_1_.func_181070_c());
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false)));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
EnumFacing.Axis enumfacing$axis = ((EnumFacing)state.getValue(FACING)).getAxis();
|
||||||
|
|
||||||
|
if (enumfacing$axis == EnumFacing.Axis.Z && (worldIn.getBlockState(pos.west()).getBlock() == Blocks.cobblestone_wall || worldIn.getBlockState(pos.east()).getBlock() == Blocks.cobblestone_wall) || enumfacing$axis == EnumFacing.Axis.X && (worldIn.getBlockState(pos.north()).getBlock() == Blocks.cobblestone_wall || worldIn.getBlockState(pos.south()).getBlock() == Blocks.cobblestone_wall))
|
||||||
|
{
|
||||||
|
state = state.withProperty(IN_WALL, Boolean.valueOf(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid() ? super.canPlaceBlockAt(worldIn, pos) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(OPEN)).booleanValue())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnumFacing.Axis enumfacing$axis = ((EnumFacing)state.getValue(FACING)).getAxis();
|
||||||
|
return enumfacing$axis == EnumFacing.Axis.Z ? new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)((float)pos.getZ() + 0.375F), (double)(pos.getX() + 1), (double)((float)pos.getY() + 1.5F), (double)((float)pos.getZ() + 0.625F)) : new AxisAlignedBB((double)((float)pos.getX() + 0.375F), (double)pos.getY(), (double)pos.getZ(), (double)((float)pos.getX() + 0.625F), (double)((float)pos.getY() + 1.5F), (double)(pos.getZ() + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
EnumFacing.Axis enumfacing$axis = ((EnumFacing)worldIn.getBlockState(pos).getValue(FACING)).getAxis();
|
||||||
|
|
||||||
|
if (enumfacing$axis == EnumFacing.Axis.Z)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.375F, 1.0F, 1.0F, 0.625F);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.375F, 0.0F, 0.0F, 0.625F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return ((Boolean)worldIn.getBlockState(pos).getValue(OPEN)).booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(OPEN)).booleanValue())
|
||||||
|
{
|
||||||
|
state = state.withProperty(OPEN, Boolean.valueOf(false));
|
||||||
|
worldIn.setBlockState(pos, state, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);
|
||||||
|
|
||||||
|
if (state.getValue(FACING) == enumfacing.getOpposite())
|
||||||
|
{
|
||||||
|
state = state.withProperty(FACING, enumfacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
state = state.withProperty(OPEN, Boolean.valueOf(true));
|
||||||
|
worldIn.setBlockState(pos, state, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
boolean flag = worldIn.isBlockPowered(pos);
|
||||||
|
|
||||||
|
if (flag || neighborBlock.canProvidePower())
|
||||||
|
{
|
||||||
|
if (flag && !((Boolean)state.getValue(OPEN)).booleanValue() && !((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(true)).withProperty(POWERED, Boolean.valueOf(true)), 2);
|
||||||
|
worldIn.playAuxSFXAtEntity((EntityPlayer)null, 1003, pos, 0);
|
||||||
|
}
|
||||||
|
else if (!flag && ((Boolean)state.getValue(OPEN)).booleanValue() && ((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)), 2);
|
||||||
|
worldIn.playAuxSFXAtEntity((EntityPlayer)null, 1006, pos, 0);
|
||||||
|
}
|
||||||
|
else if (flag != ((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(flag)), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(OPEN, Boolean.valueOf((meta & 4) != 0)).withProperty(POWERED, Boolean.valueOf((meta & 8) != 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(OPEN)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, OPEN, POWERED, IN_WALL});
|
||||||
|
}
|
||||||
|
}
|
||||||
506
client/src/main/java/net/minecraft/block/BlockFire.java
Normal file
506
client/src/main/java/net/minecraft/block/BlockFire.java
Normal file
@@ -0,0 +1,506 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldProviderEnd;
|
||||||
|
|
||||||
|
public class BlockFire extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15);
|
||||||
|
public static final PropertyBool FLIP = PropertyBool.create("flip");
|
||||||
|
public static final PropertyBool ALT = PropertyBool.create("alt");
|
||||||
|
public static final PropertyBool NORTH = PropertyBool.create("north");
|
||||||
|
public static final PropertyBool EAST = PropertyBool.create("east");
|
||||||
|
public static final PropertyBool SOUTH = PropertyBool.create("south");
|
||||||
|
public static final PropertyBool WEST = PropertyBool.create("west");
|
||||||
|
public static final PropertyInteger UPPER = PropertyInteger.create("upper", 0, 2);
|
||||||
|
private final Map<Block, Integer> encouragements = Maps.<Block, Integer>newIdentityHashMap();
|
||||||
|
private final Map<Block, Integer> flammabilities = Maps.<Block, Integer>newIdentityHashMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
int i = pos.getX();
|
||||||
|
int j = pos.getY();
|
||||||
|
int k = pos.getZ();
|
||||||
|
|
||||||
|
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !Blocks.fire.canCatchFire(worldIn, pos.down()))
|
||||||
|
{
|
||||||
|
boolean flag = (i + j + k & 1) == 1;
|
||||||
|
boolean flag1 = (i / 2 + j / 2 + k / 2 & 1) == 1;
|
||||||
|
int l = 0;
|
||||||
|
|
||||||
|
if (this.canCatchFire(worldIn, pos.up()))
|
||||||
|
{
|
||||||
|
l = flag ? 1 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state.withProperty(NORTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canCatchFire(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canCatchFire(worldIn, pos.west()))).withProperty(UPPER, Integer.valueOf(l)).withProperty(FLIP, Boolean.valueOf(flag1)).withProperty(ALT, Boolean.valueOf(flag));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.getDefaultState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockFire()
|
||||||
|
{
|
||||||
|
super(Material.fire);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)).withProperty(FLIP, Boolean.valueOf(false)).withProperty(ALT, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)).withProperty(UPPER, Integer.valueOf(0)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init()
|
||||||
|
{
|
||||||
|
Blocks.fire.setFireInfo(Blocks.planks, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.double_wooden_slab, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.wooden_slab, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.oak_fence_gate, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.spruce_fence_gate, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.birch_fence_gate, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.jungle_fence_gate, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.dark_oak_fence_gate, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.acacia_fence_gate, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.oak_fence, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.spruce_fence, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.birch_fence, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.jungle_fence, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.dark_oak_fence, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.acacia_fence, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.oak_stairs, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.birch_stairs, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.spruce_stairs, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.jungle_stairs, 5, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.log, 5, 5);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.log2, 5, 5);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.leaves, 30, 60);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.leaves2, 30, 60);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.bookshelf, 30, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.tnt, 15, 100);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.tallgrass, 60, 100);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.double_plant, 60, 100);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.yellow_flower, 60, 100);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.red_flower, 60, 100);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.deadbush, 60, 100);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.wool, 30, 60);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.vine, 15, 100);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.coal_block, 5, 5);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.hay_block, 60, 20);
|
||||||
|
Blocks.fire.setFireInfo(Blocks.carpet, 60, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFireInfo(Block blockIn, int encouragement, int flammability)
|
||||||
|
{
|
||||||
|
this.encouragements.put(blockIn, Integer.valueOf(encouragement));
|
||||||
|
this.flammabilities.put(blockIn, Integer.valueOf(flammability));
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many world ticks before ticking
|
||||||
|
*/
|
||||||
|
public int tickRate(World worldIn)
|
||||||
|
{
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (worldIn.getGameRules().getBoolean("doFireTick"))
|
||||||
|
{
|
||||||
|
if (!this.canPlaceBlockAt(worldIn, pos))
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = worldIn.getBlockState(pos.down()).getBlock();
|
||||||
|
boolean flag = block == Blocks.netherrack;
|
||||||
|
|
||||||
|
if (worldIn.provider instanceof WorldProviderEnd && block == Blocks.bedrock)
|
||||||
|
{
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos))
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
|
||||||
|
if (i < 15)
|
||||||
|
{
|
||||||
|
state = state.withProperty(AGE, Integer.valueOf(i + rand.nextInt(3) / 2));
|
||||||
|
worldIn.setBlockState(pos, state, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + rand.nextInt(10));
|
||||||
|
|
||||||
|
if (!flag)
|
||||||
|
{
|
||||||
|
if (!this.canNeighborCatchFire(worldIn, pos))
|
||||||
|
{
|
||||||
|
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) || i > 3)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.canCatchFire(worldIn, pos.down()) && i == 15 && rand.nextInt(4) == 0)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean flag1 = worldIn.isBlockinHighHumidity(pos);
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
if (flag1)
|
||||||
|
{
|
||||||
|
j = -50;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.catchOnFire(worldIn, pos.east(), 300 + j, rand, i);
|
||||||
|
this.catchOnFire(worldIn, pos.west(), 300 + j, rand, i);
|
||||||
|
this.catchOnFire(worldIn, pos.down(), 250 + j, rand, i);
|
||||||
|
this.catchOnFire(worldIn, pos.up(), 250 + j, rand, i);
|
||||||
|
this.catchOnFire(worldIn, pos.north(), 300 + j, rand, i);
|
||||||
|
this.catchOnFire(worldIn, pos.south(), 300 + j, rand, i);
|
||||||
|
|
||||||
|
for (int k = -1; k <= 1; ++k)
|
||||||
|
{
|
||||||
|
for (int l = -1; l <= 1; ++l)
|
||||||
|
{
|
||||||
|
for (int i1 = -1; i1 <= 4; ++i1)
|
||||||
|
{
|
||||||
|
if (k != 0 || i1 != 0 || l != 0)
|
||||||
|
{
|
||||||
|
int j1 = 100;
|
||||||
|
|
||||||
|
if (i1 > 1)
|
||||||
|
{
|
||||||
|
j1 += (i1 - 1) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockPos blockpos = pos.add(k, i1, l);
|
||||||
|
int k1 = this.getNeighborEncouragement(worldIn, blockpos);
|
||||||
|
|
||||||
|
if (k1 > 0)
|
||||||
|
{
|
||||||
|
int l1 = (k1 + 40 + worldIn.getDifficulty().getDifficultyId() * 7) / (i + 30);
|
||||||
|
|
||||||
|
if (flag1)
|
||||||
|
{
|
||||||
|
l1 /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (l1 > 0 && rand.nextInt(j1) <= l1 && (!worldIn.isRaining() || !this.canDie(worldIn, blockpos)))
|
||||||
|
{
|
||||||
|
int i2 = i + rand.nextInt(5) / 4;
|
||||||
|
|
||||||
|
if (i2 > 15)
|
||||||
|
{
|
||||||
|
i2 = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.setBlockState(blockpos, state.withProperty(AGE, Integer.valueOf(i2)), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canDie(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return worldIn.canLightningStrike(pos) || worldIn.canLightningStrike(pos.west()) || worldIn.canLightningStrike(pos.east()) || worldIn.canLightningStrike(pos.north()) || worldIn.canLightningStrike(pos.south());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean requiresUpdates()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getFlammability(Block blockIn)
|
||||||
|
{
|
||||||
|
Integer integer = (Integer)this.flammabilities.get(blockIn);
|
||||||
|
return integer == null ? 0 : integer.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getEncouragement(Block blockIn)
|
||||||
|
{
|
||||||
|
Integer integer = (Integer)this.encouragements.get(blockIn);
|
||||||
|
return integer == null ? 0 : integer.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
|
||||||
|
{
|
||||||
|
int i = this.getFlammability(worldIn.getBlockState(pos).getBlock());
|
||||||
|
|
||||||
|
if (random.nextInt(chance) < i)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos))
|
||||||
|
{
|
||||||
|
int j = age + random.nextInt(5) / 4;
|
||||||
|
|
||||||
|
if (j > 15)
|
||||||
|
{
|
||||||
|
j = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == Blocks.tnt)
|
||||||
|
{
|
||||||
|
Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canNeighborCatchFire(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.values())
|
||||||
|
{
|
||||||
|
if (this.canCatchFire(worldIn, pos.offset(enumfacing)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getNeighborEncouragement(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
if (!worldIn.isAirBlock(pos))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.values())
|
||||||
|
{
|
||||||
|
i = Math.max(this.getEncouragement(worldIn.getBlockState(pos.offset(enumfacing)).getBlock()), i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if this block is collidable (only used by Fire). Args: x, y, z
|
||||||
|
*/
|
||||||
|
public boolean isCollidable()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the block can be caught on fire
|
||||||
|
*/
|
||||||
|
public boolean canCatchFire(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return this.getEncouragement(worldIn.getBlockState(pos).getBlock()) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) || this.canNeighborCatchFire(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !this.canNeighborCatchFire(worldIn, pos))
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (worldIn.provider.getDimensionId() > 0 || !Blocks.portal.func_176548_d(worldIn, pos))
|
||||||
|
{
|
||||||
|
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !this.canNeighborCatchFire(worldIn, pos))
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + worldIn.rand.nextInt(10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (rand.nextInt(24) == 0)
|
||||||
|
{
|
||||||
|
worldIn.playSound((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), "fire.fire", 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !Blocks.fire.canCatchFire(worldIn, pos.down()))
|
||||||
|
{
|
||||||
|
if (Blocks.fire.canCatchFire(worldIn, pos.west()))
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 2; ++j)
|
||||||
|
{
|
||||||
|
double d3 = (double)pos.getX() + rand.nextDouble() * 0.10000000149011612D;
|
||||||
|
double d8 = (double)pos.getY() + rand.nextDouble();
|
||||||
|
double d13 = (double)pos.getZ() + rand.nextDouble();
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d3, d8, d13, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Blocks.fire.canCatchFire(worldIn, pos.east()))
|
||||||
|
{
|
||||||
|
for (int k = 0; k < 2; ++k)
|
||||||
|
{
|
||||||
|
double d4 = (double)(pos.getX() + 1) - rand.nextDouble() * 0.10000000149011612D;
|
||||||
|
double d9 = (double)pos.getY() + rand.nextDouble();
|
||||||
|
double d14 = (double)pos.getZ() + rand.nextDouble();
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d4, d9, d14, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Blocks.fire.canCatchFire(worldIn, pos.north()))
|
||||||
|
{
|
||||||
|
for (int l = 0; l < 2; ++l)
|
||||||
|
{
|
||||||
|
double d5 = (double)pos.getX() + rand.nextDouble();
|
||||||
|
double d10 = (double)pos.getY() + rand.nextDouble();
|
||||||
|
double d15 = (double)pos.getZ() + rand.nextDouble() * 0.10000000149011612D;
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d5, d10, d15, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Blocks.fire.canCatchFire(worldIn, pos.south()))
|
||||||
|
{
|
||||||
|
for (int i1 = 0; i1 < 2; ++i1)
|
||||||
|
{
|
||||||
|
double d6 = (double)pos.getX() + rand.nextDouble();
|
||||||
|
double d11 = (double)pos.getY() + rand.nextDouble();
|
||||||
|
double d16 = (double)(pos.getZ() + 1) - rand.nextDouble() * 0.10000000149011612D;
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d6, d11, d16, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Blocks.fire.canCatchFire(worldIn, pos.up()))
|
||||||
|
{
|
||||||
|
for (int j1 = 0; j1 < 2; ++j1)
|
||||||
|
{
|
||||||
|
double d7 = (double)pos.getX() + rand.nextDouble();
|
||||||
|
double d12 = (double)(pos.getY() + 1) - rand.nextDouble() * 0.10000000149011612D;
|
||||||
|
double d17 = (double)pos.getZ() + rand.nextDouble();
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d7, d12, d17, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
double d0 = (double)pos.getX() + rand.nextDouble();
|
||||||
|
double d1 = (double)pos.getY() + rand.nextDouble() * 0.5D + 0.5D;
|
||||||
|
double d2 = (double)pos.getZ() + rand.nextDouble();
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return MapColor.tntColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {AGE, NORTH, EAST, SOUTH, WEST, UPPER, FLIP, ALT});
|
||||||
|
}
|
||||||
|
}
|
||||||
196
client/src/main/java/net/minecraft/block/BlockFlower.java
Normal file
196
client/src/main/java/net/minecraft/block/BlockFlower.java
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.Collections2;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
|
||||||
|
public abstract class BlockFlower extends BlockBush
|
||||||
|
{
|
||||||
|
protected PropertyEnum<BlockFlower.EnumFlowerType> type;
|
||||||
|
|
||||||
|
protected BlockFlower()
|
||||||
|
{
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(this.getTypeProperty(), this.getBlockType() == BlockFlower.EnumFlowerColor.RED ? BlockFlower.EnumFlowerType.POPPY : BlockFlower.EnumFlowerType.DANDELION));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockFlower.EnumFlowerType)state.getValue(this.getTypeProperty())).getMeta();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
for (BlockFlower.EnumFlowerType blockflower$enumflowertype : BlockFlower.EnumFlowerType.getTypes(this.getBlockType()))
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, blockflower$enumflowertype.getMeta()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(this.getTypeProperty(), BlockFlower.EnumFlowerType.getType(this.getBlockType(), meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Type of this flower (Yellow/Red)
|
||||||
|
*/
|
||||||
|
public abstract BlockFlower.EnumFlowerColor getBlockType();
|
||||||
|
|
||||||
|
public IProperty<BlockFlower.EnumFlowerType> getTypeProperty()
|
||||||
|
{
|
||||||
|
if (this.type == null)
|
||||||
|
{
|
||||||
|
this.type = PropertyEnum.<BlockFlower.EnumFlowerType>create("type", BlockFlower.EnumFlowerType.class, new Predicate<BlockFlower.EnumFlowerType>()
|
||||||
|
{
|
||||||
|
public boolean apply(BlockFlower.EnumFlowerType p_apply_1_)
|
||||||
|
{
|
||||||
|
return p_apply_1_.getBlockType() == BlockFlower.this.getBlockType();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockFlower.EnumFlowerType)state.getValue(this.getTypeProperty())).getMeta();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {this.getTypeProperty()});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the OffsetType for this Block. Determines if the model is rendered slightly offset.
|
||||||
|
*/
|
||||||
|
public Block.EnumOffsetType getOffsetType()
|
||||||
|
{
|
||||||
|
return Block.EnumOffsetType.XZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumFlowerColor
|
||||||
|
{
|
||||||
|
YELLOW,
|
||||||
|
RED;
|
||||||
|
|
||||||
|
public BlockFlower getBlock()
|
||||||
|
{
|
||||||
|
return this == YELLOW ? Blocks.yellow_flower : Blocks.red_flower;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumFlowerType implements IStringSerializable
|
||||||
|
{
|
||||||
|
DANDELION(BlockFlower.EnumFlowerColor.YELLOW, 0, "dandelion"),
|
||||||
|
POPPY(BlockFlower.EnumFlowerColor.RED, 0, "poppy"),
|
||||||
|
BLUE_ORCHID(BlockFlower.EnumFlowerColor.RED, 1, "blue_orchid", "blueOrchid"),
|
||||||
|
ALLIUM(BlockFlower.EnumFlowerColor.RED, 2, "allium"),
|
||||||
|
HOUSTONIA(BlockFlower.EnumFlowerColor.RED, 3, "houstonia"),
|
||||||
|
RED_TULIP(BlockFlower.EnumFlowerColor.RED, 4, "red_tulip", "tulipRed"),
|
||||||
|
ORANGE_TULIP(BlockFlower.EnumFlowerColor.RED, 5, "orange_tulip", "tulipOrange"),
|
||||||
|
WHITE_TULIP(BlockFlower.EnumFlowerColor.RED, 6, "white_tulip", "tulipWhite"),
|
||||||
|
PINK_TULIP(BlockFlower.EnumFlowerColor.RED, 7, "pink_tulip", "tulipPink"),
|
||||||
|
OXEYE_DAISY(BlockFlower.EnumFlowerColor.RED, 8, "oxeye_daisy", "oxeyeDaisy");
|
||||||
|
|
||||||
|
private static final BlockFlower.EnumFlowerType[][] TYPES_FOR_BLOCK = new BlockFlower.EnumFlowerType[BlockFlower.EnumFlowerColor.values().length][];
|
||||||
|
private final BlockFlower.EnumFlowerColor blockType;
|
||||||
|
private final int meta;
|
||||||
|
private final String name;
|
||||||
|
private final String unlocalizedName;
|
||||||
|
|
||||||
|
private EnumFlowerType(BlockFlower.EnumFlowerColor blockType, int meta, String name)
|
||||||
|
{
|
||||||
|
this(blockType, meta, name, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EnumFlowerType(BlockFlower.EnumFlowerColor blockType, int meta, String name, String unlocalizedName)
|
||||||
|
{
|
||||||
|
this.blockType = blockType;
|
||||||
|
this.meta = meta;
|
||||||
|
this.name = name;
|
||||||
|
this.unlocalizedName = unlocalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFlower.EnumFlowerColor getBlockType()
|
||||||
|
{
|
||||||
|
return this.blockType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMeta()
|
||||||
|
{
|
||||||
|
return this.meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockFlower.EnumFlowerType getType(BlockFlower.EnumFlowerColor blockType, int meta)
|
||||||
|
{
|
||||||
|
BlockFlower.EnumFlowerType[] ablockflower$enumflowertype = TYPES_FOR_BLOCK[blockType.ordinal()];
|
||||||
|
|
||||||
|
if (meta < 0 || meta >= ablockflower$enumflowertype.length)
|
||||||
|
{
|
||||||
|
meta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ablockflower$enumflowertype[meta];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockFlower.EnumFlowerType[] getTypes(BlockFlower.EnumFlowerColor flowerColor)
|
||||||
|
{
|
||||||
|
return TYPES_FOR_BLOCK[flowerColor.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnlocalizedName()
|
||||||
|
{
|
||||||
|
return this.unlocalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (final BlockFlower.EnumFlowerColor blockflower$enumflowercolor : BlockFlower.EnumFlowerColor.values())
|
||||||
|
{
|
||||||
|
Collection<BlockFlower.EnumFlowerType> collection = Collections2.<BlockFlower.EnumFlowerType>filter(Lists.newArrayList(values()), new Predicate<BlockFlower.EnumFlowerType>()
|
||||||
|
{
|
||||||
|
public boolean apply(BlockFlower.EnumFlowerType p_apply_1_)
|
||||||
|
{
|
||||||
|
return p_apply_1_.getBlockType() == blockflower$enumflowercolor;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
TYPES_FOR_BLOCK[blockflower$enumflowercolor.ordinal()] = (BlockFlower.EnumFlowerType[])collection.toArray(new BlockFlower.EnumFlowerType[collection.size()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
494
client/src/main/java/net/minecraft/block/BlockFlowerPot.java
Normal file
494
client/src/main/java/net/minecraft/block/BlockFlowerPot.java
Normal file
@@ -0,0 +1,494 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
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.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.stats.StatList;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityFlowerPot;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockFlowerPot extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyInteger LEGACY_DATA = PropertyInteger.create("legacy_data", 0, 15);
|
||||||
|
public static final PropertyEnum<BlockFlowerPot.EnumFlowerType> CONTENTS = PropertyEnum.<BlockFlowerPot.EnumFlowerType>create("contents", BlockFlowerPot.EnumFlowerType.class);
|
||||||
|
|
||||||
|
public BlockFlowerPot()
|
||||||
|
{
|
||||||
|
super(Material.circuits);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(CONTENTS, BlockFlowerPot.EnumFlowerType.EMPTY).withProperty(LEGACY_DATA, Integer.valueOf(0)));
|
||||||
|
this.setBlockBoundsForItemRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the localized name of this block. Used for the statistics page.
|
||||||
|
*/
|
||||||
|
public String getLocalizedName()
|
||||||
|
{
|
||||||
|
return StatCollector.translateToLocal("item.flowerPot.name");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
float f = 0.375F;
|
||||||
|
float f1 = f / 2.0F;
|
||||||
|
this.setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, f, 0.5F + f1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityFlowerPot)
|
||||||
|
{
|
||||||
|
Item item = ((TileEntityFlowerPot)tileentity).getFlowerPotItem();
|
||||||
|
|
||||||
|
if (item instanceof ItemBlock)
|
||||||
|
{
|
||||||
|
return Block.getBlockFromItem(item).colorMultiplier(worldIn, pos, renderPass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 16777215;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = playerIn.inventory.getCurrentItem();
|
||||||
|
|
||||||
|
if (itemstack != null && itemstack.getItem() instanceof ItemBlock)
|
||||||
|
{
|
||||||
|
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
|
||||||
|
|
||||||
|
if (tileentityflowerpot == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (tileentityflowerpot.getFlowerPotItem() != null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Block block = Block.getBlockFromItem(itemstack.getItem());
|
||||||
|
|
||||||
|
if (!this.canNotContain(block, itemstack.getMetadata()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tileentityflowerpot.setFlowerPotData(itemstack.getItem(), itemstack.getMetadata());
|
||||||
|
tileentityflowerpot.markDirty();
|
||||||
|
worldIn.markBlockForUpdate(pos);
|
||||||
|
playerIn.triggerAchievement(StatList.field_181736_T);
|
||||||
|
|
||||||
|
if (!playerIn.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
|
||||||
|
{
|
||||||
|
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canNotContain(Block blockIn, int meta)
|
||||||
|
{
|
||||||
|
return blockIn != Blocks.yellow_flower && blockIn != Blocks.red_flower && blockIn != Blocks.cactus && blockIn != Blocks.brown_mushroom && blockIn != Blocks.red_mushroom && blockIn != Blocks.sapling && blockIn != Blocks.deadbush ? blockIn == Blocks.tallgrass && meta == BlockTallGrass.EnumType.FERN.getMeta() : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
|
||||||
|
return tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null ? tileentityflowerpot.getFlowerPotItem() : Items.flower_pot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDamageValue(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
|
||||||
|
return tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null ? tileentityflowerpot.getFlowerPotData() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true only if block is flowerPot
|
||||||
|
*/
|
||||||
|
public boolean isFlowerPot()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return super.canPlaceBlockAt(worldIn, pos) && World.doesBlockHaveSolidTopSurface(worldIn, pos.down());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
|
||||||
|
|
||||||
|
if (tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null)
|
||||||
|
{
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(tileentityflowerpot.getFlowerPotItem(), 1, tileentityflowerpot.getFlowerPotData()));
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
|
||||||
|
{
|
||||||
|
super.onBlockHarvested(worldIn, pos, state, player);
|
||||||
|
|
||||||
|
if (player.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
|
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
|
||||||
|
|
||||||
|
if (tileentityflowerpot != null)
|
||||||
|
{
|
||||||
|
tileentityflowerpot.setFlowerPotData((Item)null, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Items.flower_pot;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TileEntityFlowerPot getTileEntity(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
return tileentity instanceof TileEntityFlowerPot ? (TileEntityFlowerPot)tileentity : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
Block block = null;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
switch (meta)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
block = Blocks.red_flower;
|
||||||
|
i = BlockFlower.EnumFlowerType.POPPY.getMeta();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
block = Blocks.yellow_flower;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
block = Blocks.sapling;
|
||||||
|
i = BlockPlanks.EnumType.OAK.getMetadata();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
block = Blocks.sapling;
|
||||||
|
i = BlockPlanks.EnumType.SPRUCE.getMetadata();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
block = Blocks.sapling;
|
||||||
|
i = BlockPlanks.EnumType.BIRCH.getMetadata();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
block = Blocks.sapling;
|
||||||
|
i = BlockPlanks.EnumType.JUNGLE.getMetadata();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
block = Blocks.red_mushroom;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
block = Blocks.brown_mushroom;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 9:
|
||||||
|
block = Blocks.cactus;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10:
|
||||||
|
block = Blocks.deadbush;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 11:
|
||||||
|
block = Blocks.tallgrass;
|
||||||
|
i = BlockTallGrass.EnumType.FERN.getMeta();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 12:
|
||||||
|
block = Blocks.sapling;
|
||||||
|
i = BlockPlanks.EnumType.ACACIA.getMetadata();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 13:
|
||||||
|
block = Blocks.sapling;
|
||||||
|
i = BlockPlanks.EnumType.DARK_OAK.getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TileEntityFlowerPot(Item.getItemFromBlock(block), i);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {CONTENTS, LEGACY_DATA});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(LEGACY_DATA)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
BlockFlowerPot.EnumFlowerType blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.EMPTY;
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityFlowerPot)
|
||||||
|
{
|
||||||
|
TileEntityFlowerPot tileentityflowerpot = (TileEntityFlowerPot)tileentity;
|
||||||
|
Item item = tileentityflowerpot.getFlowerPotItem();
|
||||||
|
|
||||||
|
if (item instanceof ItemBlock)
|
||||||
|
{
|
||||||
|
int i = tileentityflowerpot.getFlowerPotData();
|
||||||
|
Block block = Block.getBlockFromItem(item);
|
||||||
|
|
||||||
|
if (block == Blocks.sapling)
|
||||||
|
{
|
||||||
|
switch (BlockPlanks.EnumType.byMetadata(i))
|
||||||
|
{
|
||||||
|
case OAK:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.OAK_SAPLING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPRUCE:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.SPRUCE_SAPLING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BIRCH:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.BIRCH_SAPLING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JUNGLE:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.JUNGLE_SAPLING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ACACIA:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.ACACIA_SAPLING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DARK_OAK:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.DARK_OAK_SAPLING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (block == Blocks.tallgrass)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.DEAD_BUSH;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.FERN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (block == Blocks.yellow_flower)
|
||||||
|
{
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.DANDELION;
|
||||||
|
}
|
||||||
|
else if (block == Blocks.red_flower)
|
||||||
|
{
|
||||||
|
switch (BlockFlower.EnumFlowerType.getType(BlockFlower.EnumFlowerColor.RED, i))
|
||||||
|
{
|
||||||
|
case POPPY:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.POPPY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BLUE_ORCHID:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.BLUE_ORCHID;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ALLIUM:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.ALLIUM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HOUSTONIA:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.HOUSTONIA;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RED_TULIP:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.RED_TULIP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ORANGE_TULIP:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.ORANGE_TULIP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WHITE_TULIP:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.WHITE_TULIP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PINK_TULIP:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.PINK_TULIP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OXEYE_DAISY:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.OXEYE_DAISY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (block == Blocks.red_mushroom)
|
||||||
|
{
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.MUSHROOM_RED;
|
||||||
|
}
|
||||||
|
else if (block == Blocks.brown_mushroom)
|
||||||
|
{
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.MUSHROOM_BROWN;
|
||||||
|
}
|
||||||
|
else if (block == Blocks.deadbush)
|
||||||
|
{
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.DEAD_BUSH;
|
||||||
|
}
|
||||||
|
else if (block == Blocks.cactus)
|
||||||
|
{
|
||||||
|
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.CACTUS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return state.withProperty(CONTENTS, blockflowerpot$enumflowertype);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumFlowerType implements IStringSerializable
|
||||||
|
{
|
||||||
|
EMPTY("empty"),
|
||||||
|
POPPY("rose"),
|
||||||
|
BLUE_ORCHID("blue_orchid"),
|
||||||
|
ALLIUM("allium"),
|
||||||
|
HOUSTONIA("houstonia"),
|
||||||
|
RED_TULIP("red_tulip"),
|
||||||
|
ORANGE_TULIP("orange_tulip"),
|
||||||
|
WHITE_TULIP("white_tulip"),
|
||||||
|
PINK_TULIP("pink_tulip"),
|
||||||
|
OXEYE_DAISY("oxeye_daisy"),
|
||||||
|
DANDELION("dandelion"),
|
||||||
|
OAK_SAPLING("oak_sapling"),
|
||||||
|
SPRUCE_SAPLING("spruce_sapling"),
|
||||||
|
BIRCH_SAPLING("birch_sapling"),
|
||||||
|
JUNGLE_SAPLING("jungle_sapling"),
|
||||||
|
ACACIA_SAPLING("acacia_sapling"),
|
||||||
|
DARK_OAK_SAPLING("dark_oak_sapling"),
|
||||||
|
MUSHROOM_RED("mushroom_red"),
|
||||||
|
MUSHROOM_BROWN("mushroom_brown"),
|
||||||
|
DEAD_BUSH("dead_bush"),
|
||||||
|
FERN("fern"),
|
||||||
|
CACTUS("cactus");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private EnumFlowerType(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
272
client/src/main/java/net/minecraft/block/BlockFurnace.java
Normal file
272
client/src/main/java/net/minecraft/block/BlockFurnace.java
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
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;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockFurnace extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
private final boolean isBurning;
|
||||||
|
private static boolean keepInventory;
|
||||||
|
|
||||||
|
protected BlockFurnace(boolean isBurning)
|
||||||
|
{
|
||||||
|
super(Material.rock);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||||
|
this.isBurning = isBurning;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(Blocks.furnace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.setDefaultFacing(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("incomplete-switch")
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (this.isBurning)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
double d0 = (double)pos.getX() + 0.5D;
|
||||||
|
double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
|
||||||
|
double d2 = (double)pos.getZ() + 0.5D;
|
||||||
|
double d3 = 0.52D;
|
||||||
|
double d4 = rand.nextDouble() * 0.6D - 0.3D;
|
||||||
|
|
||||||
|
switch (enumfacing)
|
||||||
|
{
|
||||||
|
case WEST:
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EAST:
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityFurnace)
|
||||||
|
{
|
||||||
|
playerIn.displayGUIChest((TileEntityFurnace)tileentity);
|
||||||
|
playerIn.triggerAchievement(StatList.field_181741_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setState(boolean active, World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
keepInventory = true;
|
||||||
|
|
||||||
|
if (active)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.lit_furnace.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||||
|
worldIn.setBlockState(pos, Blocks.lit_furnace.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.furnace.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||||
|
worldIn.setBlockState(pos, Blocks.furnace.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
keepInventory = false;
|
||||||
|
|
||||||
|
if (tileentity != null)
|
||||||
|
{
|
||||||
|
tileentity.validate();
|
||||||
|
worldIn.setTileEntity(pos, tileentity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityFurnace();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
|
||||||
|
|
||||||
|
if (stack.hasDisplayName())
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityFurnace)
|
||||||
|
{
|
||||||
|
((TileEntityFurnace)tileentity).setCustomInventoryName(stack.getDisplayName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (!keepInventory)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityFurnace)
|
||||||
|
{
|
||||||
|
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityFurnace)tileentity);
|
||||||
|
worldIn.updateComparatorOutputLevel(pos, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Container.calcRedstone(worldIn.getTileEntity(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(Blocks.furnace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
|
||||||
|
*/
|
||||||
|
public IBlockState getStateForEntityRender(IBlockState state)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = EnumFacing.getFront(meta);
|
||||||
|
|
||||||
|
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
|
||||||
|
{
|
||||||
|
enumfacing = EnumFacing.NORTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState().withProperty(FACING, enumfacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING});
|
||||||
|
}
|
||||||
|
}
|
||||||
38
client/src/main/java/net/minecraft/block/BlockGlass.java
Normal file
38
client/src/main/java/net/minecraft/block/BlockGlass.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
|
||||||
|
public class BlockGlass extends BlockBreakable
|
||||||
|
{
|
||||||
|
public BlockGlass(Material materialIn, boolean ignoreSimilarity)
|
||||||
|
{
|
||||||
|
super(materialIn, ignoreSimilarity);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canSilkHarvest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
51
client/src/main/java/net/minecraft/block/BlockGlowstone.java
Normal file
51
client/src/main/java/net/minecraft/block/BlockGlowstone.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
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.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
|
||||||
|
public class BlockGlowstone extends Block
|
||||||
|
{
|
||||||
|
public BlockGlowstone(Material materialIn)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the quantity dropped based on the given fortune level
|
||||||
|
*/
|
||||||
|
public int quantityDroppedWithBonus(int fortune, Random random)
|
||||||
|
{
|
||||||
|
return MathHelper.clamp_int(this.quantityDropped(random) + random.nextInt(fortune + 1), 1, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 2 + random.nextInt(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Items.glowstone_dust;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return MapColor.sandColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
174
client/src/main/java/net/minecraft/block/BlockGrass.java
Normal file
174
client/src/main/java/net/minecraft/block/BlockGrass.java
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.ColorizerGrass;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.biome.BiomeColorHelper;
|
||||||
|
|
||||||
|
public class BlockGrass extends Block implements IGrowable
|
||||||
|
{
|
||||||
|
public static final PropertyBool SNOWY = PropertyBool.create("snowy");
|
||||||
|
|
||||||
|
protected BlockGrass()
|
||||||
|
{
|
||||||
|
super(Material.grass);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
Block block = worldIn.getBlockState(pos.up()).getBlock();
|
||||||
|
return state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockColor()
|
||||||
|
{
|
||||||
|
return ColorizerGrass.getGrassColor(0.5D, 1.0D);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRenderColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return this.getBlockColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||||
|
{
|
||||||
|
return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getBlock().getLightOpacity() > 2)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
|
||||||
|
Block block = worldIn.getBlockState(blockpos.up()).getBlock();
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos, Blocks.grass.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Blocks.dirt.getItemDropped(Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this IGrowable can grow
|
||||||
|
*/
|
||||||
|
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.up();
|
||||||
|
|
||||||
|
for (int i = 0; i < 128; ++i)
|
||||||
|
{
|
||||||
|
BlockPos blockpos1 = blockpos;
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (j >= i / 16)
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(blockpos1).getBlock().blockMaterial == Material.air)
|
||||||
|
{
|
||||||
|
if (rand.nextInt(8) == 0)
|
||||||
|
{
|
||||||
|
BlockFlower.EnumFlowerType blockflower$enumflowertype = worldIn.getBiomeGenForCoords(blockpos1).pickRandomFlower(rand, blockpos1);
|
||||||
|
BlockFlower blockflower = blockflower$enumflowertype.getBlockType().getBlock();
|
||||||
|
IBlockState iblockstate = blockflower.getDefaultState().withProperty(blockflower.getTypeProperty(), blockflower$enumflowertype);
|
||||||
|
|
||||||
|
if (blockflower.canBlockStay(worldIn, blockpos1, iblockstate))
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos1, iblockstate, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IBlockState iblockstate1 = Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS);
|
||||||
|
|
||||||
|
if (Blocks.tallgrass.canBlockStay(worldIn, blockpos1, iblockstate1))
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos1, iblockstate1, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(blockpos1.down()).getBlock() != Blocks.grass || worldIn.getBlockState(blockpos1).getBlock().isNormalCube())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT_MIPPED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {SNOWY});
|
||||||
|
}
|
||||||
|
}
|
||||||
31
client/src/main/java/net/minecraft/block/BlockGravel.java
Normal file
31
client/src/main/java/net/minecraft/block/BlockGravel.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
public class BlockGravel extends BlockFalling
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
if (fortune > 3)
|
||||||
|
{
|
||||||
|
fortune = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rand.nextInt(10 - fortune * 3) == 0 ? Items.flint : Item.getItemFromBlock(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return MapColor.stoneColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
public class BlockHalfStoneSlab extends BlockStoneSlab
|
||||||
|
{
|
||||||
|
public boolean isDouble()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
public class BlockHalfStoneSlabNew extends BlockStoneSlabNew
|
||||||
|
{
|
||||||
|
public boolean isDouble()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
public class BlockHalfWoodSlab extends BlockWoodSlab
|
||||||
|
{
|
||||||
|
public boolean isDouble()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
|
||||||
|
public class BlockHardenedClay extends Block
|
||||||
|
{
|
||||||
|
public BlockHardenedClay()
|
||||||
|
{
|
||||||
|
super(Material.rock);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return MapColor.adobeColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
83
client/src/main/java/net/minecraft/block/BlockHay.java
Normal file
83
client/src/main/java/net/minecraft/block/BlockHay.java
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockHay extends BlockRotatedPillar
|
||||||
|
{
|
||||||
|
public BlockHay()
|
||||||
|
{
|
||||||
|
super(Material.grass, MapColor.yellowColor);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Y;
|
||||||
|
int i = meta & 12;
|
||||||
|
|
||||||
|
if (i == 4)
|
||||||
|
{
|
||||||
|
enumfacing$axis = EnumFacing.Axis.X;
|
||||||
|
}
|
||||||
|
else if (i == 8)
|
||||||
|
{
|
||||||
|
enumfacing$axis = EnumFacing.Axis.Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState().withProperty(AXIS, enumfacing$axis);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)state.getValue(AXIS);
|
||||||
|
|
||||||
|
if (enumfacing$axis == EnumFacing.Axis.X)
|
||||||
|
{
|
||||||
|
i |= 4;
|
||||||
|
}
|
||||||
|
else if (enumfacing$axis == EnumFacing.Axis.Z)
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {AXIS});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ItemStack createStackedBlock(IBlockState state)
|
||||||
|
{
|
||||||
|
return new ItemStack(Item.getItemFromBlock(this), 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(AXIS, facing.getAxis());
|
||||||
|
}
|
||||||
|
}
|
||||||
253
client/src/main/java/net/minecraft/block/BlockHopper.java
Normal file
253
client/src/main/java/net/minecraft/block/BlockHopper.java
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
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;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockHopper extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", new Predicate<EnumFacing>()
|
||||||
|
{
|
||||||
|
public boolean apply(EnumFacing p_apply_1_)
|
||||||
|
{
|
||||||
|
return p_apply_1_ != EnumFacing.UP;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
public static final PropertyBool ENABLED = PropertyBool.create("enabled");
|
||||||
|
|
||||||
|
public BlockHopper()
|
||||||
|
{
|
||||||
|
super(Material.iron, MapColor.stoneColor);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.DOWN).withProperty(ENABLED, Boolean.valueOf(true)));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
float f = 0.125F;
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = facing.getOpposite();
|
||||||
|
|
||||||
|
if (enumfacing == EnumFacing.UP)
|
||||||
|
{
|
||||||
|
enumfacing = EnumFacing.DOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState().withProperty(FACING, enumfacing).withProperty(ENABLED, Boolean.valueOf(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityHopper();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
|
||||||
|
|
||||||
|
if (stack.hasDisplayName())
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityHopper)
|
||||||
|
{
|
||||||
|
((TileEntityHopper)tileentity).setCustomName(stack.getDisplayName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.updateState(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityHopper)
|
||||||
|
{
|
||||||
|
playerIn.displayGUIChest((TileEntityHopper)tileentity);
|
||||||
|
playerIn.triggerAchievement(StatList.field_181732_P);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
this.updateState(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
boolean flag = !worldIn.isBlockPowered(pos);
|
||||||
|
|
||||||
|
if (flag != ((Boolean)state.getValue(ENABLED)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(ENABLED, Boolean.valueOf(flag)), 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityHopper)
|
||||||
|
{
|
||||||
|
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityHopper)tileentity);
|
||||||
|
worldIn.updateComparatorOutputLevel(pos, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumFacing getFacing(int meta)
|
||||||
|
{
|
||||||
|
return EnumFacing.getFront(meta & 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get's the hopper's active status from the 8-bit of the metadata. Note that the metadata stores whether the block
|
||||||
|
* is powered, so this returns true when that bit is 0.
|
||||||
|
*/
|
||||||
|
public static boolean isEnabled(int meta)
|
||||||
|
{
|
||||||
|
return (meta & 8) != 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Container.calcRedstone(worldIn.getTileEntity(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT_MIPPED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, getFacing(meta)).withProperty(ENABLED, Boolean.valueOf(isEnabled(meta)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
|
||||||
|
if (!((Boolean)state.getValue(ENABLED)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, ENABLED});
|
||||||
|
}
|
||||||
|
}
|
||||||
160
client/src/main/java/net/minecraft/block/BlockHugeMushroom.java
Normal file
160
client/src/main/java/net/minecraft/block/BlockHugeMushroom.java
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockHugeMushroom extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockHugeMushroom.EnumType> VARIANT = PropertyEnum.<BlockHugeMushroom.EnumType>create("variant", BlockHugeMushroom.EnumType.class);
|
||||||
|
private final Block smallBlock;
|
||||||
|
|
||||||
|
public BlockHugeMushroom(Material p_i46392_1_, MapColor p_i46392_2_, Block p_i46392_3_)
|
||||||
|
{
|
||||||
|
super(p_i46392_1_, p_i46392_2_);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockHugeMushroom.EnumType.ALL_OUTSIDE));
|
||||||
|
this.smallBlock = p_i46392_3_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return Math.max(0, random.nextInt(10) - 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
switch ((BlockHugeMushroom.EnumType)state.getValue(VARIANT))
|
||||||
|
{
|
||||||
|
case ALL_STEM:
|
||||||
|
return MapColor.clothColor;
|
||||||
|
|
||||||
|
case ALL_INSIDE:
|
||||||
|
return MapColor.sandColor;
|
||||||
|
|
||||||
|
case STEM:
|
||||||
|
return MapColor.sandColor;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return super.getMapColor(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(this.smallBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(this.smallBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(VARIANT, BlockHugeMushroom.EnumType.byMetadata(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {VARIANT});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumType implements IStringSerializable
|
||||||
|
{
|
||||||
|
NORTH_WEST(1, "north_west"),
|
||||||
|
NORTH(2, "north"),
|
||||||
|
NORTH_EAST(3, "north_east"),
|
||||||
|
WEST(4, "west"),
|
||||||
|
CENTER(5, "center"),
|
||||||
|
EAST(6, "east"),
|
||||||
|
SOUTH_WEST(7, "south_west"),
|
||||||
|
SOUTH(8, "south"),
|
||||||
|
SOUTH_EAST(9, "south_east"),
|
||||||
|
STEM(10, "stem"),
|
||||||
|
ALL_INSIDE(0, "all_inside"),
|
||||||
|
ALL_OUTSIDE(14, "all_outside"),
|
||||||
|
ALL_STEM(15, "all_stem");
|
||||||
|
|
||||||
|
private static final BlockHugeMushroom.EnumType[] META_LOOKUP = new BlockHugeMushroom.EnumType[16];
|
||||||
|
private final int meta;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private EnumType(int meta, String name)
|
||||||
|
{
|
||||||
|
this.meta = meta;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMetadata()
|
||||||
|
{
|
||||||
|
return this.meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockHugeMushroom.EnumType byMetadata(int meta)
|
||||||
|
{
|
||||||
|
if (meta < 0 || meta >= META_LOOKUP.length)
|
||||||
|
{
|
||||||
|
meta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockHugeMushroom.EnumType blockhugemushroom$enumtype = META_LOOKUP[meta];
|
||||||
|
return blockhugemushroom$enumtype == null ? META_LOOKUP[0] : blockhugemushroom$enumtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (BlockHugeMushroom.EnumType blockhugemushroom$enumtype : values())
|
||||||
|
{
|
||||||
|
META_LOOKUP[blockhugemushroom$enumtype.getMetadata()] = blockhugemushroom$enumtype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
94
client/src/main/java/net/minecraft/block/BlockIce.java
Normal file
94
client/src/main/java/net/minecraft/block/BlockIce.java
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
|
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.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.EnumSkyBlock;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockIce extends BlockBreakable
|
||||||
|
{
|
||||||
|
public BlockIce()
|
||||||
|
{
|
||||||
|
super(Material.ice, false);
|
||||||
|
this.slipperiness = 0.98F;
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.TRANSLUCENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
|
||||||
|
{
|
||||||
|
player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||||
|
player.addExhaustion(0.025F);
|
||||||
|
|
||||||
|
if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
|
||||||
|
{
|
||||||
|
ItemStack itemstack = this.createStackedBlock(state);
|
||||||
|
|
||||||
|
if (itemstack != null)
|
||||||
|
{
|
||||||
|
spawnAsEntity(worldIn, pos, itemstack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (worldIn.provider.doesWaterVaporize())
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = EnchantmentHelper.getFortuneModifier(player);
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, i);
|
||||||
|
Material material = worldIn.getBlockState(pos.down()).getBlock().getMaterial();
|
||||||
|
|
||||||
|
if (material.blocksMovement() || material.isLiquid())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.flowing_water.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11 - this.getLightOpacity())
|
||||||
|
{
|
||||||
|
if (worldIn.provider.doesWaterVaporize())
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
|
||||||
|
worldIn.setBlockState(pos, Blocks.water.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMobilityFlag()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
205
client/src/main/java/net/minecraft/block/BlockJukebox.java
Normal file
205
client/src/main/java/net/minecraft/block/BlockJukebox.java
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.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;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockJukebox extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyBool HAS_RECORD = PropertyBool.create("has_record");
|
||||||
|
|
||||||
|
protected BlockJukebox()
|
||||||
|
{
|
||||||
|
super(Material.wood, MapColor.dirtColor);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(HAS_RECORD, Boolean.valueOf(false)));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(HAS_RECORD)).booleanValue())
|
||||||
|
{
|
||||||
|
this.dropRecord(worldIn, pos, state);
|
||||||
|
state = state.withProperty(HAS_RECORD, Boolean.valueOf(false));
|
||||||
|
worldIn.setBlockState(pos, state, 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.dropRecord(worldIn, pos, state);
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new BlockJukebox.TileEntityJukebox();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComparatorInputOverride()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComparatorInputOverride(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof BlockJukebox.TileEntityJukebox)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = ((BlockJukebox.TileEntityJukebox)tileentity).getRecord();
|
||||||
|
|
||||||
|
if (itemstack != null)
|
||||||
|
{
|
||||||
|
return Item.getIdFromItem(itemstack.getItem()) + 1 - Item.getIdFromItem(Items.record_13);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(HAS_RECORD, Boolean.valueOf(meta > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Boolean)state.getValue(HAS_RECORD)).booleanValue() ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {HAS_RECORD});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TileEntityJukebox extends TileEntity
|
||||||
|
{
|
||||||
|
private ItemStack record;
|
||||||
|
|
||||||
|
public void readFromNBT(NBTTagCompound compound)
|
||||||
|
{
|
||||||
|
super.readFromNBT(compound);
|
||||||
|
|
||||||
|
if (compound.hasKey("RecordItem", 10))
|
||||||
|
{
|
||||||
|
this.setRecord(ItemStack.loadItemStackFromNBT(compound.getCompoundTag("RecordItem")));
|
||||||
|
}
|
||||||
|
else if (compound.getInteger("Record") > 0)
|
||||||
|
{
|
||||||
|
this.setRecord(new ItemStack(Item.getItemById(compound.getInteger("Record")), 1, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToNBT(NBTTagCompound compound)
|
||||||
|
{
|
||||||
|
super.writeToNBT(compound);
|
||||||
|
|
||||||
|
if (this.getRecord() != null)
|
||||||
|
{
|
||||||
|
compound.setTag("RecordItem", this.getRecord().writeToNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getRecord()
|
||||||
|
{
|
||||||
|
return this.record;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecord(ItemStack recordStack)
|
||||||
|
{
|
||||||
|
this.record = recordStack;
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
164
client/src/main/java/net/minecraft/block/BlockLadder.java
Normal file
164
client/src/main/java/net/minecraft/block/BlockLadder.java
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.EntityLivingBase;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockLadder extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
|
||||||
|
protected BlockLadder()
|
||||||
|
{
|
||||||
|
super(Material.circuits);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
return super.getCollisionBoundingBox(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
return super.getSelectedBoundingBox(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
float f = 0.125F;
|
||||||
|
|
||||||
|
switch ((EnumFacing)iblockstate.getValue(FACING))
|
||||||
|
{
|
||||||
|
case NORTH:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EAST:
|
||||||
|
default:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos.west()).getBlock().isNormalCube() ? true : (worldIn.getBlockState(pos.east()).getBlock().isNormalCube() ? true : (worldIn.getBlockState(pos.north()).getBlock().isNormalCube() ? true : worldIn.getBlockState(pos.south()).getBlock().isNormalCube()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
if (facing.getAxis().isHorizontal() && this.canBlockStay(worldIn, pos, facing))
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, facing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
if (this.canBlockStay(worldIn, pos, enumfacing))
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, enumfacing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
|
||||||
|
if (!this.canBlockStay(worldIn, pos, enumfacing))
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canBlockStay(World worldIn, BlockPos pos, EnumFacing facing)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos.offset(facing.getOpposite())).getBlock().isNormalCube();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = EnumFacing.getFront(meta);
|
||||||
|
|
||||||
|
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
|
||||||
|
{
|
||||||
|
enumfacing = EnumFacing.NORTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getDefaultState().withProperty(FACING, enumfacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING});
|
||||||
|
}
|
||||||
|
}
|
||||||
304
client/src/main/java/net/minecraft/block/BlockLeaves.java
Normal file
304
client/src/main/java/net/minecraft/block/BlockLeaves.java
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
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;
|
||||||
|
import net.minecraft.world.ColorizerFoliage;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.biome.BiomeColorHelper;
|
||||||
|
|
||||||
|
public abstract class BlockLeaves extends BlockLeavesBase
|
||||||
|
{
|
||||||
|
public static final PropertyBool DECAYABLE = PropertyBool.create("decayable");
|
||||||
|
public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay");
|
||||||
|
int[] surroundings;
|
||||||
|
protected int iconIndex;
|
||||||
|
protected boolean isTransparent;
|
||||||
|
|
||||||
|
public BlockLeaves()
|
||||||
|
{
|
||||||
|
super(Material.leaves, false);
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
this.setHardness(0.2F);
|
||||||
|
this.setLightOpacity(1);
|
||||||
|
this.setStepSound(soundTypeGrass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockColor()
|
||||||
|
{
|
||||||
|
return ColorizerFoliage.getFoliageColor(0.5D, 1.0D);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRenderColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return ColorizerFoliage.getFoliageColorBasic();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||||
|
{
|
||||||
|
return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
int j = i + 1;
|
||||||
|
int k = pos.getX();
|
||||||
|
int l = pos.getY();
|
||||||
|
int i1 = pos.getZ();
|
||||||
|
|
||||||
|
if (worldIn.isAreaLoaded(new BlockPos(k - j, l - j, i1 - j), new BlockPos(k + j, l + j, i1 + j)))
|
||||||
|
{
|
||||||
|
for (int j1 = -i; j1 <= i; ++j1)
|
||||||
|
{
|
||||||
|
for (int k1 = -i; k1 <= i; ++k1)
|
||||||
|
{
|
||||||
|
for (int l1 = -i; l1 <= i; ++l1)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.add(j1, k1, l1);
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock().getMaterial() == Material.leaves && !((Boolean)iblockstate.getValue(CHECK_DECAY)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos, iblockstate.withProperty(CHECK_DECAY, Boolean.valueOf(true)), 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue() && ((Boolean)state.getValue(DECAYABLE)).booleanValue())
|
||||||
|
{
|
||||||
|
int i = 4;
|
||||||
|
int j = i + 1;
|
||||||
|
int k = pos.getX();
|
||||||
|
int l = pos.getY();
|
||||||
|
int i1 = pos.getZ();
|
||||||
|
int j1 = 32;
|
||||||
|
int k1 = j1 * j1;
|
||||||
|
int l1 = j1 / 2;
|
||||||
|
|
||||||
|
if (this.surroundings == null)
|
||||||
|
{
|
||||||
|
this.surroundings = new int[j1 * j1 * j1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.isAreaLoaded(new BlockPos(k - j, l - j, i1 - j), new BlockPos(k + j, l + j, i1 + j)))
|
||||||
|
{
|
||||||
|
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||||
|
|
||||||
|
for (int i2 = -i; i2 <= i; ++i2)
|
||||||
|
{
|
||||||
|
for (int j2 = -i; j2 <= i; ++j2)
|
||||||
|
{
|
||||||
|
for (int k2 = -i; k2 <= i; ++k2)
|
||||||
|
{
|
||||||
|
Block block = worldIn.getBlockState(blockpos$mutableblockpos.func_181079_c(k + i2, l + j2, i1 + k2)).getBlock();
|
||||||
|
|
||||||
|
if (block != Blocks.log && block != Blocks.log2)
|
||||||
|
{
|
||||||
|
if (block.getMaterial() == Material.leaves)
|
||||||
|
{
|
||||||
|
this.surroundings[(i2 + l1) * k1 + (j2 + l1) * j1 + k2 + l1] = -2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.surroundings[(i2 + l1) * k1 + (j2 + l1) * j1 + k2 + l1] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.surroundings[(i2 + l1) * k1 + (j2 + l1) * j1 + k2 + l1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i3 = 1; i3 <= 4; ++i3)
|
||||||
|
{
|
||||||
|
for (int j3 = -i; j3 <= i; ++j3)
|
||||||
|
{
|
||||||
|
for (int k3 = -i; k3 <= i; ++k3)
|
||||||
|
{
|
||||||
|
for (int l3 = -i; l3 <= i; ++l3)
|
||||||
|
{
|
||||||
|
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + l3 + l1] == i3 - 1)
|
||||||
|
{
|
||||||
|
if (this.surroundings[(j3 + l1 - 1) * k1 + (k3 + l1) * j1 + l3 + l1] == -2)
|
||||||
|
{
|
||||||
|
this.surroundings[(j3 + l1 - 1) * k1 + (k3 + l1) * j1 + l3 + l1] = i3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.surroundings[(j3 + l1 + 1) * k1 + (k3 + l1) * j1 + l3 + l1] == -2)
|
||||||
|
{
|
||||||
|
this.surroundings[(j3 + l1 + 1) * k1 + (k3 + l1) * j1 + l3 + l1] = i3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1 - 1) * j1 + l3 + l1] == -2)
|
||||||
|
{
|
||||||
|
this.surroundings[(j3 + l1) * k1 + (k3 + l1 - 1) * j1 + l3 + l1] = i3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1 + 1) * j1 + l3 + l1] == -2)
|
||||||
|
{
|
||||||
|
this.surroundings[(j3 + l1) * k1 + (k3 + l1 + 1) * j1 + l3 + l1] = i3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + (l3 + l1 - 1)] == -2)
|
||||||
|
{
|
||||||
|
this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + (l3 + l1 - 1)] = i3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + l3 + l1 + 1] == -2)
|
||||||
|
{
|
||||||
|
this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + l3 + l1 + 1] = i3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int l2 = this.surroundings[l1 * k1 + l1 * j1 + l1];
|
||||||
|
|
||||||
|
if (l2 >= 0)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(CHECK_DECAY, Boolean.valueOf(false)), 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.destroy(worldIn, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (worldIn.canLightningStrike(pos.up()) && !World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && rand.nextInt(15) == 1)
|
||||||
|
{
|
||||||
|
double d0 = (double)((float)pos.getX() + rand.nextFloat());
|
||||||
|
double d1 = (double)pos.getY() - 0.05D;
|
||||||
|
double d2 = (double)((float)pos.getZ() + rand.nextFloat());
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void destroy(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return random.nextInt(20) == 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(Blocks.sapling);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
int i = this.getSaplingDropChance(state);
|
||||||
|
|
||||||
|
if (fortune > 0)
|
||||||
|
{
|
||||||
|
i -= 2 << fortune;
|
||||||
|
|
||||||
|
if (i < 10)
|
||||||
|
{
|
||||||
|
i = 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.rand.nextInt(i) == 0)
|
||||||
|
{
|
||||||
|
Item item = this.getItemDropped(state, worldIn.rand, fortune);
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(item, 1, this.damageDropped(state)));
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 200;
|
||||||
|
|
||||||
|
if (fortune > 0)
|
||||||
|
{
|
||||||
|
i -= 10 << fortune;
|
||||||
|
|
||||||
|
if (i < 40)
|
||||||
|
{
|
||||||
|
i = 40;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dropApple(worldIn, pos, state, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getSaplingDropChance(IBlockState state)
|
||||||
|
{
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return !this.fancyGraphics;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass true to draw this block using fancy graphics, or false for fast graphics.
|
||||||
|
*/
|
||||||
|
public void setGraphicsLevel(boolean fancy)
|
||||||
|
{
|
||||||
|
this.isTransparent = fancy;
|
||||||
|
this.fancyGraphics = fancy;
|
||||||
|
this.iconIndex = fancy ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return this.isTransparent ? EnumWorldBlockLayer.CUTOUT_MIPPED : EnumWorldBlockLayer.SOLID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVisuallyOpaque()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract BlockPlanks.EnumType getWoodType(int meta);
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
|
public class BlockLeavesBase extends Block
|
||||||
|
{
|
||||||
|
protected boolean fancyGraphics;
|
||||||
|
|
||||||
|
protected BlockLeavesBase(Material materialIn, boolean fancyGraphics)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
this.fancyGraphics = fancyGraphics;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return !this.fancyGraphics && worldIn.getBlockState(pos).getBlock() == this ? false : super.shouldSideBeRendered(worldIn, pos, side);
|
||||||
|
}
|
||||||
|
}
|
||||||
380
client/src/main/java/net/minecraft/block/BlockLever.java
Normal file
380
client/src/main/java/net/minecraft/block/BlockLever.java
Normal file
@@ -0,0 +1,380 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockLever extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockLever.EnumOrientation> FACING = PropertyEnum.<BlockLever.EnumOrientation>create("facing", BlockLever.EnumOrientation.class);
|
||||||
|
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||||
|
|
||||||
|
protected BlockLever()
|
||||||
|
{
|
||||||
|
super(Material.circuits);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, BlockLever.EnumOrientation.NORTH).withProperty(POWERED, Boolean.valueOf(false)));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether this Block can be placed on the given side
|
||||||
|
*/
|
||||||
|
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return func_181090_a(worldIn, pos, side.getOpposite());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.values())
|
||||||
|
{
|
||||||
|
if (func_181090_a(worldIn, pos, enumfacing))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean func_181090_a(World p_181090_0_, BlockPos p_181090_1_, EnumFacing p_181090_2_)
|
||||||
|
{
|
||||||
|
return BlockButton.func_181088_a(p_181090_0_, p_181090_1_, p_181090_2_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = this.getDefaultState().withProperty(POWERED, Boolean.valueOf(false));
|
||||||
|
|
||||||
|
if (func_181090_a(worldIn, pos, facing.getOpposite()))
|
||||||
|
{
|
||||||
|
return iblockstate.withProperty(FACING, BlockLever.EnumOrientation.forFacings(facing, placer.getHorizontalFacing()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
if (enumfacing != facing && func_181090_a(worldIn, pos, enumfacing.getOpposite()))
|
||||||
|
{
|
||||||
|
return iblockstate.withProperty(FACING, BlockLever.EnumOrientation.forFacings(enumfacing, placer.getHorizontalFacing()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
|
||||||
|
{
|
||||||
|
return iblockstate.withProperty(FACING, BlockLever.EnumOrientation.forFacings(EnumFacing.UP, placer.getHorizontalFacing()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return iblockstate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMetadataForFacing(EnumFacing facing)
|
||||||
|
{
|
||||||
|
switch (facing)
|
||||||
|
{
|
||||||
|
case DOWN:
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case UP:
|
||||||
|
return 5;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
return 4;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
case EAST:
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (this.func_181091_e(worldIn, pos, state) && !func_181090_a(worldIn, pos, ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing().getOpposite()))
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean func_181091_e(World p_181091_1_, BlockPos p_181091_2_, IBlockState p_181091_3_)
|
||||||
|
{
|
||||||
|
if (this.canPlaceBlockAt(p_181091_1_, p_181091_2_))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(p_181091_1_, p_181091_2_, p_181091_3_, 0);
|
||||||
|
p_181091_1_.setBlockToAir(p_181091_2_);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
float f = 0.1875F;
|
||||||
|
|
||||||
|
switch ((BlockLever.EnumOrientation)worldIn.getBlockState(pos).getValue(FACING))
|
||||||
|
{
|
||||||
|
case EAST:
|
||||||
|
this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UP_Z:
|
||||||
|
case UP_X:
|
||||||
|
f = 0.25F;
|
||||||
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DOWN_X:
|
||||||
|
case DOWN_Z:
|
||||||
|
f = 0.25F;
|
||||||
|
this.setBlockBounds(0.5F - f, 0.4F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state = state.cycleProperty(POWERED);
|
||||||
|
worldIn.setBlockState(pos, state, 3);
|
||||||
|
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, ((Boolean)state.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F);
|
||||||
|
worldIn.notifyNeighborsOfStateChange(pos, this);
|
||||||
|
EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing();
|
||||||
|
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.notifyNeighborsOfStateChange(pos, this);
|
||||||
|
EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing();
|
||||||
|
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
return ((Boolean)state.getValue(POWERED)).booleanValue() ? 15 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
|
||||||
|
{
|
||||||
|
return !((Boolean)state.getValue(POWERED)).booleanValue() ? 0 : (((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing() == side ? 15 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||||
|
*/
|
||||||
|
public boolean canProvidePower()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, BlockLever.EnumOrientation.byMetadata(meta & 7)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((BlockLever.EnumOrientation)state.getValue(FACING)).getMetadata();
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, POWERED});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumOrientation implements IStringSerializable
|
||||||
|
{
|
||||||
|
DOWN_X(0, "down_x", EnumFacing.DOWN),
|
||||||
|
EAST(1, "east", EnumFacing.EAST),
|
||||||
|
WEST(2, "west", EnumFacing.WEST),
|
||||||
|
SOUTH(3, "south", EnumFacing.SOUTH),
|
||||||
|
NORTH(4, "north", EnumFacing.NORTH),
|
||||||
|
UP_Z(5, "up_z", EnumFacing.UP),
|
||||||
|
UP_X(6, "up_x", EnumFacing.UP),
|
||||||
|
DOWN_Z(7, "down_z", EnumFacing.DOWN);
|
||||||
|
|
||||||
|
private static final BlockLever.EnumOrientation[] META_LOOKUP = new BlockLever.EnumOrientation[values().length];
|
||||||
|
private final int meta;
|
||||||
|
private final String name;
|
||||||
|
private final EnumFacing facing;
|
||||||
|
|
||||||
|
private EnumOrientation(int meta, String name, EnumFacing facing)
|
||||||
|
{
|
||||||
|
this.meta = meta;
|
||||||
|
this.name = name;
|
||||||
|
this.facing = facing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMetadata()
|
||||||
|
{
|
||||||
|
return this.meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumFacing getFacing()
|
||||||
|
{
|
||||||
|
return this.facing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockLever.EnumOrientation byMetadata(int meta)
|
||||||
|
{
|
||||||
|
if (meta < 0 || meta >= META_LOOKUP.length)
|
||||||
|
{
|
||||||
|
meta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return META_LOOKUP[meta];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockLever.EnumOrientation forFacings(EnumFacing clickedSide, EnumFacing entityFacing)
|
||||||
|
{
|
||||||
|
switch (clickedSide)
|
||||||
|
{
|
||||||
|
case DOWN:
|
||||||
|
switch (entityFacing.getAxis())
|
||||||
|
{
|
||||||
|
case X:
|
||||||
|
return DOWN_X;
|
||||||
|
|
||||||
|
case Z:
|
||||||
|
return DOWN_Z;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid entityFacing " + entityFacing + " for facing " + clickedSide);
|
||||||
|
}
|
||||||
|
|
||||||
|
case UP:
|
||||||
|
switch (entityFacing.getAxis())
|
||||||
|
{
|
||||||
|
case X:
|
||||||
|
return UP_X;
|
||||||
|
|
||||||
|
case Z:
|
||||||
|
return UP_Z;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid entityFacing " + entityFacing + " for facing " + clickedSide);
|
||||||
|
}
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
return NORTH;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
return SOUTH;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
return WEST;
|
||||||
|
|
||||||
|
case EAST:
|
||||||
|
return EAST;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid facing: " + clickedSide);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (BlockLever.EnumOrientation blocklever$enumorientation : values())
|
||||||
|
{
|
||||||
|
META_LOOKUP[blocklever$enumorientation.getMetadata()] = blocklever$enumorientation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
84
client/src/main/java/net/minecraft/block/BlockLilyPad.java
Normal file
84
client/src/main/java/net/minecraft/block/BlockLilyPad.java
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
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.entity.item.EntityBoat;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockLilyPad extends BlockBush
|
||||||
|
{
|
||||||
|
protected BlockLilyPad()
|
||||||
|
{
|
||||||
|
float f = 0.5F;
|
||||||
|
float f1 = 0.015625F;
|
||||||
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
if (collidingEntity == null || !(collidingEntity instanceof EntityBoat))
|
||||||
|
{
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockColor()
|
||||||
|
{
|
||||||
|
return 7455580;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRenderColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return 7455580;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||||
|
{
|
||||||
|
return 2129968;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is the block grass, dirt or farmland
|
||||||
|
*/
|
||||||
|
protected boolean canPlaceBlockOn(Block ground)
|
||||||
|
{
|
||||||
|
return ground == Blocks.water;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (pos.getY() >= 0 && pos.getY() < 256)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos.down());
|
||||||
|
return iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
410
client/src/main/java/net/minecraft/block/BlockLiquid.java
Normal file
410
client/src/main/java/net/minecraft/block/BlockLiquid.java
Normal file
@@ -0,0 +1,410 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.biome.BiomeColorHelper;
|
||||||
|
|
||||||
|
public abstract class BlockLiquid extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 15);
|
||||||
|
|
||||||
|
protected BlockLiquid(Material materialIn)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(LEVEL, Integer.valueOf(0)));
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return this.blockMaterial != Material.lava;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||||
|
{
|
||||||
|
return this.blockMaterial == Material.water ? BiomeColorHelper.getWaterColorAtPos(worldIn, pos) : 16777215;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the percentage of the liquid block that is air, based on the given flow decay of the liquid
|
||||||
|
*/
|
||||||
|
public static float getLiquidHeightPercent(int meta)
|
||||||
|
{
|
||||||
|
if (meta >= 8)
|
||||||
|
{
|
||||||
|
meta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float)(meta + 1) / 9.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getLevel(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos).getBlock().getMaterial() == this.blockMaterial ? ((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue() : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getEffectiveFlowDecay(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
int i = this.getLevel(worldIn, pos);
|
||||||
|
return i >= 8 ? 0 : i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid)
|
||||||
|
{
|
||||||
|
return hitIfLiquid && ((Integer)state.getValue(LEVEL)).intValue() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this Block is solid on the given Side
|
||||||
|
*/
|
||||||
|
public boolean isBlockSolid(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
|
||||||
|
return material == this.blockMaterial ? false : (side == EnumFacing.UP ? true : (material == Material.ice ? false : super.isBlockSolid(worldIn, pos, side)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos).getBlock().getMaterial() == this.blockMaterial ? false : (side == EnumFacing.UP ? true : super.shouldSideBeRendered(worldIn, pos, side));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean func_176364_g(IBlockAccess blockAccess, BlockPos pos)
|
||||||
|
{
|
||||||
|
for (int i = -1; i <= 1; ++i)
|
||||||
|
{
|
||||||
|
for (int j = -1; j <= 1; ++j)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = blockAccess.getBlockState(pos.add(i, 0, j));
|
||||||
|
Block block = iblockstate.getBlock();
|
||||||
|
Material material = block.getMaterial();
|
||||||
|
|
||||||
|
if (material != this.blockMaterial && !block.isFullBlock())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Vec3 getFlowVector(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
Vec3 vec3 = new Vec3(0.0D, 0.0D, 0.0D);
|
||||||
|
int i = this.getEffectiveFlowDecay(worldIn, pos);
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.offset(enumfacing);
|
||||||
|
int j = this.getEffectiveFlowDecay(worldIn, blockpos);
|
||||||
|
|
||||||
|
if (j < 0)
|
||||||
|
{
|
||||||
|
if (!worldIn.getBlockState(blockpos).getBlock().getMaterial().blocksMovement())
|
||||||
|
{
|
||||||
|
j = this.getEffectiveFlowDecay(worldIn, blockpos.down());
|
||||||
|
|
||||||
|
if (j >= 0)
|
||||||
|
{
|
||||||
|
int k = j - (i - 8);
|
||||||
|
vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * k), (double)((blockpos.getY() - pos.getY()) * k), (double)((blockpos.getZ() - pos.getZ()) * k));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (j >= 0)
|
||||||
|
{
|
||||||
|
int l = j - i;
|
||||||
|
vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * l), (double)((blockpos.getY() - pos.getY()) * l), (double)((blockpos.getZ() - pos.getZ()) * l));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue() >= 8)
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL)
|
||||||
|
{
|
||||||
|
BlockPos blockpos1 = pos.offset(enumfacing1);
|
||||||
|
|
||||||
|
if (this.isBlockSolid(worldIn, blockpos1, enumfacing1) || this.isBlockSolid(worldIn, blockpos1.up(), enumfacing1))
|
||||||
|
{
|
||||||
|
vec3 = vec3.normalize().addVector(0.0D, -6.0D, 0.0D);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec3.normalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3 modifyAcceleration(World worldIn, BlockPos pos, Entity entityIn, Vec3 motion)
|
||||||
|
{
|
||||||
|
return motion.add(this.getFlowVector(worldIn, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many world ticks before ticking
|
||||||
|
*/
|
||||||
|
public int tickRate(World worldIn)
|
||||||
|
{
|
||||||
|
return this.blockMaterial == Material.water ? 5 : (this.blockMaterial == Material.lava ? (worldIn.provider.getHasNoSky() ? 10 : 30) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMixedBrightnessForBlock(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
int i = worldIn.getCombinedLight(pos, 0);
|
||||||
|
int j = worldIn.getCombinedLight(pos.up(), 0);
|
||||||
|
int k = i & 255;
|
||||||
|
int l = j & 255;
|
||||||
|
int i1 = i >> 16 & 255;
|
||||||
|
int j1 = j >> 16 & 255;
|
||||||
|
return (k > l ? k : l) | (i1 > j1 ? i1 : j1) << 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return this.blockMaterial == Material.water ? EnumWorldBlockLayer.TRANSLUCENT : EnumWorldBlockLayer.SOLID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
double d0 = (double)pos.getX();
|
||||||
|
double d1 = (double)pos.getY();
|
||||||
|
double d2 = (double)pos.getZ();
|
||||||
|
|
||||||
|
if (this.blockMaterial == Material.water)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(LEVEL)).intValue();
|
||||||
|
|
||||||
|
if (i > 0 && i < 8)
|
||||||
|
{
|
||||||
|
if (rand.nextInt(64) == 0)
|
||||||
|
{
|
||||||
|
worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "liquid.water", rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() * 1.0F + 0.5F, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (rand.nextInt(10) == 0)
|
||||||
|
{
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double)rand.nextFloat(), d1 + (double)rand.nextFloat(), d2 + (double)rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.blockMaterial == Material.lava && worldIn.getBlockState(pos.up()).getBlock().getMaterial() == Material.air && !worldIn.getBlockState(pos.up()).getBlock().isOpaqueCube())
|
||||||
|
{
|
||||||
|
if (rand.nextInt(100) == 0)
|
||||||
|
{
|
||||||
|
double d8 = d0 + (double)rand.nextFloat();
|
||||||
|
double d4 = d1 + this.maxY;
|
||||||
|
double d6 = d2 + (double)rand.nextFloat();
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
worldIn.playSound(d8, d4, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rand.nextInt(200) == 0)
|
||||||
|
{
|
||||||
|
worldIn.playSound(d0, d1, d2, "liquid.lava", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
|
||||||
|
{
|
||||||
|
Material material = worldIn.getBlockState(pos.down(2)).getBlock().getMaterial();
|
||||||
|
|
||||||
|
if (!material.blocksMovement() && !material.isLiquid())
|
||||||
|
{
|
||||||
|
double d3 = d0 + (double)rand.nextFloat();
|
||||||
|
double d5 = d1 - 1.05D;
|
||||||
|
double d7 = d2 + (double)rand.nextFloat();
|
||||||
|
|
||||||
|
if (this.blockMaterial == Material.water)
|
||||||
|
{
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.DRIP_LAVA, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getFlowDirection(IBlockAccess worldIn, BlockPos pos, Material materialIn)
|
||||||
|
{
|
||||||
|
Vec3 vec3 = getFlowingBlock(materialIn).getFlowVector(worldIn, pos);
|
||||||
|
return vec3.xCoord == 0.0D && vec3.zCoord == 0.0D ? -1000.0D : MathHelper.func_181159_b(vec3.zCoord, vec3.xCoord) - (Math.PI / 2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.checkForMixing(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
this.checkForMixing(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkForMixing(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (this.blockMaterial == Material.lava)
|
||||||
|
{
|
||||||
|
boolean flag = false;
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.values())
|
||||||
|
{
|
||||||
|
if (enumfacing != EnumFacing.DOWN && worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getMaterial() == Material.water)
|
||||||
|
{
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
Integer integer = (Integer)state.getValue(LEVEL);
|
||||||
|
|
||||||
|
if (integer.intValue() == 0)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.obsidian.getDefaultState());
|
||||||
|
this.triggerMixEffects(worldIn, pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (integer.intValue() <= 4)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.cobblestone.getDefaultState());
|
||||||
|
this.triggerMixEffects(worldIn, pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void triggerMixEffects(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
double d0 = (double)pos.getX();
|
||||||
|
double d1 = (double)pos.getY();
|
||||||
|
double d2 = (double)pos.getZ();
|
||||||
|
worldIn.playSoundEffect(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; ++i)
|
||||||
|
{
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0 + Math.random(), d1 + 1.2D, d2 + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(LEVEL, Integer.valueOf(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(LEVEL)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {LEVEL});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockDynamicLiquid getFlowingBlock(Material materialIn)
|
||||||
|
{
|
||||||
|
if (materialIn == Material.water)
|
||||||
|
{
|
||||||
|
return Blocks.flowing_water;
|
||||||
|
}
|
||||||
|
else if (materialIn == Material.lava)
|
||||||
|
{
|
||||||
|
return Blocks.flowing_lava;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Invalid material");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockStaticLiquid getStaticBlock(Material materialIn)
|
||||||
|
{
|
||||||
|
if (materialIn == Material.water)
|
||||||
|
{
|
||||||
|
return Blocks.water;
|
||||||
|
}
|
||||||
|
else if (materialIn == Material.lava)
|
||||||
|
{
|
||||||
|
return Blocks.lava;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Invalid material");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
95
client/src/main/java/net/minecraft/block/BlockLog.java
Normal file
95
client/src/main/java/net/minecraft/block/BlockLog.java
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public abstract class BlockLog extends BlockRotatedPillar
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockLog.EnumAxis> LOG_AXIS = PropertyEnum.<BlockLog.EnumAxis>create("axis", BlockLog.EnumAxis.class);
|
||||||
|
|
||||||
|
public BlockLog()
|
||||||
|
{
|
||||||
|
super(Material.wood);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
this.setHardness(2.0F);
|
||||||
|
this.setStepSound(soundTypeWood);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 4;
|
||||||
|
int j = i + 1;
|
||||||
|
|
||||||
|
if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j)))
|
||||||
|
{
|
||||||
|
for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i)))
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock().getMaterial() == Material.leaves && !((Boolean)iblockstate.getValue(BlockLeaves.CHECK_DECAY)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos, iblockstate.withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(true)), 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(LOG_AXIS, BlockLog.EnumAxis.fromFacingAxis(facing.getAxis()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumAxis implements IStringSerializable
|
||||||
|
{
|
||||||
|
X("x"),
|
||||||
|
Y("y"),
|
||||||
|
Z("z"),
|
||||||
|
NONE("none");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private EnumAxis(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockLog.EnumAxis fromFacingAxis(EnumFacing.Axis axis)
|
||||||
|
{
|
||||||
|
switch (axis)
|
||||||
|
{
|
||||||
|
case X:
|
||||||
|
return X;
|
||||||
|
|
||||||
|
case Y:
|
||||||
|
return Y;
|
||||||
|
|
||||||
|
case Z:
|
||||||
|
return Z;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
client/src/main/java/net/minecraft/block/BlockMelon.java
Normal file
42
client/src/main/java/net/minecraft/block/BlockMelon.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
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.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
public class BlockMelon extends Block
|
||||||
|
{
|
||||||
|
protected BlockMelon()
|
||||||
|
{
|
||||||
|
super(Material.gourd, MapColor.limeColor);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Items.melon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 3 + random.nextInt(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the quantity dropped based on the given fortune level
|
||||||
|
*/
|
||||||
|
public int quantityDroppedWithBonus(int fortune, Random random)
|
||||||
|
{
|
||||||
|
return Math.min(9, this.quantityDropped(random) + random.nextInt(1 + fortune));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockMobSpawner extends BlockContainer
|
||||||
|
{
|
||||||
|
protected BlockMobSpawner()
|
||||||
|
{
|
||||||
|
super(Material.rock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityMobSpawner();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);
|
||||||
|
int i = 15 + worldIn.rand.nextInt(15) + worldIn.rand.nextInt(15);
|
||||||
|
this.dropXpOnBlockBreak(worldIn, pos, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
127
client/src/main/java/net/minecraft/block/BlockMushroom.java
Normal file
127
client/src/main/java/net/minecraft/block/BlockMushroom.java
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
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;
|
||||||
|
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||||
|
|
||||||
|
public class BlockMushroom extends BlockBush implements IGrowable
|
||||||
|
{
|
||||||
|
protected BlockMushroom()
|
||||||
|
{
|
||||||
|
float f = 0.2F;
|
||||||
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (rand.nextInt(25) == 0)
|
||||||
|
{
|
||||||
|
int i = 5;
|
||||||
|
int j = 4;
|
||||||
|
|
||||||
|
for (BlockPos blockpos : BlockPos.getAllInBoxMutable(pos.add(-4, -1, -4), pos.add(4, 1, 4)))
|
||||||
|
{
|
||||||
|
if (worldIn.getBlockState(blockpos).getBlock() == this)
|
||||||
|
{
|
||||||
|
--i;
|
||||||
|
|
||||||
|
if (i <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockPos blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
|
||||||
|
|
||||||
|
for (int k = 0; k < 4; ++k)
|
||||||
|
{
|
||||||
|
if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState()))
|
||||||
|
{
|
||||||
|
pos = blockpos1;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState()))
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos1, this.getDefaultState(), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return super.canPlaceBlockAt(worldIn, pos) && this.canBlockStay(worldIn, pos, this.getDefaultState());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is the block grass, dirt or farmland
|
||||||
|
*/
|
||||||
|
protected boolean canPlaceBlockOn(Block ground)
|
||||||
|
{
|
||||||
|
return ground.isFullBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (pos.getY() >= 0 && pos.getY() < 256)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos.down());
|
||||||
|
return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean generateBigMushroom(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
WorldGenerator worldgenerator = null;
|
||||||
|
|
||||||
|
if (this == Blocks.brown_mushroom)
|
||||||
|
{
|
||||||
|
worldgenerator = new WorldGenBigMushroom(Blocks.brown_mushroom_block);
|
||||||
|
}
|
||||||
|
else if (this == Blocks.red_mushroom)
|
||||||
|
{
|
||||||
|
worldgenerator = new WorldGenBigMushroom(Blocks.red_mushroom_block);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldgenerator != null && worldgenerator.generate(worldIn, rand, pos))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state, 3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this IGrowable can grow
|
||||||
|
*/
|
||||||
|
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return (double)rand.nextFloat() < 0.4D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.generateBigMushroom(worldIn, pos, state, rand);
|
||||||
|
}
|
||||||
|
}
|
||||||
98
client/src/main/java/net/minecraft/block/BlockMycelium.java
Normal file
98
client/src/main/java/net/minecraft/block/BlockMycelium.java
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.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.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockMycelium extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyBool SNOWY = PropertyBool.create("snowy");
|
||||||
|
|
||||||
|
protected BlockMycelium()
|
||||||
|
{
|
||||||
|
super(Material.grass, MapColor.purpleColor);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
Block block = worldIn.getBlockState(pos.up()).getBlock();
|
||||||
|
return state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getBlock().getLightOpacity() > 2)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
Block block = worldIn.getBlockState(blockpos.up()).getBlock();
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(blockpos, this.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
super.randomDisplayTick(worldIn, pos, state, rand);
|
||||||
|
|
||||||
|
if (rand.nextInt(10) == 0)
|
||||||
|
{
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.TOWN_AURA, (double)((float)pos.getX() + rand.nextFloat()), (double)((float)pos.getY() + 1.1F), (double)((float)pos.getZ() + rand.nextFloat()), 0.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Blocks.dirt.getItemDropped(Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {SNOWY});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
|
||||||
|
public class BlockNetherBrick extends Block
|
||||||
|
{
|
||||||
|
public BlockNetherBrick()
|
||||||
|
{
|
||||||
|
super(Material.rock);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return MapColor.netherrackColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
125
client/src/main/java/net/minecraft/block/BlockNetherWart.java
Normal file
125
client/src/main/java/net/minecraft/block/BlockNetherWart.java
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.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;
|
||||||
|
|
||||||
|
public class BlockNetherWart extends BlockBush
|
||||||
|
{
|
||||||
|
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 3);
|
||||||
|
|
||||||
|
protected BlockNetherWart()
|
||||||
|
{
|
||||||
|
super(Material.plants, MapColor.redColor);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
float f = 0.5F;
|
||||||
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
|
||||||
|
this.setCreativeTab((CreativeTabs)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is the block grass, dirt or farmland
|
||||||
|
*/
|
||||||
|
protected boolean canPlaceBlockOn(Block ground)
|
||||||
|
{
|
||||||
|
return ground == Blocks.soul_sand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
int i = ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
|
||||||
|
if (i < 3 && rand.nextInt(10) == 0)
|
||||||
|
{
|
||||||
|
state = state.withProperty(AGE, Integer.valueOf(i + 1));
|
||||||
|
worldIn.setBlockState(pos, state, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.updateTick(worldIn, pos, state, rand);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
if (((Integer)state.getValue(AGE)).intValue() >= 3)
|
||||||
|
{
|
||||||
|
i = 2 + worldIn.rand.nextInt(3);
|
||||||
|
|
||||||
|
if (fortune > 0)
|
||||||
|
{
|
||||||
|
i += worldIn.rand.nextInt(fortune + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < i; ++j)
|
||||||
|
{
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(Items.nether_wart));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return Items.nether_wart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Integer)state.getValue(AGE)).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {AGE});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
|
||||||
|
public class BlockNetherrack extends Block
|
||||||
|
{
|
||||||
|
public BlockNetherrack()
|
||||||
|
{
|
||||||
|
super(Material.rock);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return MapColor.netherrackColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
122
client/src/main/java/net/minecraft/block/BlockNewLeaf.java
Normal file
122
client/src/main/java/net/minecraft/block/BlockNewLeaf.java
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class BlockNewLeaf extends BlockLeaves
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockPlanks.EnumType> VARIANT = PropertyEnum.<BlockPlanks.EnumType>create("variant", BlockPlanks.EnumType.class, new Predicate<BlockPlanks.EnumType>()
|
||||||
|
{
|
||||||
|
public boolean apply(BlockPlanks.EnumType p_apply_1_)
|
||||||
|
{
|
||||||
|
return p_apply_1_.getMetadata() >= 4;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
public BlockNewLeaf()
|
||||||
|
{
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockPlanks.EnumType.ACACIA).withProperty(CHECK_DECAY, Boolean.valueOf(true)).withProperty(DECAYABLE, Boolean.valueOf(true)));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance)
|
||||||
|
{
|
||||||
|
if (state.getValue(VARIANT) == BlockPlanks.EnumType.DARK_OAK && worldIn.rand.nextInt(chance) == 0)
|
||||||
|
{
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(Items.apple, 1, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDamageValue(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
return iblockstate.getBlock().getMetaFromState(iblockstate) & 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, 0));
|
||||||
|
list.add(new ItemStack(itemIn, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ItemStack createStackedBlock(IBlockState state)
|
||||||
|
{
|
||||||
|
return new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(VARIANT, this.getWoodType(meta)).withProperty(DECAYABLE, Boolean.valueOf((meta & 4) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf((meta & 8) > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4;
|
||||||
|
|
||||||
|
if (!((Boolean)state.getValue(DECAYABLE)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPlanks.EnumType getWoodType(int meta)
|
||||||
|
{
|
||||||
|
return BlockPlanks.EnumType.byMetadata((meta & 3) + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {VARIANT, CHECK_DECAY, DECAYABLE});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
|
||||||
|
{
|
||||||
|
player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
super.harvestBlock(worldIn, player, pos, state, te);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
139
client/src/main/java/net/minecraft/block/BlockNewLog.java
Normal file
139
client/src/main/java/net/minecraft/block/BlockNewLog.java
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class BlockNewLog extends BlockLog
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockPlanks.EnumType> VARIANT = PropertyEnum.<BlockPlanks.EnumType>create("variant", BlockPlanks.EnumType.class, new Predicate<BlockPlanks.EnumType>()
|
||||||
|
{
|
||||||
|
public boolean apply(BlockPlanks.EnumType p_apply_1_)
|
||||||
|
{
|
||||||
|
return p_apply_1_.getMetadata() >= 4;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
public BlockNewLog()
|
||||||
|
{
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockPlanks.EnumType.ACACIA).withProperty(LOG_AXIS, BlockLog.EnumAxis.Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
BlockPlanks.EnumType blockplanks$enumtype = (BlockPlanks.EnumType)state.getValue(VARIANT);
|
||||||
|
|
||||||
|
switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS))
|
||||||
|
{
|
||||||
|
case X:
|
||||||
|
case Z:
|
||||||
|
case NONE:
|
||||||
|
default:
|
||||||
|
switch (blockplanks$enumtype)
|
||||||
|
{
|
||||||
|
case ACACIA:
|
||||||
|
default:
|
||||||
|
return MapColor.stoneColor;
|
||||||
|
|
||||||
|
case DARK_OAK:
|
||||||
|
return BlockPlanks.EnumType.DARK_OAK.func_181070_c();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Y:
|
||||||
|
return blockplanks$enumtype.func_181070_c();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.ACACIA.getMetadata() - 4));
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.DARK_OAK.getMetadata() - 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, BlockPlanks.EnumType.byMetadata((meta & 3) + 4));
|
||||||
|
|
||||||
|
switch (meta & 12)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return iblockstate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("incomplete-switch")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4;
|
||||||
|
|
||||||
|
switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS))
|
||||||
|
{
|
||||||
|
case X:
|
||||||
|
i |= 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Z:
|
||||||
|
i |= 8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NONE:
|
||||||
|
i |= 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {VARIANT, LOG_AXIS});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ItemStack createStackedBlock(IBlockState state)
|
||||||
|
{
|
||||||
|
return new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
123
client/src/main/java/net/minecraft/block/BlockNote.java
Normal file
123
client/src/main/java/net/minecraft/block/BlockNote.java
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.List;
|
||||||
|
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;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockNote extends BlockContainer
|
||||||
|
{
|
||||||
|
private static final List<String> INSTRUMENTS = Lists.newArrayList(new String[] {"harp", "bd", "snare", "hat", "bassattack"});
|
||||||
|
|
||||||
|
public BlockNote()
|
||||||
|
{
|
||||||
|
super(Material.wood);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
boolean flag = worldIn.isBlockPowered(pos);
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityNote)
|
||||||
|
{
|
||||||
|
TileEntityNote tileentitynote = (TileEntityNote)tileentity;
|
||||||
|
|
||||||
|
if (tileentitynote.previousRedstoneState != flag)
|
||||||
|
{
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
tileentitynote.triggerNote(worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
tileentitynote.previousRedstoneState = flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityNote)
|
||||||
|
{
|
||||||
|
TileEntityNote tileentitynote = (TileEntityNote)tileentity;
|
||||||
|
tileentitynote.changePitch();
|
||||||
|
tileentitynote.triggerNote(worldIn, pos);
|
||||||
|
playerIn.triggerAchievement(StatList.field_181735_S);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityNote)
|
||||||
|
{
|
||||||
|
((TileEntityNote)tileentity).triggerNote(worldIn, pos);
|
||||||
|
playerIn.triggerAchievement(StatList.field_181734_R);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityNote();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getInstrument(int id)
|
||||||
|
{
|
||||||
|
if (id < 0 || id >= INSTRUMENTS.size())
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (String)INSTRUMENTS.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on both Client and Server when World#addBlockEvent is called
|
||||||
|
*/
|
||||||
|
public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam)
|
||||||
|
{
|
||||||
|
float f = (float)Math.pow(2.0D, (double)(eventParam - 12) / 12.0D);
|
||||||
|
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "note." + this.getInstrument(eventID), 3.0F, f);
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.NOTE, (double)pos.getX() + 0.5D, (double)pos.getY() + 1.2D, (double)pos.getZ() + 0.5D, (double)eventParam / 24.0D, 0.0D, 0.0D, new int[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
34
client/src/main/java/net/minecraft/block/BlockObsidian.java
Normal file
34
client/src/main/java/net/minecraft/block/BlockObsidian.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
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.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
public class BlockObsidian extends Block
|
||||||
|
{
|
||||||
|
public BlockObsidian()
|
||||||
|
{
|
||||||
|
super(Material.rock);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(Blocks.obsidian);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return MapColor.blackColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
160
client/src/main/java/net/minecraft/block/BlockOldLeaf.java
Normal file
160
client/src/main/java/net/minecraft/block/BlockOldLeaf.java
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockOldLeaf extends BlockLeaves
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockPlanks.EnumType> VARIANT = PropertyEnum.<BlockPlanks.EnumType>create("variant", BlockPlanks.EnumType.class, new Predicate<BlockPlanks.EnumType>()
|
||||||
|
{
|
||||||
|
public boolean apply(BlockPlanks.EnumType p_apply_1_)
|
||||||
|
{
|
||||||
|
return p_apply_1_.getMetadata() < 4;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
public BlockOldLeaf()
|
||||||
|
{
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockPlanks.EnumType.OAK).withProperty(CHECK_DECAY, Boolean.valueOf(true)).withProperty(DECAYABLE, Boolean.valueOf(true)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRenderColor(IBlockState state)
|
||||||
|
{
|
||||||
|
if (state.getBlock() != this)
|
||||||
|
{
|
||||||
|
return super.getRenderColor(state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BlockPlanks.EnumType blockplanks$enumtype = (BlockPlanks.EnumType)state.getValue(VARIANT);
|
||||||
|
return blockplanks$enumtype == BlockPlanks.EnumType.SPRUCE ? ColorizerFoliage.getFoliageColorPine() : (blockplanks$enumtype == BlockPlanks.EnumType.BIRCH ? ColorizerFoliage.getFoliageColorBirch() : super.getRenderColor(state));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this)
|
||||||
|
{
|
||||||
|
BlockPlanks.EnumType blockplanks$enumtype = (BlockPlanks.EnumType)iblockstate.getValue(VARIANT);
|
||||||
|
|
||||||
|
if (blockplanks$enumtype == BlockPlanks.EnumType.SPRUCE)
|
||||||
|
{
|
||||||
|
return ColorizerFoliage.getFoliageColorPine();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockplanks$enumtype == BlockPlanks.EnumType.BIRCH)
|
||||||
|
{
|
||||||
|
return ColorizerFoliage.getFoliageColorBirch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.colorMultiplier(worldIn, pos, renderPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance)
|
||||||
|
{
|
||||||
|
if (state.getValue(VARIANT) == BlockPlanks.EnumType.OAK && worldIn.rand.nextInt(chance) == 0)
|
||||||
|
{
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(Items.apple, 1, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getSaplingDropChance(IBlockState state)
|
||||||
|
{
|
||||||
|
return state.getValue(VARIANT) == BlockPlanks.EnumType.JUNGLE ? 40 : super.getSaplingDropChance(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.OAK.getMetadata()));
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.SPRUCE.getMetadata()));
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.BIRCH.getMetadata()));
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.JUNGLE.getMetadata()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ItemStack createStackedBlock(IBlockState state)
|
||||||
|
{
|
||||||
|
return new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(VARIANT, this.getWoodType(meta)).withProperty(DECAYABLE, Boolean.valueOf((meta & 4) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf((meta & 8) > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||||
|
|
||||||
|
if (!((Boolean)state.getValue(DECAYABLE)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPlanks.EnumType getWoodType(int meta)
|
||||||
|
{
|
||||||
|
return BlockPlanks.EnumType.byMetadata((meta & 3) % 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {VARIANT, CHECK_DECAY, DECAYABLE});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
|
||||||
|
{
|
||||||
|
player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
|
||||||
|
spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
super.harvestBlock(worldIn, player, pos, state, te);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
147
client/src/main/java/net/minecraft/block/BlockOldLog.java
Normal file
147
client/src/main/java/net/minecraft/block/BlockOldLog.java
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class BlockOldLog extends BlockLog
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockPlanks.EnumType> VARIANT = PropertyEnum.<BlockPlanks.EnumType>create("variant", BlockPlanks.EnumType.class, new Predicate<BlockPlanks.EnumType>()
|
||||||
|
{
|
||||||
|
public boolean apply(BlockPlanks.EnumType p_apply_1_)
|
||||||
|
{
|
||||||
|
return p_apply_1_.getMetadata() < 4;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
public BlockOldLog()
|
||||||
|
{
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockPlanks.EnumType.OAK).withProperty(LOG_AXIS, BlockLog.EnumAxis.Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
BlockPlanks.EnumType blockplanks$enumtype = (BlockPlanks.EnumType)state.getValue(VARIANT);
|
||||||
|
|
||||||
|
switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS))
|
||||||
|
{
|
||||||
|
case X:
|
||||||
|
case Z:
|
||||||
|
case NONE:
|
||||||
|
default:
|
||||||
|
switch (blockplanks$enumtype)
|
||||||
|
{
|
||||||
|
case OAK:
|
||||||
|
default:
|
||||||
|
return BlockPlanks.EnumType.SPRUCE.func_181070_c();
|
||||||
|
|
||||||
|
case SPRUCE:
|
||||||
|
return BlockPlanks.EnumType.DARK_OAK.func_181070_c();
|
||||||
|
|
||||||
|
case BIRCH:
|
||||||
|
return MapColor.quartzColor;
|
||||||
|
|
||||||
|
case JUNGLE:
|
||||||
|
return BlockPlanks.EnumType.SPRUCE.func_181070_c();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Y:
|
||||||
|
return blockplanks$enumtype.func_181070_c();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.OAK.getMetadata()));
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.SPRUCE.getMetadata()));
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.BIRCH.getMetadata()));
|
||||||
|
list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.JUNGLE.getMetadata()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, BlockPlanks.EnumType.byMetadata((meta & 3) % 4));
|
||||||
|
|
||||||
|
switch (meta & 12)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return iblockstate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("incomplete-switch")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||||
|
|
||||||
|
switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS))
|
||||||
|
{
|
||||||
|
case X:
|
||||||
|
i |= 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Z:
|
||||||
|
i |= 8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NONE:
|
||||||
|
i |= 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {VARIANT, LOG_AXIS});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ItemStack createStackedBlock(IBlockState state)
|
||||||
|
{
|
||||||
|
return new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||||
|
}
|
||||||
|
}
|
||||||
116
client/src/main/java/net/minecraft/block/BlockOre.java
Normal file
116
client/src/main/java/net/minecraft/block/BlockOre.java
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
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.init.Blocks;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.EnumDyeColor;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockOre extends Block
|
||||||
|
{
|
||||||
|
public BlockOre()
|
||||||
|
{
|
||||||
|
this(Material.rock.getMaterialMapColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockOre(MapColor p_i46390_1_)
|
||||||
|
{
|
||||||
|
super(Material.rock, p_i46390_1_);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return this == Blocks.coal_ore ? Items.coal : (this == Blocks.diamond_ore ? Items.diamond : (this == Blocks.lapis_ore ? Items.dye : (this == Blocks.emerald_ore ? Items.emerald : (this == Blocks.quartz_ore ? Items.quartz : Item.getItemFromBlock(this)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return this == Blocks.lapis_ore ? 4 + random.nextInt(5) : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the quantity dropped based on the given fortune level
|
||||||
|
*/
|
||||||
|
public int quantityDroppedWithBonus(int fortune, Random random)
|
||||||
|
{
|
||||||
|
if (fortune > 0 && Item.getItemFromBlock(this) != this.getItemDropped((IBlockState)this.getBlockState().getValidStates().iterator().next(), random, fortune))
|
||||||
|
{
|
||||||
|
int i = random.nextInt(fortune + 2) - 1;
|
||||||
|
|
||||||
|
if (i < 0)
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.quantityDropped(random) * (i + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.quantityDropped(random);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);
|
||||||
|
|
||||||
|
if (this.getItemDropped(state, worldIn.rand, fortune) != Item.getItemFromBlock(this))
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (this == Blocks.coal_ore)
|
||||||
|
{
|
||||||
|
i = MathHelper.getRandomIntegerInRange(worldIn.rand, 0, 2);
|
||||||
|
}
|
||||||
|
else if (this == Blocks.diamond_ore)
|
||||||
|
{
|
||||||
|
i = MathHelper.getRandomIntegerInRange(worldIn.rand, 3, 7);
|
||||||
|
}
|
||||||
|
else if (this == Blocks.emerald_ore)
|
||||||
|
{
|
||||||
|
i = MathHelper.getRandomIntegerInRange(worldIn.rand, 3, 7);
|
||||||
|
}
|
||||||
|
else if (this == Blocks.lapis_ore)
|
||||||
|
{
|
||||||
|
i = MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
|
||||||
|
}
|
||||||
|
else if (this == Blocks.quartz_ore)
|
||||||
|
{
|
||||||
|
i = MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dropXpOnBlockBreak(worldIn, pos, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDamageValue(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return this == Blocks.lapis_ore ? EnumDyeColor.BLUE.getDyeDamage() : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
23
client/src/main/java/net/minecraft/block/BlockPackedIce.java
Normal file
23
client/src/main/java/net/minecraft/block/BlockPackedIce.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
|
||||||
|
public class BlockPackedIce extends Block
|
||||||
|
{
|
||||||
|
public BlockPackedIce()
|
||||||
|
{
|
||||||
|
super(Material.packedIce);
|
||||||
|
this.slipperiness = 0.98F;
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
204
client/src/main/java/net/minecraft/block/BlockPane.java
Normal file
204
client/src/main/java/net/minecraft/block/BlockPane.java
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockPane extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyBool NORTH = PropertyBool.create("north");
|
||||||
|
public static final PropertyBool EAST = PropertyBool.create("east");
|
||||||
|
public static final PropertyBool SOUTH = PropertyBool.create("south");
|
||||||
|
public static final PropertyBool WEST = PropertyBool.create("west");
|
||||||
|
private final boolean canDrop;
|
||||||
|
|
||||||
|
protected BlockPane(Material materialIn, boolean canDrop)
|
||||||
|
{
|
||||||
|
super(materialIn);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
|
||||||
|
this.canDrop = canDrop;
|
||||||
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||||
|
* metadata, such as fence connections.
|
||||||
|
*/
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return state.withProperty(NORTH, Boolean.valueOf(this.canPaneConnectToBlock(worldIn.getBlockState(pos.north()).getBlock()))).withProperty(SOUTH, Boolean.valueOf(this.canPaneConnectToBlock(worldIn.getBlockState(pos.south()).getBlock()))).withProperty(WEST, Boolean.valueOf(this.canPaneConnectToBlock(worldIn.getBlockState(pos.west()).getBlock()))).withProperty(EAST, Boolean.valueOf(this.canPaneConnectToBlock(worldIn.getBlockState(pos.east()).getBlock())));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return !this.canDrop ? null : super.getItemDropped(state, rand, fortune);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos).getBlock() == this ? false : super.shouldSideBeRendered(worldIn, pos, side);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
boolean flag = this.canPaneConnectToBlock(worldIn.getBlockState(pos.north()).getBlock());
|
||||||
|
boolean flag1 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.south()).getBlock());
|
||||||
|
boolean flag2 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.west()).getBlock());
|
||||||
|
boolean flag3 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.east()).getBlock());
|
||||||
|
|
||||||
|
if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
|
||||||
|
{
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
else if (flag3)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
|
||||||
|
{
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
else if (flag1)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
float f = 0.4375F;
|
||||||
|
float f1 = 0.5625F;
|
||||||
|
float f2 = 0.4375F;
|
||||||
|
float f3 = 0.5625F;
|
||||||
|
boolean flag = this.canPaneConnectToBlock(worldIn.getBlockState(pos.north()).getBlock());
|
||||||
|
boolean flag1 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.south()).getBlock());
|
||||||
|
boolean flag2 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.west()).getBlock());
|
||||||
|
boolean flag3 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.east()).getBlock());
|
||||||
|
|
||||||
|
if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
|
||||||
|
{
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
f = 0.0F;
|
||||||
|
}
|
||||||
|
else if (flag3)
|
||||||
|
{
|
||||||
|
f1 = 1.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
f = 0.0F;
|
||||||
|
f1 = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
|
||||||
|
{
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
f2 = 0.0F;
|
||||||
|
}
|
||||||
|
else if (flag1)
|
||||||
|
{
|
||||||
|
f3 = 1.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
f2 = 0.0F;
|
||||||
|
f3 = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean canPaneConnectToBlock(Block blockIn)
|
||||||
|
{
|
||||||
|
return blockIn.isFullBlock() || blockIn == this || blockIn == Blocks.glass || blockIn == Blocks.stained_glass || blockIn == Blocks.stained_glass_pane || blockIn instanceof BlockPane;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canSilkHarvest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.CUTOUT_MIPPED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {NORTH, EAST, WEST, SOUTH});
|
||||||
|
}
|
||||||
|
}
|
||||||
488
client/src/main/java/net/minecraft/block/BlockPistonBase.java
Normal file
488
client/src/main/java/net/minecraft/block/BlockPistonBase.java
Normal file
@@ -0,0 +1,488 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.state.BlockPistonStructureHelper;
|
||||||
|
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.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityPiston;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockPistonBase extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing");
|
||||||
|
public static final PropertyBool EXTENDED = PropertyBool.create("extended");
|
||||||
|
|
||||||
|
/** This piston is the sticky one? */
|
||||||
|
private final boolean isSticky;
|
||||||
|
|
||||||
|
public BlockPistonBase(boolean isSticky)
|
||||||
|
{
|
||||||
|
super(Material.piston);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(EXTENDED, Boolean.valueOf(false)));
|
||||||
|
this.isSticky = isSticky;
|
||||||
|
this.setStepSound(soundTypePiston);
|
||||||
|
this.setHardness(0.5F);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||||
|
*/
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(FACING, getFacingFromEntity(worldIn, pos, placer)), 2);
|
||||||
|
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
this.checkForMove(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
this.checkForMove(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote && worldIn.getTileEntity(pos) == null)
|
||||||
|
{
|
||||||
|
this.checkForMove(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||||
|
* IBlockstate
|
||||||
|
*/
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, getFacingFromEntity(worldIn, pos, placer)).withProperty(EXTENDED, Boolean.valueOf(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkForMove(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);
|
||||||
|
|
||||||
|
if (flag && !((Boolean)state.getValue(EXTENDED)).booleanValue())
|
||||||
|
{
|
||||||
|
if ((new BlockPistonStructureHelper(worldIn, pos, enumfacing, true)).canMove())
|
||||||
|
{
|
||||||
|
worldIn.addBlockEvent(pos, this, 0, enumfacing.getIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!flag && ((Boolean)state.getValue(EXTENDED)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(false)), 2);
|
||||||
|
worldIn.addBlockEvent(pos, this, 1, enumfacing.getIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean shouldBeExtended(World worldIn, BlockPos pos, EnumFacing facing)
|
||||||
|
{
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.values())
|
||||||
|
{
|
||||||
|
if (enumfacing != facing && worldIn.isSidePowered(pos.offset(enumfacing), enumfacing))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldIn.isSidePowered(pos, EnumFacing.DOWN))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.up();
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing1 : EnumFacing.values())
|
||||||
|
{
|
||||||
|
if (enumfacing1 != EnumFacing.DOWN && worldIn.isSidePowered(blockpos.offset(enumfacing1), enumfacing1))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on both Client and Server when World#addBlockEvent is called
|
||||||
|
*/
|
||||||
|
public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);
|
||||||
|
|
||||||
|
if (flag && eventID == 1)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(true)), 2);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flag && eventID == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eventID == 0)
|
||||||
|
{
|
||||||
|
if (!this.doMove(worldIn, pos, enumfacing, true))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(true)), 2);
|
||||||
|
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "tile.piston.out", 0.5F, worldIn.rand.nextFloat() * 0.25F + 0.6F);
|
||||||
|
}
|
||||||
|
else if (eventID == 1)
|
||||||
|
{
|
||||||
|
TileEntity tileentity1 = worldIn.getTileEntity(pos.offset(enumfacing));
|
||||||
|
|
||||||
|
if (tileentity1 instanceof TileEntityPiston)
|
||||||
|
{
|
||||||
|
((TileEntityPiston)tileentity1).clearPistonTileEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.setBlockState(pos, Blocks.piston_extension.getDefaultState().withProperty(BlockPistonMoving.FACING, enumfacing).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT), 3);
|
||||||
|
worldIn.setTileEntity(pos, BlockPistonMoving.newTileEntity(this.getStateFromMeta(eventParam), enumfacing, false, true));
|
||||||
|
|
||||||
|
if (this.isSticky)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.add(enumfacing.getFrontOffsetX() * 2, enumfacing.getFrontOffsetY() * 2, enumfacing.getFrontOffsetZ() * 2);
|
||||||
|
Block block = worldIn.getBlockState(blockpos).getBlock();
|
||||||
|
boolean flag1 = false;
|
||||||
|
|
||||||
|
if (block == Blocks.piston_extension)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityPiston)
|
||||||
|
{
|
||||||
|
TileEntityPiston tileentitypiston = (TileEntityPiston)tileentity;
|
||||||
|
|
||||||
|
if (tileentitypiston.getFacing() == enumfacing && tileentitypiston.isExtending())
|
||||||
|
{
|
||||||
|
tileentitypiston.clearPistonTileEntity();
|
||||||
|
flag1 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flag1 && block.getMaterial() != Material.air && canPush(block, worldIn, blockpos, enumfacing.getOpposite(), false) && (block.getMobilityFlag() == 0 || block == Blocks.piston || block == Blocks.sticky_piston))
|
||||||
|
{
|
||||||
|
this.doMove(worldIn, pos, enumfacing, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos.offset(enumfacing));
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "tile.piston.in", 0.5F, worldIn.rand.nextFloat() * 0.15F + 0.6F);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() == this && ((Boolean)iblockstate.getValue(EXTENDED)).booleanValue())
|
||||||
|
{
|
||||||
|
float f = 0.25F;
|
||||||
|
EnumFacing enumfacing = (EnumFacing)iblockstate.getValue(FACING);
|
||||||
|
|
||||||
|
if (enumfacing != null)
|
||||||
|
{
|
||||||
|
switch (enumfacing)
|
||||||
|
{
|
||||||
|
case DOWN:
|
||||||
|
this.setBlockBounds(0.0F, 0.25F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UP:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.25F, 1.0F, 1.0F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.75F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
this.setBlockBounds(0.25F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EAST:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.75F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the block's bounds for rendering it as an item
|
||||||
|
*/
|
||||||
|
public void setBlockBoundsForItemRender()
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
this.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
return super.getCollisionBoundingBox(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumFacing getFacing(int meta)
|
||||||
|
{
|
||||||
|
int i = meta & 7;
|
||||||
|
return i > 5 ? null : EnumFacing.getFront(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn)
|
||||||
|
{
|
||||||
|
if (MathHelper.abs((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F)
|
||||||
|
{
|
||||||
|
double d0 = entityIn.posY + (double)entityIn.getEyeHeight();
|
||||||
|
|
||||||
|
if (d0 - (double)clickedBlock.getY() > 2.0D)
|
||||||
|
{
|
||||||
|
return EnumFacing.UP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((double)clickedBlock.getY() - d0 > 0.0D)
|
||||||
|
{
|
||||||
|
return EnumFacing.DOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return entityIn.getHorizontalFacing().getOpposite();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canPush(Block blockIn, World worldIn, BlockPos pos, EnumFacing direction, boolean allowDestroy)
|
||||||
|
{
|
||||||
|
if (blockIn == Blocks.obsidian)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!worldIn.getWorldBorder().contains(pos))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (pos.getY() >= 0 && (direction != EnumFacing.DOWN || pos.getY() != 0))
|
||||||
|
{
|
||||||
|
if (pos.getY() <= worldIn.getHeight() - 1 && (direction != EnumFacing.UP || pos.getY() != worldIn.getHeight() - 1))
|
||||||
|
{
|
||||||
|
if (blockIn != Blocks.piston && blockIn != Blocks.sticky_piston)
|
||||||
|
{
|
||||||
|
if (blockIn.getBlockHardness(worldIn, pos) == -1.0F)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockIn.getMobilityFlag() == 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockIn.getMobilityFlag() == 1)
|
||||||
|
{
|
||||||
|
if (!allowDestroy)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (((Boolean)worldIn.getBlockState(pos).getValue(EXTENDED)).booleanValue())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !(blockIn instanceof ITileEntityProvider);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending)
|
||||||
|
{
|
||||||
|
if (!extending)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos.offset(direction));
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockPistonStructureHelper blockpistonstructurehelper = new BlockPistonStructureHelper(worldIn, pos, direction, extending);
|
||||||
|
List<BlockPos> list = blockpistonstructurehelper.getBlocksToMove();
|
||||||
|
List<BlockPos> list1 = blockpistonstructurehelper.getBlocksToDestroy();
|
||||||
|
|
||||||
|
if (!blockpistonstructurehelper.canMove())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = list.size() + list1.size();
|
||||||
|
Block[] ablock = new Block[i];
|
||||||
|
EnumFacing enumfacing = extending ? direction : direction.getOpposite();
|
||||||
|
|
||||||
|
for (int j = list1.size() - 1; j >= 0; --j)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = (BlockPos)list1.get(j);
|
||||||
|
Block block = worldIn.getBlockState(blockpos).getBlock();
|
||||||
|
block.dropBlockAsItem(worldIn, blockpos, worldIn.getBlockState(blockpos), 0);
|
||||||
|
worldIn.setBlockToAir(blockpos);
|
||||||
|
--i;
|
||||||
|
ablock[i] = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k = list.size() - 1; k >= 0; --k)
|
||||||
|
{
|
||||||
|
BlockPos blockpos2 = (BlockPos)list.get(k);
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos2);
|
||||||
|
Block block1 = iblockstate.getBlock();
|
||||||
|
block1.getMetaFromState(iblockstate);
|
||||||
|
worldIn.setBlockToAir(blockpos2);
|
||||||
|
blockpos2 = blockpos2.offset(enumfacing);
|
||||||
|
worldIn.setBlockState(blockpos2, Blocks.piston_extension.getDefaultState().withProperty(FACING, direction), 4);
|
||||||
|
worldIn.setTileEntity(blockpos2, BlockPistonMoving.newTileEntity(iblockstate, direction, extending, false));
|
||||||
|
--i;
|
||||||
|
ablock[i] = block1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockPos blockpos1 = pos.offset(direction);
|
||||||
|
|
||||||
|
if (extending)
|
||||||
|
{
|
||||||
|
BlockPistonExtension.EnumPistonType blockpistonextension$enumpistontype = this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT;
|
||||||
|
IBlockState iblockstate1 = Blocks.piston_head.getDefaultState().withProperty(BlockPistonExtension.FACING, direction).withProperty(BlockPistonExtension.TYPE, blockpistonextension$enumpistontype);
|
||||||
|
IBlockState iblockstate2 = Blocks.piston_extension.getDefaultState().withProperty(BlockPistonMoving.FACING, direction).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
|
||||||
|
worldIn.setBlockState(blockpos1, iblockstate2, 4);
|
||||||
|
worldIn.setTileEntity(blockpos1, BlockPistonMoving.newTileEntity(iblockstate1, direction, true, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int l = list1.size() - 1; l >= 0; --l)
|
||||||
|
{
|
||||||
|
worldIn.notifyNeighborsOfStateChange((BlockPos)list1.get(l), ablock[i++]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i1 = list.size() - 1; i1 >= 0; --i1)
|
||||||
|
{
|
||||||
|
worldIn.notifyNeighborsOfStateChange((BlockPos)list.get(i1), ablock[i++]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extending)
|
||||||
|
{
|
||||||
|
worldIn.notifyNeighborsOfStateChange(blockpos1, Blocks.piston_head);
|
||||||
|
worldIn.notifyNeighborsOfStateChange(pos, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
|
||||||
|
*/
|
||||||
|
public IBlockState getStateForEntityRender(IBlockState state)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, EnumFacing.UP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, getFacing(meta)).withProperty(EXTENDED, Boolean.valueOf((meta & 8) > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
|
||||||
|
if (((Boolean)state.getValue(EXTENDED)).booleanValue())
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, EXTENDED});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,279 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.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.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockPistonExtension extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing");
|
||||||
|
public static final PropertyEnum<BlockPistonExtension.EnumPistonType> TYPE = PropertyEnum.<BlockPistonExtension.EnumPistonType>create("type", BlockPistonExtension.EnumPistonType.class);
|
||||||
|
public static final PropertyBool SHORT = PropertyBool.create("short");
|
||||||
|
|
||||||
|
public BlockPistonExtension()
|
||||||
|
{
|
||||||
|
super(Material.piston);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(TYPE, BlockPistonExtension.EnumPistonType.DEFAULT).withProperty(SHORT, Boolean.valueOf(false)));
|
||||||
|
this.setStepSound(soundTypePiston);
|
||||||
|
this.setHardness(0.5F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
|
||||||
|
{
|
||||||
|
if (player.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
|
||||||
|
if (enumfacing != null)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.offset(enumfacing.getOpposite());
|
||||||
|
Block block = worldIn.getBlockState(blockpos).getBlock();
|
||||||
|
|
||||||
|
if (block == Blocks.piston || block == Blocks.sticky_piston)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(blockpos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onBlockHarvested(worldIn, pos, state, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
EnumFacing enumfacing = ((EnumFacing)state.getValue(FACING)).getOpposite();
|
||||||
|
pos = pos.offset(enumfacing);
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if ((iblockstate.getBlock() == Blocks.piston || iblockstate.getBlock() == Blocks.sticky_piston) && ((Boolean)iblockstate.getValue(BlockPistonBase.EXTENDED)).booleanValue())
|
||||||
|
{
|
||||||
|
iblockstate.getBlock().dropBlockAsItem(worldIn, pos, iblockstate, 0);
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether this Block can be placed on the given side
|
||||||
|
*/
|
||||||
|
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all collision boxes of this Block to the list that intersect with the given mask.
|
||||||
|
*/
|
||||||
|
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
||||||
|
{
|
||||||
|
this.applyHeadBounds(state);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.applyCoreBounds(state);
|
||||||
|
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyCoreBounds(IBlockState state)
|
||||||
|
{
|
||||||
|
float f = 0.25F;
|
||||||
|
float f1 = 0.375F;
|
||||||
|
float f2 = 0.625F;
|
||||||
|
float f3 = 0.25F;
|
||||||
|
float f4 = 0.75F;
|
||||||
|
|
||||||
|
switch ((EnumFacing)state.getValue(FACING))
|
||||||
|
{
|
||||||
|
case DOWN:
|
||||||
|
this.setBlockBounds(0.375F, 0.25F, 0.375F, 0.625F, 1.0F, 0.625F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UP:
|
||||||
|
this.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.75F, 0.625F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
this.setBlockBounds(0.25F, 0.375F, 0.25F, 0.75F, 0.625F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
this.setBlockBounds(0.25F, 0.375F, 0.0F, 0.75F, 0.625F, 0.75F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
this.setBlockBounds(0.375F, 0.25F, 0.25F, 0.625F, 0.75F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EAST:
|
||||||
|
this.setBlockBounds(0.0F, 0.375F, 0.25F, 0.75F, 0.625F, 0.75F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
this.applyHeadBounds(worldIn.getBlockState(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyHeadBounds(IBlockState state)
|
||||||
|
{
|
||||||
|
float f = 0.25F;
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
|
||||||
|
if (enumfacing != null)
|
||||||
|
{
|
||||||
|
switch (enumfacing)
|
||||||
|
{
|
||||||
|
case DOWN:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UP:
|
||||||
|
this.setBlockBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORTH:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WEST:
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EAST:
|
||||||
|
this.setBlockBounds(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||||
|
BlockPos blockpos = pos.offset(enumfacing.getOpposite());
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() != Blocks.piston && iblockstate.getBlock() != Blocks.sticky_piston)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iblockstate.getBlock().onNeighborBlockChange(worldIn, blockpos, iblockstate, neighborBlock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumFacing getFacing(int meta)
|
||||||
|
{
|
||||||
|
int i = meta & 7;
|
||||||
|
return i > 5 ? null : EnumFacing.getFront(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return worldIn.getBlockState(pos).getValue(TYPE) == BlockPistonExtension.EnumPistonType.STICKY ? Item.getItemFromBlock(Blocks.sticky_piston) : Item.getItemFromBlock(Blocks.piston);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, getFacing(meta)).withProperty(TYPE, (meta & 8) > 0 ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
|
||||||
|
if (state.getValue(TYPE) == BlockPistonExtension.EnumPistonType.STICKY)
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, TYPE, SHORT});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumPistonType implements IStringSerializable
|
||||||
|
{
|
||||||
|
DEFAULT("normal"),
|
||||||
|
STICKY("sticky");
|
||||||
|
|
||||||
|
private final String VARIANT;
|
||||||
|
|
||||||
|
private EnumPistonType(String name)
|
||||||
|
{
|
||||||
|
this.VARIANT = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.VARIANT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.VARIANT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
312
client/src/main/java/net/minecraft/block/BlockPistonMoving.java
Normal file
312
client/src/main/java/net/minecraft/block/BlockPistonMoving.java
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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;
|
||||||
|
import net.minecraft.tileentity.TileEntityPiston;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockPistonMoving extends BlockContainer
|
||||||
|
{
|
||||||
|
public static final PropertyDirection FACING = BlockPistonExtension.FACING;
|
||||||
|
public static final PropertyEnum<BlockPistonExtension.EnumPistonType> TYPE = BlockPistonExtension.TYPE;
|
||||||
|
|
||||||
|
public BlockPistonMoving()
|
||||||
|
{
|
||||||
|
super(Material.piston);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(TYPE, BlockPistonExtension.EnumPistonType.DEFAULT));
|
||||||
|
this.setHardness(-1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||||
|
*/
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TileEntity newTileEntity(IBlockState state, EnumFacing facing, boolean extending, boolean renderHead)
|
||||||
|
{
|
||||||
|
return new TileEntityPiston(state, facing, extending, renderHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tileentity instanceof TileEntityPiston)
|
||||||
|
{
|
||||||
|
((TileEntityPiston)tileentity).clearPistonTileEntity();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
super.breakBlock(worldIn, pos, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether this Block can be placed on the given side
|
||||||
|
*/
|
||||||
|
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player destroys this Block
|
||||||
|
*/
|
||||||
|
public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
|
if (iblockstate.getBlock() instanceof BlockPistonBase && ((Boolean)iblockstate.getValue(BlockPistonBase.EXTENDED)).booleanValue())
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(blockpos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||||
|
*/
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote && worldIn.getTileEntity(pos) == null)
|
||||||
|
{
|
||||||
|
worldIn.setBlockToAir(pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Item that this Block should drop when harvested.
|
||||||
|
*/
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns this Block's drops into the World as EntityItems.
|
||||||
|
*/
|
||||||
|
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
TileEntityPiston tileentitypiston = this.getTileEntity(worldIn, pos);
|
||||||
|
|
||||||
|
if (tileentitypiston != null)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = tileentitypiston.getPistonState();
|
||||||
|
iblockstate.getBlock().dropBlockAsItem(worldIn, pos, iblockstate, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
|
||||||
|
*/
|
||||||
|
public MovingObjectPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
{
|
||||||
|
worldIn.getTileEntity(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
TileEntityPiston tileentitypiston = this.getTileEntity(worldIn, pos);
|
||||||
|
|
||||||
|
if (tileentitypiston == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float f = tileentitypiston.getProgress(0.0F);
|
||||||
|
|
||||||
|
if (tileentitypiston.isExtending())
|
||||||
|
{
|
||||||
|
f = 1.0F - f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getBoundingBox(worldIn, pos, tileentitypiston.getPistonState(), f, tileentitypiston.getFacing());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
TileEntityPiston tileentitypiston = this.getTileEntity(worldIn, pos);
|
||||||
|
|
||||||
|
if (tileentitypiston != null)
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = tileentitypiston.getPistonState();
|
||||||
|
Block block = iblockstate.getBlock();
|
||||||
|
|
||||||
|
if (block == this || block.getMaterial() == Material.air)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float f = tileentitypiston.getProgress(0.0F);
|
||||||
|
|
||||||
|
if (tileentitypiston.isExtending())
|
||||||
|
{
|
||||||
|
f = 1.0F - f;
|
||||||
|
}
|
||||||
|
|
||||||
|
block.setBlockBoundsBasedOnState(worldIn, pos);
|
||||||
|
|
||||||
|
if (block == Blocks.piston || block == Blocks.sticky_piston)
|
||||||
|
{
|
||||||
|
f = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnumFacing enumfacing = tileentitypiston.getFacing();
|
||||||
|
this.minX = block.getBlockBoundsMinX() - (double)((float)enumfacing.getFrontOffsetX() * f);
|
||||||
|
this.minY = block.getBlockBoundsMinY() - (double)((float)enumfacing.getFrontOffsetY() * f);
|
||||||
|
this.minZ = block.getBlockBoundsMinZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
|
||||||
|
this.maxX = block.getBlockBoundsMaxX() - (double)((float)enumfacing.getFrontOffsetX() * f);
|
||||||
|
this.maxY = block.getBlockBoundsMaxY() - (double)((float)enumfacing.getFrontOffsetY() * f);
|
||||||
|
this.maxZ = block.getBlockBoundsMaxZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getBoundingBox(World worldIn, BlockPos pos, IBlockState extendingBlock, float progress, EnumFacing direction)
|
||||||
|
{
|
||||||
|
if (extendingBlock.getBlock() != this && extendingBlock.getBlock().getMaterial() != Material.air)
|
||||||
|
{
|
||||||
|
AxisAlignedBB axisalignedbb = extendingBlock.getBlock().getCollisionBoundingBox(worldIn, pos, extendingBlock);
|
||||||
|
|
||||||
|
if (axisalignedbb == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double d0 = axisalignedbb.minX;
|
||||||
|
double d1 = axisalignedbb.minY;
|
||||||
|
double d2 = axisalignedbb.minZ;
|
||||||
|
double d3 = axisalignedbb.maxX;
|
||||||
|
double d4 = axisalignedbb.maxY;
|
||||||
|
double d5 = axisalignedbb.maxZ;
|
||||||
|
|
||||||
|
if (direction.getFrontOffsetX() < 0)
|
||||||
|
{
|
||||||
|
d0 -= (double)((float)direction.getFrontOffsetX() * progress);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d3 -= (double)((float)direction.getFrontOffsetX() * progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction.getFrontOffsetY() < 0)
|
||||||
|
{
|
||||||
|
d1 -= (double)((float)direction.getFrontOffsetY() * progress);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d4 -= (double)((float)direction.getFrontOffsetY() * progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction.getFrontOffsetZ() < 0)
|
||||||
|
{
|
||||||
|
d2 -= (double)((float)direction.getFrontOffsetZ() * progress);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d5 -= (double)((float)direction.getFrontOffsetZ() * progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AxisAlignedBB(d0, d1, d2, d3, d4, d5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TileEntityPiston getTileEntity(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||||
|
return tileentity instanceof TileEntityPiston ? (TileEntityPiston)tileentity : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(FACING, BlockPistonExtension.getFacing(meta)).withProperty(TYPE, (meta & 8) > 0 ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i = i | ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||||
|
|
||||||
|
if (state.getValue(TYPE) == BlockPistonExtension.EnumPistonType.STICKY)
|
||||||
|
{
|
||||||
|
i |= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {FACING, TYPE});
|
||||||
|
}
|
||||||
|
}
|
||||||
145
client/src/main/java/net/minecraft/block/BlockPlanks.java
Normal file
145
client/src/main/java/net/minecraft/block/BlockPlanks.java
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.material.MapColor;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
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.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
|
||||||
|
public class BlockPlanks extends Block
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<BlockPlanks.EnumType> VARIANT = PropertyEnum.<BlockPlanks.EnumType>create("variant", BlockPlanks.EnumType.class);
|
||||||
|
|
||||||
|
public BlockPlanks()
|
||||||
|
{
|
||||||
|
super(Material.wood);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockPlanks.EnumType.OAK));
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||||
|
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||||
|
*/
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||||
|
*/
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
|
||||||
|
{
|
||||||
|
for (BlockPlanks.EnumType blockplanks$enumtype : BlockPlanks.EnumType.values())
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(itemIn, 1, blockplanks$enumtype.getMetadata()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(VARIANT, BlockPlanks.EnumType.byMetadata(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MapColor for this Block and the given BlockState
|
||||||
|
*/
|
||||||
|
public MapColor getMapColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockPlanks.EnumType)state.getValue(VARIANT)).func_181070_c();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {VARIANT});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumType implements IStringSerializable
|
||||||
|
{
|
||||||
|
OAK(0, "oak", MapColor.woodColor),
|
||||||
|
SPRUCE(1, "spruce", MapColor.obsidianColor),
|
||||||
|
BIRCH(2, "birch", MapColor.sandColor),
|
||||||
|
JUNGLE(3, "jungle", MapColor.dirtColor),
|
||||||
|
ACACIA(4, "acacia", MapColor.adobeColor),
|
||||||
|
DARK_OAK(5, "dark_oak", "big_oak", MapColor.brownColor);
|
||||||
|
|
||||||
|
private static final BlockPlanks.EnumType[] META_LOOKUP = new BlockPlanks.EnumType[values().length];
|
||||||
|
private final int meta;
|
||||||
|
private final String name;
|
||||||
|
private final String unlocalizedName;
|
||||||
|
private final MapColor field_181071_k;
|
||||||
|
|
||||||
|
private EnumType(int p_i46388_3_, String p_i46388_4_, MapColor p_i46388_5_)
|
||||||
|
{
|
||||||
|
this(p_i46388_3_, p_i46388_4_, p_i46388_4_, p_i46388_5_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EnumType(int p_i46389_3_, String p_i46389_4_, String p_i46389_5_, MapColor p_i46389_6_)
|
||||||
|
{
|
||||||
|
this.meta = p_i46389_3_;
|
||||||
|
this.name = p_i46389_4_;
|
||||||
|
this.unlocalizedName = p_i46389_5_;
|
||||||
|
this.field_181071_k = p_i46389_6_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMetadata()
|
||||||
|
{
|
||||||
|
return this.meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapColor func_181070_c()
|
||||||
|
{
|
||||||
|
return this.field_181071_k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockPlanks.EnumType byMetadata(int meta)
|
||||||
|
{
|
||||||
|
if (meta < 0 || meta >= META_LOOKUP.length)
|
||||||
|
{
|
||||||
|
meta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return META_LOOKUP[meta];
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnlocalizedName()
|
||||||
|
{
|
||||||
|
return this.unlocalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (BlockPlanks.EnumType blockplanks$enumtype : values())
|
||||||
|
{
|
||||||
|
META_LOOKUP[blockplanks$enumtype.getMetadata()] = blockplanks$enumtype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
484
client/src/main/java/net/minecraft/block/BlockPortal.java
Normal file
484
client/src/main/java/net/minecraft/block/BlockPortal.java
Normal file
@@ -0,0 +1,484 @@
|
|||||||
|
package net.minecraft.block;
|
||||||
|
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import java.util.Random;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.BlockWorldState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.block.state.pattern.BlockPattern;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemMonsterPlacer;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.util.EnumWorldBlockLayer;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockPortal extends BlockBreakable
|
||||||
|
{
|
||||||
|
public static final PropertyEnum<EnumFacing.Axis> AXIS = PropertyEnum.<EnumFacing.Axis>create("axis", EnumFacing.Axis.class, new EnumFacing.Axis[] {EnumFacing.Axis.X, EnumFacing.Axis.Z});
|
||||||
|
|
||||||
|
public BlockPortal()
|
||||||
|
{
|
||||||
|
super(Material.portal, false);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.X));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
super.updateTick(worldIn, pos, state, rand);
|
||||||
|
|
||||||
|
if (worldIn.provider.isSurfaceWorld() && worldIn.getGameRules().getBoolean("doMobSpawning") && rand.nextInt(2000) < worldIn.getDifficulty().getDifficultyId())
|
||||||
|
{
|
||||||
|
int i = pos.getY();
|
||||||
|
BlockPos blockpos;
|
||||||
|
|
||||||
|
for (blockpos = pos; !World.doesBlockHaveSolidTopSurface(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down())
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i > 0 && !worldIn.getBlockState(blockpos.up()).getBlock().isNormalCube())
|
||||||
|
{
|
||||||
|
Entity entity = ItemMonsterPlacer.spawnCreature(worldIn, 57, (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 1.1D, (double)blockpos.getZ() + 0.5D);
|
||||||
|
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
entity.timeUntilPortal = entity.getPortalCooldown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)worldIn.getBlockState(pos).getValue(AXIS);
|
||||||
|
float f = 0.125F;
|
||||||
|
float f1 = 0.125F;
|
||||||
|
|
||||||
|
if (enumfacing$axis == EnumFacing.Axis.X)
|
||||||
|
{
|
||||||
|
f = 0.5F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enumfacing$axis == EnumFacing.Axis.Z)
|
||||||
|
{
|
||||||
|
f1 = 0.5F;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMetaForAxis(EnumFacing.Axis axis)
|
||||||
|
{
|
||||||
|
return axis == EnumFacing.Axis.X ? 1 : (axis == EnumFacing.Axis.Z ? 2 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean func_176548_d(World worldIn, BlockPos p_176548_2_)
|
||||||
|
{
|
||||||
|
BlockPortal.Size blockportal$size = new BlockPortal.Size(worldIn, p_176548_2_, EnumFacing.Axis.X);
|
||||||
|
|
||||||
|
if (blockportal$size.func_150860_b() && blockportal$size.field_150864_e == 0)
|
||||||
|
{
|
||||||
|
blockportal$size.func_150859_c();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BlockPortal.Size blockportal$size1 = new BlockPortal.Size(worldIn, p_176548_2_, EnumFacing.Axis.Z);
|
||||||
|
|
||||||
|
if (blockportal$size1.func_150860_b() && blockportal$size1.field_150864_e == 0)
|
||||||
|
{
|
||||||
|
blockportal$size1.func_150859_c();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a neighboring block changes.
|
||||||
|
*/
|
||||||
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)state.getValue(AXIS);
|
||||||
|
|
||||||
|
if (enumfacing$axis == EnumFacing.Axis.X)
|
||||||
|
{
|
||||||
|
BlockPortal.Size blockportal$size = new BlockPortal.Size(worldIn, pos, EnumFacing.Axis.X);
|
||||||
|
|
||||||
|
if (!blockportal$size.func_150860_b() || blockportal$size.field_150864_e < blockportal$size.field_150868_h * blockportal$size.field_150862_g)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.air.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (enumfacing$axis == EnumFacing.Axis.Z)
|
||||||
|
{
|
||||||
|
BlockPortal.Size blockportal$size1 = new BlockPortal.Size(worldIn, pos, EnumFacing.Axis.Z);
|
||||||
|
|
||||||
|
if (!blockportal$size1.func_150860_b() || blockportal$size1.field_150864_e < blockportal$size1.field_150868_h * blockportal$size1.field_150862_g)
|
||||||
|
{
|
||||||
|
worldIn.setBlockState(pos, Blocks.air.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||||
|
{
|
||||||
|
EnumFacing.Axis enumfacing$axis = null;
|
||||||
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(pos).getBlock() == this)
|
||||||
|
{
|
||||||
|
enumfacing$axis = (EnumFacing.Axis)iblockstate.getValue(AXIS);
|
||||||
|
|
||||||
|
if (enumfacing$axis == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enumfacing$axis == EnumFacing.Axis.Z && side != EnumFacing.EAST && side != EnumFacing.WEST)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enumfacing$axis == EnumFacing.Axis.X && side != EnumFacing.SOUTH && side != EnumFacing.NORTH)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean flag = worldIn.getBlockState(pos.west()).getBlock() == this && worldIn.getBlockState(pos.west(2)).getBlock() != this;
|
||||||
|
boolean flag1 = worldIn.getBlockState(pos.east()).getBlock() == this && worldIn.getBlockState(pos.east(2)).getBlock() != this;
|
||||||
|
boolean flag2 = worldIn.getBlockState(pos.north()).getBlock() == this && worldIn.getBlockState(pos.north(2)).getBlock() != this;
|
||||||
|
boolean flag3 = worldIn.getBlockState(pos.south()).getBlock() == this && worldIn.getBlockState(pos.south(2)).getBlock() != this;
|
||||||
|
boolean flag4 = flag || flag1 || enumfacing$axis == EnumFacing.Axis.X;
|
||||||
|
boolean flag5 = flag2 || flag3 || enumfacing$axis == EnumFacing.Axis.Z;
|
||||||
|
return flag4 && side == EnumFacing.WEST ? true : (flag4 && side == EnumFacing.EAST ? true : (flag5 && side == EnumFacing.NORTH ? true : flag5 && side == EnumFacing.SOUTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the quantity of items to drop on block destruction.
|
||||||
|
*/
|
||||||
|
public int quantityDropped(Random random)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumWorldBlockLayer getBlockLayer()
|
||||||
|
{
|
||||||
|
return EnumWorldBlockLayer.TRANSLUCENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called When an Entity Collided with the Block
|
||||||
|
*/
|
||||||
|
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
|
||||||
|
{
|
||||||
|
if (entityIn.ridingEntity == null && entityIn.riddenByEntity == null)
|
||||||
|
{
|
||||||
|
entityIn.func_181015_d(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
||||||
|
{
|
||||||
|
if (rand.nextInt(100) == 0)
|
||||||
|
{
|
||||||
|
worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "portal.portal", 0.5F, rand.nextFloat() * 0.4F + 0.8F, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
double d0 = (double)((float)pos.getX() + rand.nextFloat());
|
||||||
|
double d1 = (double)((float)pos.getY() + rand.nextFloat());
|
||||||
|
double d2 = (double)((float)pos.getZ() + rand.nextFloat());
|
||||||
|
double d3 = ((double)rand.nextFloat() - 0.5D) * 0.5D;
|
||||||
|
double d4 = ((double)rand.nextFloat() - 0.5D) * 0.5D;
|
||||||
|
double d5 = ((double)rand.nextFloat() - 0.5D) * 0.5D;
|
||||||
|
int j = rand.nextInt(2) * 2 - 1;
|
||||||
|
|
||||||
|
if (worldIn.getBlockState(pos.west()).getBlock() != this && worldIn.getBlockState(pos.east()).getBlock() != this)
|
||||||
|
{
|
||||||
|
d0 = (double)pos.getX() + 0.5D + 0.25D * (double)j;
|
||||||
|
d3 = (double)(rand.nextFloat() * 2.0F * (float)j);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d2 = (double)pos.getZ() + 0.5D + 0.25D * (double)j;
|
||||||
|
d5 = (double)(rand.nextFloat() * 2.0F * (float)j);
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(World worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given metadata into a BlockState for this Block
|
||||||
|
*/
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(AXIS, (meta & 3) == 2 ? EnumFacing.Axis.Z : EnumFacing.Axis.X);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the BlockState into the correct metadata value
|
||||||
|
*/
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return getMetaForAxis((EnumFacing.Axis)state.getValue(AXIS));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
return new BlockState(this, new IProperty[] {AXIS});
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPattern.PatternHelper func_181089_f(World p_181089_1_, BlockPos p_181089_2_)
|
||||||
|
{
|
||||||
|
EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Z;
|
||||||
|
BlockPortal.Size blockportal$size = new BlockPortal.Size(p_181089_1_, p_181089_2_, EnumFacing.Axis.X);
|
||||||
|
LoadingCache<BlockPos, BlockWorldState> loadingcache = BlockPattern.func_181627_a(p_181089_1_, true);
|
||||||
|
|
||||||
|
if (!blockportal$size.func_150860_b())
|
||||||
|
{
|
||||||
|
enumfacing$axis = EnumFacing.Axis.X;
|
||||||
|
blockportal$size = new BlockPortal.Size(p_181089_1_, p_181089_2_, EnumFacing.Axis.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!blockportal$size.func_150860_b())
|
||||||
|
{
|
||||||
|
return new BlockPattern.PatternHelper(p_181089_2_, EnumFacing.NORTH, EnumFacing.UP, loadingcache, 1, 1, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int[] aint = new int[EnumFacing.AxisDirection.values().length];
|
||||||
|
EnumFacing enumfacing = blockportal$size.field_150866_c.rotateYCCW();
|
||||||
|
BlockPos blockpos = blockportal$size.field_150861_f.up(blockportal$size.func_181100_a() - 1);
|
||||||
|
|
||||||
|
for (EnumFacing.AxisDirection enumfacing$axisdirection : EnumFacing.AxisDirection.values())
|
||||||
|
{
|
||||||
|
BlockPattern.PatternHelper blockpattern$patternhelper = new BlockPattern.PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection ? blockpos : blockpos.offset(blockportal$size.field_150866_c, blockportal$size.func_181101_b() - 1), EnumFacing.func_181076_a(enumfacing$axisdirection, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.func_181101_b(), blockportal$size.func_181100_a(), 1);
|
||||||
|
|
||||||
|
for (int i = 0; i < blockportal$size.func_181101_b(); ++i)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < blockportal$size.func_181100_a(); ++j)
|
||||||
|
{
|
||||||
|
BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, 1);
|
||||||
|
|
||||||
|
if (blockworldstate.getBlockState() != null && blockworldstate.getBlockState().getBlock().getMaterial() != Material.air)
|
||||||
|
{
|
||||||
|
++aint[enumfacing$axisdirection.ordinal()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EnumFacing.AxisDirection enumfacing$axisdirection1 = EnumFacing.AxisDirection.POSITIVE;
|
||||||
|
|
||||||
|
for (EnumFacing.AxisDirection enumfacing$axisdirection2 : EnumFacing.AxisDirection.values())
|
||||||
|
{
|
||||||
|
if (aint[enumfacing$axisdirection2.ordinal()] < aint[enumfacing$axisdirection1.ordinal()])
|
||||||
|
{
|
||||||
|
enumfacing$axisdirection1 = enumfacing$axisdirection2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BlockPattern.PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection1 ? blockpos : blockpos.offset(blockportal$size.field_150866_c, blockportal$size.func_181101_b() - 1), EnumFacing.func_181076_a(enumfacing$axisdirection1, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.func_181101_b(), blockportal$size.func_181100_a(), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Size
|
||||||
|
{
|
||||||
|
private final World world;
|
||||||
|
private final EnumFacing.Axis axis;
|
||||||
|
private final EnumFacing field_150866_c;
|
||||||
|
private final EnumFacing field_150863_d;
|
||||||
|
private int field_150864_e = 0;
|
||||||
|
private BlockPos field_150861_f;
|
||||||
|
private int field_150862_g;
|
||||||
|
private int field_150868_h;
|
||||||
|
|
||||||
|
public Size(World worldIn, BlockPos p_i45694_2_, EnumFacing.Axis p_i45694_3_)
|
||||||
|
{
|
||||||
|
this.world = worldIn;
|
||||||
|
this.axis = p_i45694_3_;
|
||||||
|
|
||||||
|
if (p_i45694_3_ == EnumFacing.Axis.X)
|
||||||
|
{
|
||||||
|
this.field_150863_d = EnumFacing.EAST;
|
||||||
|
this.field_150866_c = EnumFacing.WEST;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.field_150863_d = EnumFacing.NORTH;
|
||||||
|
this.field_150866_c = EnumFacing.SOUTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockPos blockpos = p_i45694_2_; p_i45694_2_.getY() > blockpos.getY() - 21 && p_i45694_2_.getY() > 0 && this.func_150857_a(worldIn.getBlockState(p_i45694_2_.down()).getBlock()); p_i45694_2_ = p_i45694_2_.down())
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = this.func_180120_a(p_i45694_2_, this.field_150863_d) - 1;
|
||||||
|
|
||||||
|
if (i >= 0)
|
||||||
|
{
|
||||||
|
this.field_150861_f = p_i45694_2_.offset(this.field_150863_d, i);
|
||||||
|
this.field_150868_h = this.func_180120_a(this.field_150861_f, this.field_150866_c);
|
||||||
|
|
||||||
|
if (this.field_150868_h < 2 || this.field_150868_h > 21)
|
||||||
|
{
|
||||||
|
this.field_150861_f = null;
|
||||||
|
this.field_150868_h = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.field_150861_f != null)
|
||||||
|
{
|
||||||
|
this.field_150862_g = this.func_150858_a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int func_180120_a(BlockPos p_180120_1_, EnumFacing p_180120_2_)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 22; ++i)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = p_180120_1_.offset(p_180120_2_, i);
|
||||||
|
|
||||||
|
if (!this.func_150857_a(this.world.getBlockState(blockpos).getBlock()) || this.world.getBlockState(blockpos.down()).getBlock() != Blocks.obsidian)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = this.world.getBlockState(p_180120_1_.offset(p_180120_2_, i)).getBlock();
|
||||||
|
return block == Blocks.obsidian ? i : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int func_181100_a()
|
||||||
|
{
|
||||||
|
return this.field_150862_g;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int func_181101_b()
|
||||||
|
{
|
||||||
|
return this.field_150868_h;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int func_150858_a()
|
||||||
|
{
|
||||||
|
label24:
|
||||||
|
|
||||||
|
for (this.field_150862_g = 0; this.field_150862_g < 21; ++this.field_150862_g)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this.field_150868_h; ++i)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = this.field_150861_f.offset(this.field_150866_c, i).up(this.field_150862_g);
|
||||||
|
Block block = this.world.getBlockState(blockpos).getBlock();
|
||||||
|
|
||||||
|
if (!this.func_150857_a(block))
|
||||||
|
{
|
||||||
|
break label24;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block == Blocks.portal)
|
||||||
|
{
|
||||||
|
++this.field_150864_e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
block = this.world.getBlockState(blockpos.offset(this.field_150863_d)).getBlock();
|
||||||
|
|
||||||
|
if (block != Blocks.obsidian)
|
||||||
|
{
|
||||||
|
break label24;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i == this.field_150868_h - 1)
|
||||||
|
{
|
||||||
|
block = this.world.getBlockState(blockpos.offset(this.field_150866_c)).getBlock();
|
||||||
|
|
||||||
|
if (block != Blocks.obsidian)
|
||||||
|
{
|
||||||
|
break label24;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < this.field_150868_h; ++j)
|
||||||
|
{
|
||||||
|
if (this.world.getBlockState(this.field_150861_f.offset(this.field_150866_c, j).up(this.field_150862_g)).getBlock() != Blocks.obsidian)
|
||||||
|
{
|
||||||
|
this.field_150862_g = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.field_150862_g <= 21 && this.field_150862_g >= 3)
|
||||||
|
{
|
||||||
|
return this.field_150862_g;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.field_150861_f = null;
|
||||||
|
this.field_150868_h = 0;
|
||||||
|
this.field_150862_g = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean func_150857_a(Block p_150857_1_)
|
||||||
|
{
|
||||||
|
return p_150857_1_.blockMaterial == Material.air || p_150857_1_ == Blocks.fire || p_150857_1_ == Blocks.portal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean func_150860_b()
|
||||||
|
{
|
||||||
|
return this.field_150861_f != null && this.field_150868_h >= 2 && this.field_150868_h <= 21 && this.field_150862_g >= 3 && this.field_150862_g <= 21;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void func_150859_c()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this.field_150868_h; ++i)
|
||||||
|
{
|
||||||
|
BlockPos blockpos = this.field_150861_f.offset(this.field_150866_c, i);
|
||||||
|
|
||||||
|
for (int j = 0; j < this.field_150862_g; ++j)
|
||||||
|
{
|
||||||
|
this.world.setBlockState(blockpos.up(j), Blocks.portal.getDefaultState().withProperty(BlockPortal.AXIS, this.axis), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user