use of net.minecraft.item.ItemBlock in project ArsMagica2 by Mithion.
the class GuiArcaneCompendium method mouseClicked.
@Override
protected void mouseClicked(int par1, int par2, int par3) {
if (stackTip != null) {
GuiArcaneCompendium newGuiToDisplay = null;
if (stackTip.getItem() instanceof ItemBlock) {
ItemBlock item = (ItemBlock) stackTip.getItem();
Block block = item.field_150939_a;
String name = block.getUnlocalizedName().replace("arsmagica2:", "").replace("tile.", "");
String metaname = name + "@" + stackTip.getItemDamage();
String searchName = metaname;
CompendiumEntry entry = ArcaneCompendium.instance.getEntry(metaname);
if (entry == null) {
searchName = name;
entry = ArcaneCompendium.instance.getEntry(searchName);
}
if (entry != null) {
newGuiToDisplay = entry.getCompendiumGui(searchName);
}
} else if (stackTip.getItem() == ItemsCommonProxy.spell_component) {
String name = SkillManager.instance.getSkillName(SkillManager.instance.getSkill(stackTip.getItemDamage()));
CompendiumEntry entry = ArcaneCompendium.instance.getEntry(name);
if (entry != null) {
newGuiToDisplay = new GuiArcaneCompendium(name, stackTip.getItem(), stackTip.getItemDamage());
}
} else {
String name = stackTip.getItem().getUnlocalizedName().replace("item.", "").replace("arsmagica2:", "");
String metaname = name + "@" + stackTip.getItemDamage();
String searchName = metaname;
CompendiumEntry entry = ArcaneCompendium.instance.getEntry(metaname);
if (entry == null) {
searchName = name;
entry = ArcaneCompendium.instance.getEntry(searchName);
}
if (entry != null) {
newGuiToDisplay = entry.getCompendiumGui(searchName);
}
}
if (newGuiToDisplay != null) {
storeBreadcrumb();
Minecraft.getMinecraft().displayGuiScreen(newGuiToDisplay);
}
return;
} else if (entryEntity != null) {
isDragging = true;
lastMouseX = par1;
}
super.mouseClicked(par1, par2, par3);
}
use of net.minecraft.item.ItemBlock in project OpenLights by PC-Logix.
the class DriverBlock method worksWith.
protected boolean worksWith(final Block referenceBlock, final int referenceMetadata) {
for (ItemStack stack : blocks) {
if (stack != null && stack.getItem() instanceof ItemBlock) {
final ItemBlock item = (ItemBlock) stack.getItem();
final Block supportedBlock = item.field_150939_a;
final int supportedMetadata = item.getMetadata(stack.getItemDamage());
if (referenceBlock == supportedBlock && (referenceMetadata == supportedMetadata || stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) {
return true;
}
}
}
return false;
}
use of net.minecraft.item.ItemBlock in project Railcraft by Railcraft.
the class ItemFirestoneRefined method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (player.canPlayerEdit(pos, side, stack)) {
Block block = WorldPlugin.getBlock(world, pos);
if (block != Blocks.STONE) {
List<ItemStack> drops = block.getDrops(world, pos, WorldPlugin.getBlockState(world, pos), 0);
if (drops.size() == 1 && drops.get(0) != null && drops.get(0).getItem() instanceof ItemBlock) {
ItemStack cooked = FurnaceRecipes.instance().getSmeltingResult(drops.get(0));
if (cooked != null && cooked.getItem() instanceof ItemBlock) {
IBlockState newState = InvTools.getBlockStateFromStack(cooked, world, pos);
if (newState != null) {
WorldPlugin.setBlockState(world, pos, newState);
SoundHelper.playSound(world, null, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
stack.damageItem(1, player);
return EnumActionResult.SUCCESS;
}
}
}
}
}
pos = pos.offset(side);
if (player.canPlayerEdit(pos, side, stack) && world.isAirBlock(pos)) {
SoundHelper.playSound(world, null, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
world.setBlockState(pos, Blocks.FIRE.getDefaultState());
stack.damageItem(1, player);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
use of net.minecraft.item.ItemBlock in project Railcraft by Railcraft.
the class EntityCartUndercutter method replaceWith.
private void replaceWith(BlockPos pos, int slotExist, int slotStock) {
ItemStack exist = patternInv.getStackInSlot(slotExist);
ItemStack stock = getStackInSlot(slotStock);
if (!isValidBallast(stock))
return;
IBlockState oldState = WorldPlugin.getBlockState(worldObj, pos);
if (oldState == null || !blockMatches(oldState, exist))
return;
if (safeToReplace(pos)) {
Block stockBlock = InvTools.getBlockFromStack(stock);
List<ItemStack> drops = oldState.getBlock().getDrops(worldObj, pos, oldState, 0);
ItemBlock item = (ItemBlock) stock.getItem();
int newMeta = 0;
if (item.getHasSubtypes())
newMeta = item.getMetadata(stock.getItemDamage());
IBlockState newState;
if (stockBlock != null && WorldPlugin.setBlockState(worldObj, pos, (newState = stockBlock.getStateFromMeta(newMeta)))) {
SoundHelper.playBlockSound(worldObj, pos, stockBlock.getSoundType().getPlaceSound(), SoundCategory.NEUTRAL, (1f + 1.0F) / 2.0F, 1f * 0.8F, newState);
decrStackSize(slotStock, 1);
for (ItemStack stack : drops) {
CartToolsAPI.transferHelper.offerOrDropItem(this, stack);
}
blink();
}
}
}
use of net.minecraft.item.ItemBlock in project Railcraft by Railcraft.
the class EntityCartUndercutter method blockMatches.
private boolean blockMatches(IBlockState state, ItemStack stack) {
if (InvTools.isEmpty(stack))
return true;
if (stack.getItem() instanceof ItemBlock) {
ItemBlock existItem = (ItemBlock) stack.getItem();
int existMeta = OreDictionary.WILDCARD_VALUE;
if (existItem.getHasSubtypes())
existMeta = existItem.getMetadata(stack.getItemDamage());
Block stackBlock = InvTools.getBlockFromStack(stack);
return (stackBlock == state.getBlock() && (existMeta == OreDictionary.WILDCARD_VALUE || state.getBlock().getMetaFromState(state) == existMeta)) || (stackBlock == Blocks.DIRT && stackBlock == Blocks.GRASS);
}
return false;
}
Aggregations