Lots of changes, fixed a few crashes, and minor bugs. Also, doesnt need Asielib anymore

This commit is contained in:
Fenn committed 2014-04-21 19:13:15 +01:00
1 parent 333c1d6596
commit fd4351711a
146 files changed
+12167 -9527

No files matched your search

+120 -87
View File
@@ -1,87 +1,120 @@
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;
}
}
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;
}
}