mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-25 14:44:35 +00:00
first commit
This commit is contained in:
commit
c79c767bb8
1389 files changed
+10744
No files matched your search
@@ -0,0 +1,87 @@
|
||||
package info.jbcs.minecraft.chisel.item;
|
||||
|
||||
import info.jbcs.minecraft.chisel.block.BlockMarbleSlab;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemMarbleSlab extends ItemCarvable {
|
||||
|
||||
public ItemMarbleSlab(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given ItemBlock can be placed on the given side of the given block position.
|
||||
*/
|
||||
@Override
|
||||
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack){
|
||||
BlockMarbleSlab block = (BlockMarbleSlab)Block.getBlockFromItem(this);
|
||||
|
||||
switch(side){
|
||||
case 0: --y; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --z; break;
|
||||
case 3: ++z; break;
|
||||
case 4: --x; break;
|
||||
case 5: ++x; break;
|
||||
}
|
||||
|
||||
Block targetBlock = world.getBlock(x, y, z);
|
||||
int meta=world.getBlockMetadata(x, y, z);
|
||||
|
||||
if((targetBlock.equals(block) || targetBlock.equals(block.top)) && meta==stack.getItemDamage())
|
||||
return true;
|
||||
|
||||
return world.canPlaceEntityOnSide(block, x, y, z, false, side, (Entity)null, stack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hx, float hy, float hz){
|
||||
BlockMarbleSlab block = (BlockMarbleSlab)Block.getBlockFromItem(this);
|
||||
|
||||
Block targetBlock = world.getBlock(x, y, z);
|
||||
int meta=world.getBlockMetadata(x, y, z);
|
||||
boolean metaMatches=meta==stack.getItemDamage();
|
||||
|
||||
if(metaMatches && side==0 && targetBlock.equals(block.top)){
|
||||
world.setBlock(x, y, z, block.master, meta, 2);
|
||||
return true;
|
||||
} else if(metaMatches && side==1 && targetBlock.equals(block.bottom)){
|
||||
world.setBlock(x, y, z, block.master, meta, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean result=super.onItemUse(stack,player,world,x,y,z,side,hz,hy,hz);
|
||||
|
||||
|
||||
switch(side){
|
||||
case 0: --y; break;
|
||||
case 1: ++y; break;
|
||||
case 2: --z; break;
|
||||
case 3: ++z; break;
|
||||
case 4: --x; break;
|
||||
case 5: ++x; break;
|
||||
}
|
||||
|
||||
targetBlock = world.getBlock(x, y, z);
|
||||
meta=world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(!result && (targetBlock.equals(block.top) || targetBlock.equals(block.bottom)) && meta==stack.getItemDamage()){
|
||||
world.setBlock(x, y, z, block.master, meta, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!result)
|
||||
return false;
|
||||
|
||||
if(side != 0 && (side == 1 || hy <= 0.5D))
|
||||
return true;
|
||||
|
||||
world.setBlock(x, y, z, block.top, meta, 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user