本文整理汇总了Java中net.minecraft.item.ItemShears类的典型用法代码示例。如果您正苦于以下问题:Java ItemShears类的具体用法?Java ItemShears怎么用?Java ItemShears使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemShears类属于net.minecraft.item包,在下文中一共展示了ItemShears类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockActivated
import net.minecraft.item.ItemShears; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing face, float hitX, float hitY, float hitZ){
ItemStack heldItem = player.getHeldItem(hand);
if (heldItem.getItem() instanceof ItemShears){
if (state.getBlock() == this){
if (!state.getValue(CLIPPED) && state.getValue(TYPE) != 0){
ItemStack stack = heldItem.copy();
((ItemShears)heldItem.getItem()).setDamage(stack, ((ItemShears)heldItem.getItem()).getDamage(stack)+1);
if (((ItemShears)heldItem.getItem()).getDamage(stack) > ((ItemShears)heldItem.getItem()).getMaxDamage()){
player.setHeldItem(hand, ItemStack.EMPTY);
}
else {
player.setHeldItem(hand, stack);
}
this.dropBlockAsItem(world, pos, state, 0);
world.setBlockState(pos, state.withProperty(CLIPPED, true), 8);
world.notifyBlockUpdate(pos, state, state.withProperty(CLIPPED, true), 8);
return true;
}
}
}
return false;
}
示例2: isUsingShears
import net.minecraft.item.ItemShears; //导入依赖的package包/类
private static boolean isUsingShears(EntityPlayer player)
{
ItemStack stack = player.getHeldItemMainhand();
if (!stack.isEmpty() && stack.getItem() instanceof ItemShears)
{
return true;
}
stack = player.getHeldItemOffhand();
if (!stack.isEmpty() && stack.getItem() instanceof ItemShears)
{
return true;
}
return false;
}
示例3: onSheared
import net.minecraft.item.ItemShears; //导入依赖的package包/类
@SubscribeEvent
public void onSheared(EntityInteractSpecific event) {
ItemStack rainbow = BaublesApi.getBaublesHandler((EntityPlayer)event.getEntityPlayer()).getStackInSlot(6);
if (rainbow == null || (rainbow != null && rainbow.getItem() != this)) return;
if (!(event.getTarget() instanceof IShearable)) return;
if (!(event.getTarget() instanceof EntitySheep) || (event.getTarget() instanceof EntitySheep && ((EntitySheep)event.getTarget()).getSheared())) return;
if (event.getItemStack() == null || (event.getItemStack() != null && !(event.getItemStack().getItem() instanceof ItemShears))) return;
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, event.getItemStack());
if (!event.getWorld().isRemote) {
List<ItemStack> wools = ((IShearable)event.getTarget()).onSheared(event.getItemStack(), event.getWorld(), event.getPos(), fortune);
for (ItemStack is : wools) {
Random rand = new Random();
is.setItemDamage(rand.nextInt(15));
EntityItem wool = new EntityItem(event.getWorld(), event.getTarget().posX, event.getTarget().posY, event.getTarget().posZ, is);
event.getWorld().spawnEntityInWorld(wool);
}
}
}
示例4: onItemCraft
import net.minecraft.item.ItemShears; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onItemCraft(ItemCraftedEvent event) {
Item item = event.crafting.getItem();
if (item == HFItems.seeds_hemp_crushed || item == HFItems.seeds_indica_crushed
|| item == HFItems.seeds_sativa_crushed) {
for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
if (event.craftMatrix.getStackInSlot(i) != null) {
ItemStack stack = event.craftMatrix.getStackInSlot(i);
if (stack.getItem() instanceof ItemShears) {
if (stack.getItemDamage() < stack.getMaxDamage()) {
stack.shrink(1);
stack.setItemDamage(stack.getItemDamage() + 1);
event.craftMatrix.setInventorySlotContents(i, stack);
}
}
}
}
}
}
示例5: isItemValid
import net.minecraft.item.ItemShears; //导入依赖的package包/类
@Override
protected boolean isItemValid(TileEntity tileEntity, ItemStack itemStack)
{
Class<?> cls = tileEntity.getClass();
if(cls != TEToolRack.class)
return false;
Item item = itemStack.getItem();
return item instanceof ItemTool ||
item instanceof ItemWeapon ||
item instanceof ItemHoe ||
item instanceof ItemProPick ||
item instanceof ItemBow ||
item instanceof ItemSword ||
item instanceof ItemAxe ||
item instanceof ItemSpade ||
item instanceof ItemShears ||
item instanceof ItemSpindle
;
}
示例6: registerShearingUpgrades
import net.minecraft.item.ItemShears; //导入依赖的package包/类
private static void registerShearingUpgrades() {
if (ConfigurationLib.shearUpgradesEnabled) {
for (String shearUpgrade : ConfigurationLib.shearUpgrades) {
String[] string = shearUpgrade.split("-");
int shearUpgradeID = Integer.parseInt(string[0]);
String unlocalizedName = string[1];
if (Item.itemRegistry.containsKey(unlocalizedName)) {
Object object = Item.itemRegistry.getObject(unlocalizedName);
if (object != null && object instanceof ItemShears) {
ItemStack shears = new ItemStack((Item) object);
ComputerCraftAPI.registerTurtleUpgrade(new ShearingUpgrade(shearUpgradeID, shears));
}
}
}
}
}
示例7: preInit
import net.minecraft.item.ItemShears; //导入依赖的package包/类
public static void preInit() {
for (final Object o : IceAndShadow2.getPreRegistrationHandlers()) {
IaSRegistry.doAdd(o);
}
setPrimarilyTransfusionTarget(ItemArmor.class);
setPrimarilyTransfusionTarget(ItemTool.class);
setPrimarilyTransfusionTarget(ItemSword.class);
setPrimarilyTransfusionTarget(ItemHoe.class);
setPrimarilyTransfusionTarget(ItemShears.class);
setPrimarilyTransfusionTarget(ItemFlintAndSteel.class);
setPrimarilyTransfusionTarget(ItemBow.class);
setPrimarilyTransfusionTarget(ItemFishingRod.class);
setPrimarilyTransfusionTarget(IaSItemEchirArmorActive.class);
setPrimarilyTransfusionTarget(IaSItemEchirKnifeActive.class);
setPrimarilyTransfusionTarget(IaSItemEchirToolActive.class);
setPrimarilyTransfusionTarget(IaSItemToolBroken.class);
setPrimarilyTransfusionTarget(NyxBaseItemBow.class);
setPrimarilyTransfusionTarget(NyxItemFlask.class);
setPrimarilyTransfusionTarget(NyxItemSwordFrost.class);
addGrenadeLogic(new NyxGrenadeExplosive());
addGrenadeLogic(new NyxGrenadeIceWall());
addGrenadeLogic(new NyxGrenadeShadow());
}
示例8: damageTool
import net.minecraft.item.ItemShears; //导入依赖的package包/类
public static boolean damageTool(ItemStack tool, World world, int x, int y, int z) {
if ( (tool.getItem() instanceof ItemShears) || (tool.getItem() instanceof ItemTool) ||
(tool.getItem() instanceof ItemHoe) || (tool.getItem() instanceof ItemSword) ) {
if (tool.attemptDamageItem(1, RND)) {
return true;
}
} else {
Block mineBlock = world.getBlockState(new BlockPos(x, y, z)).getBlock();
PlayerFake fakePlayer = new PlayerFake((WorldServer)world);
if (tinkersType(tool.getItem())==TYPE_HOE) {
tool.attemptDamageItem(1, RND);
} else {
tool.getItem().onBlockDestroyed(tool, world, mineBlock.getDefaultState(), new BlockPos(x, y, z), fakePlayer);
}
if (tinkersIsBroken(tool)) return true;
}
return false;
}
示例9: identityType
import net.minecraft.item.ItemShears; //导入依赖的package包/类
private static String identityType(@Nonnull ItemStack stack) {
Item item = stack.getItem();
if (item instanceof ItemArmor) {
switch (((ItemArmor)item).armorType) {
case HEAD:
return "helmet";
case CHEST:
return "chestplate";
case LEGS:
return "leggings";
case FEET:
return "boots";
default:
break;
}
} else if (item instanceof ItemPickaxe) return "pickaxe";
else if (item instanceof ItemShears) return "shears";
else if (item instanceof ItemAxe) return "axe";
else if (item instanceof ItemSpade) return "shovel";
else if (item instanceof ItemBlock) return "block";
else if (item instanceof ItemBucket) return "bucket";
return "gizmo";
}
示例10: harvestBlock
import net.minecraft.item.ItemShears; //导入依赖的package包/类
@Override
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) {
if (!worldIn.isRemote && stack.getItem() instanceof ItemShears) {
player.addStat(StatList.getBlockStats(this));
spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this)));
} else {
super.harvestBlock(worldIn, player, pos, state, te, stack);
}
}
示例11: harvestEvent
import net.minecraft.item.ItemShears; //导入依赖的package包/类
@SubscribeEvent
public void harvestEvent(BlockEvent.HarvestDropsEvent event) {
if (EtFuturum.enableSilkTouchingMushrooms && event.isSilkTouching)
if (event.block == Blocks.brown_mushroom_block) {
event.drops.clear();
event.drops.add(new ItemStack(ModBlocks.brown_mushroom_block));
} else if (event.block == Blocks.red_mushroom_block) {
event.drops.clear();
event.drops.add(new ItemStack(ModBlocks.red_mushroom_block));
}
if (EtFuturum.enableSticksFromDeadBushes)
if (event.block == Blocks.deadbush) {
boolean isShears = event.harvester != null && event.harvester.getCurrentEquippedItem() != null && event.harvester.getCurrentEquippedItem().getItem() instanceof ItemShears;
if (event.harvester == null || event.harvester.getCurrentEquippedItem() == null || !isShears)
for (int i = 0; i < event.world.rand.nextInt(3); i++)
event.drops.add(new ItemStack(Items.stick));
}
if (EtFuturum.enableShearableCobwebs)
if (event.block == Blocks.web && event.harvester != null) {
ItemStack stack = event.harvester.getCurrentEquippedItem();
if (stack != null && stack.getItem() instanceof ItemShears) {
event.drops.clear();
event.drops.add(new ItemStack(Blocks.web));
}
}
}
示例12: onShearEvent
import net.minecraft.item.ItemShears; //导入依赖的package包/类
@SubscribeEvent
public void onShearEvent(PlayerInteractEvent.EntityInteractSpecific event)
{
if(!InteractionBWM.HARDCORE_SHEARING)
return;
World world = event.getWorld();
BlockPos pos = event.getEntity().getPosition();
ItemStack tool = event.getItemStack();
EntityPlayer player = event.getEntityPlayer();
if(!world.isRemote && event.getTarget() instanceof EntitySheep && tool.getItem() instanceof ItemShears)
{
EntitySheep sheep = (EntitySheep) event.getTarget();
if(!sheep.isShearable(tool,world,pos))
return;
java.util.Random rand = new java.util.Random();
for(ItemStack stack : InteractionBWM.convertShearedWool(sheep.onSheared(tool,world,pos, EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE,tool))))
{
EntityItem ent = sheep.entityDropItem(stack, 1.0F);
ent.motionY += rand.nextFloat() * 0.05F;
ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
}
tool.damageItem(1, player);
event.setCanceled(true);
event.setCancellationResult(EnumActionResult.SUCCESS);
}
}
示例13: giveShears
import net.minecraft.item.ItemShears; //导入依赖的package包/类
public boolean giveShears(EntityMinionWorker worker) {
if(worker.getHeldItemMainhand() == null){
int[] slots = this.inventory.getRawIndices(RelativeSide.BOTTOM);
for(int i = 0; i < slots.length; i++){
int slot = slots[i];
ItemStack shears = inventory.getStackInSlot(slot);
if(ItemStackTools.isValid(shears) && shears.getItem() instanceof ItemShears && !ToolUtil.isEmptyRfTool(shears)){
worker.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, shears);
this.inventory.setInventorySlotContents(slot, ItemStackTools.getEmptyStack());
return true;
}
}
}
return false;
}
示例14: onPlayerInteractionWithEntity
import net.minecraft.item.ItemShears; //导入依赖的package包/类
@SuppressWarnings({"ConstantConditions", "MethodWithMoreThanThreeNegations"})
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerInteractionWithEntity(EntityInteract event)
{
//Process for shearing a sheep
if (event.getWorld().isRemote) return;
if (event.getHand() != EnumHand.MAIN_HAND) return;
if (!(event.getTarget() instanceof EntitySheep)) return;
final ItemStack itemStack = event.getItemStack();
if (itemStack == null) {
checkSpecialSheepInteraction(event);
return;
}
if (!(itemStack.getItem() instanceof ItemShears)) return;
final EntitySheep sheep = (EntitySheep) event.getTarget();
if (!sheep.isShearable(itemStack, event.getWorld(), event.getPos())) return;
final IChiseledSheepCapability capability = sheep.getCapability(Capability.CHISELED_SHEEP, null);
if (capability == null) return;
if (!capability.isChiseled()) return;
//Ok, we have a chiseled sheep, cancel vanilla.
event.setCanceled(true);
Shearing.shearSheep(itemStack, sheep, capability);
}
示例15: getRemainingItems
import net.minecraft.item.ItemShears; //导入依赖的package包/类
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
ItemStack[] ret = new ItemStack[inv.getSizeInventory()];
for (int i = 0; i < ret.length; i++) {
ItemStack is = inv.getStackInSlot(i);
if (is == null) continue;
if (is.getItem() instanceof ItemShears) {
ItemStack s = is.copy();
if (!s.attemptDamageItem(1, rng)) {
ret[i] = s;
}
}
}
return ret;
}