Java Code Examples for net.minecraft.entity.player.EntityPlayer#sendMessage()

The following examples show how to use net.minecraft.entity.player.EntityPlayer#sendMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemTofuSlimeRadar.java    From TofuCraftReload with MIT License 7 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
	 boolean flag = playerIn.capabilities.isCreativeMode;

        if (flag || playerIn.getHeldItem(handIn).getItemDamage() <= playerIn.getHeldItem(handIn).getMaxDamage())
        {
            if (!worldIn.isRemote)
            {
                boolean isSpawnChunk = playerIn.dimension == TofuMain.TOFU_DIMENSION.getId() || EntityTofuSlime.isSpawnChunk(playerIn.world, playerIn.posX, playerIn.posZ);
            
                if(isSpawnChunk) playerIn.sendMessage(new TextComponentTranslation("tofucraft.radar.result.success", new Object()));
                else playerIn.sendMessage(new TextComponentTranslation("tofucraft.radar.result.failed", new Object()));
            }

            if (!playerIn.capabilities.isCreativeMode && playerIn.getHeldItem(handIn).isItemStackDamageable())
            {
            	playerIn.getHeldItem(handIn).damageItem(1, playerIn);
            }
            playerIn.playSound(SoundEvents.UI_BUTTON_CLICK, 0.5F, 1.0F);
        }
	return super.onItemRightClick(worldIn, playerIn, handIn);
}
 
Example 2
Source File: ChatMsgHandler.java    From BakaDanmaku with MIT License 6 votes vote down vote up
/**
 * 欢迎玩家进入
 *
 * @param e 玩家进入事件
 */
@SubscribeEvent
public static void welcome(WelcomeEvent e) {
    EntityPlayer player = Minecraft.getMinecraft().player;
    Pattern readWelcome = Pattern.compile(BakaDanmakuConfig.blockFunction.blockWelcome); // 屏蔽欢迎玩家

    // 先判定是否显示欢迎信息
    if (player != null && BakaDanmakuConfig.chatMsg.showWelcome) {
        // 进行玩家屏蔽
        Matcher mWelcome = readWelcome.matcher(e.getUser());
        // 没找到,或者对应列表为空
        if (!mWelcome.find() || BakaDanmakuConfig.blockFunction.blockWelcome.isEmpty()) {
            player.sendMessage(new TextComponentString(String.format(BakaDanmakuConfig.chatMsg.welcomeStyle,
                    e.getPlatform(), e.getUser())));
        }
    }
}
 
Example 3
Source File: ChatMsgHandler.java    From BakaDanmaku with MIT License 6 votes vote down vote up
/**
 * 发送礼物
 *
 * @param e 发送礼物事件
 */
@SubscribeEvent
public static void receiveGift(GiftEvent e) {
    EntityPlayer player = Minecraft.getMinecraft().player;
    Pattern readGiftName = Pattern.compile(BakaDanmakuConfig.blockFunction.blockGift); // 屏蔽礼物

    // 先判定是否开启礼物显示
    if (player != null && BakaDanmakuConfig.chatMsg.showGift) {
        // 进行礼物屏蔽
        Matcher mGift = readGiftName.matcher(e.getGiftName());
        // 没找到,或者对应列表为空
        if (!mGift.find() || BakaDanmakuConfig.blockFunction.blockGift.isEmpty()) {
            player.sendMessage(new TextComponentString(String.format(BakaDanmakuConfig.chatMsg.giftStyle,
                    e.getPlatform(), e.getUser(), e.getGiftName(), e.getNum())));
        }
    }
}
 
Example 4
Source File: ItemTicket.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand){
    ItemStack stack = player.getHeldItem(hand);
    if(!world.isRemote) {
        TileEntity te = world.getTileEntity(pos);
        if(te instanceof TileEntityStationMarker) {
            TileEntityStationMarker stationMarker = (TileEntityStationMarker)te;
            String stationName = stationMarker.getStationName();

            appendDestination(stack, stationName);

            String concatDestinations = getConcattedDestinations(stack);
            player.sendMessage(new TextComponentTranslation("signals.message.added_destination", TextFormatting.GOLD + stationName + TextFormatting.WHITE, TextFormatting.GOLD + concatDestinations + TextFormatting.WHITE));

            return EnumActionResult.SUCCESS;
        }
    }
    return super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand);
}
 
Example 5
Source File: SimpleMachineMetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean onScrewdriverClick(EntityPlayer playerIn, EnumHand hand, EnumFacing facing, CuboidRayTraceResult hitResult) {
    if(facing == getOutputFacing()) {
        if(!getWorld().isRemote) {
            if(allowInputFromOutputSide) {
                setAllowInputFromOutputSide(false);
                playerIn.sendMessage(new TextComponentTranslation("gregtech.machine.basic.input_from_output_side.disallow"));
            } else {
                setAllowInputFromOutputSide(true);
                playerIn.sendMessage(new TextComponentTranslation("gregtech.machine.basic.input_from_output_side.allow"));
            }
        }
        return true;
    }
    return super.onScrewdriverClick(playerIn, hand, facing, hitResult);
}
 
Example 6
Source File: ItemTicket.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand){
    if(!worldIn.isRemote) {
        ItemStack stack = playerIn.getHeldItem(hand);
        if(playerIn.isSneaking()) {
            setDestinations(stack, Collections.emptyList());
            stack.clearCustomName();
            playerIn.sendMessage(new TextComponentTranslation("signals.message.cleared_ticket"));
        } else {
            playerIn.openGui(Signals.instance, CommonProxy.EnumGuiId.TICKET_DESTINATION.ordinal(), worldIn, 0, 0, 0);
        }

    }
    return super.onItemRightClick(worldIn, playerIn, hand);
}
 
Example 7
Source File: BlockNetworkDisplay.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state,
    EntityPlayer playerIn,
    EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        TileEntity tile = worldIn.getTileEntity(pos);
        if (tile instanceof TileEntityNetworkDisplay) {
            TileEntityNetworkDisplay displayTile = (TileEntityNetworkDisplay) tile;
            Iterable<IVSNode> networkedObjects = displayTile.getNetworkedConnections();
            List<IVSNode> connectedNodes = new ArrayList<IVSNode>();
            Map<String, Integer> networkedClassTypeCounts = new HashMap<String, Integer>();
            for (IVSNode node : networkedObjects) {
                connectedNodes.add(node);
                Class nodeClass = node.getParentTile().getClass();
                String tileClassName = nodeClass.getSimpleName();
                if (!networkedClassTypeCounts.containsKey(tileClassName)) {
                    networkedClassTypeCounts.put(tileClassName, 0);
                }
                networkedClassTypeCounts
                    .put(tileClassName, networkedClassTypeCounts.get(tileClassName) + 1);
            }
            playerIn.sendMessage(new TextComponentString(
                "Networked objects connected: " + connectedNodes.size()));
            playerIn.sendMessage(new TextComponentString(
                "Types of objects connected: " + networkedClassTypeCounts.toString()));
        }
    }
    return true;
}
 
Example 8
Source File: TileLandingPad.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public boolean onLinkComplete(ItemStack item, TileEntity entity,
		EntityPlayer player, World world) {

	TileEntity tile = world.getTileEntity(ItemLinker.getMasterCoords(item));

	if(tile instanceof IInfrastructure) {
		HashedBlockPosition pos = new HashedBlockPosition(tile.getPos());
		if(!blockPos.contains(pos)) {
			blockPos.add(pos);
		}

		AxisAlignedBB bbCache =  new AxisAlignedBB(this.getPos().add(-1,0,-1), this.getPos().add(1,2,1));


		List<EntityRocketBase> rockets = world.getEntitiesWithinAABB(EntityRocketBase.class, bbCache);
		for(EntityRocketBase rocket : rockets) {
			rocket.linkInfrastructure((IInfrastructure) tile);
		}


		if(!world.isRemote) {
			player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.success")));

			if(tile instanceof IMultiblock)
				((IMultiblock)tile).setMasterBlock(getPos());
		}

		ItemLinker.resetPosition(item);
		return true;
	}
	return false;
}
 
Example 9
Source File: ToroQuestCommand.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private void listCommand(EntityPlayer player, String[] args) throws CommandException {
	List<Province> provinces = CivilizationsWorldSaveData.get(player.world).getProvinces();
	StringBuilder sb = new StringBuilder();
	for (Province province : provinces) {
		sb.append(province.toString()).append("\n");
	}
	player.sendMessage(new TextComponentString(sb.toString()));
}
 
Example 10
Source File: MetaTileEntityTransformer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing facing, CuboidRayTraceResult hitResult) {
    ItemStack itemStack = playerIn.getHeldItem(hand);
    if(!itemStack.isEmpty() && itemStack.hasCapability(GregtechCapabilities.CAPABILITY_MALLET, null)) {
        ISoftHammerItem softHammerItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_MALLET, null);

        if (getWorld().isRemote) {
            return true;
        }
        if(!softHammerItem.damageItem(DamageValues.DAMAGE_FOR_SOFT_HAMMER, false)) {
            return false;
        }

        if (isTransformUp) {
            setTransformUp(false);
            playerIn.sendMessage(new TextComponentTranslation("gregtech.machine.transformer.message_transform_down",
                energyContainer.getInputVoltage(), energyContainer.getInputAmperage(), energyContainer.getOutputVoltage(), energyContainer.getOutputAmperage()));
            return true;
        } else {
            setTransformUp(true);
            playerIn.sendMessage(new TextComponentTranslation("gregtech.machine.transformer.message_transform_up",
                energyContainer.getInputVoltage(), energyContainer.getInputAmperage(), energyContainer.getOutputVoltage(), energyContainer.getOutputAmperage()));
            return true;
        }
    }
    return false;
}
 
Example 11
Source File: ItemUpgradeDirectional.java    From BetterChests with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
	ItemStack stack = player.getHeldItem(hand);
	if (!world.isRemote) {
		setSide(stack, null);
		player.sendMessage(ServerUtil.getChatForString(getTooltipName(stack)));
	}
	return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
 
Example 12
Source File: ItemSealDetector.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player,
		World world, BlockPos pos, EnumHand hand, EnumFacing facing,
		float hitX, float hitY, float hitZ) {
       if (!world.isRemote)
       {
           if (SealableBlockHandler.INSTANCE.isBlockSealed(world, pos))
           {
               player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.sealdetector.sealed")));
           }
           else
           {
           	IBlockState state = world.getBlockState(pos);
               Material mat = state.getMaterial();
               if (SealableBlockHandler.INSTANCE.isMaterialBanned(mat))
               {
                   player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.sealdetector.notsealmat")));
               }
               else if (SealableBlockHandler.INSTANCE.isBlockBanned(state.getBlock()))
               {
                   player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.sealdetector.notsealblock")));
               }
               else if (SealableBlockHandler.isFulBlock(world, pos))
               {
                   player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.sealdetector.notfullblock")));
               }
               else if (state.getBlock() instanceof IFluidBlock)
               {
                   player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.sealdetector.fluid")));
               }
               else
               {
                   player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.sealdetector.other")));
               }
           }
       }
       return EnumActionResult.SUCCESS;
}
 
Example 13
Source File: EntityRocket.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
protected boolean interact(EntityPlayer player) {
	//Actual interact code needs to be moved to a packet receive on the server

	ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);

	//Handle linkers and right-click with fuel
	if(heldItem != null) {
		float fuelMult;
		FluidStack fluidStack;

		if(heldItem.getItem() instanceof ItemLinker) {
			if(ItemLinker.isSet(heldItem)) {


				TileEntity tile = this.world.getTileEntity(ItemLinker.getMasterCoords(heldItem));

				if(tile instanceof IInfrastructure) {
					IInfrastructure infrastructure = (IInfrastructure)tile;
					if(this.getDistance(ItemLinker.getMasterX(heldItem), this.posY, ItemLinker.getMasterZ(heldItem)) < infrastructure.getMaxLinkDistance() + Math.max(storage.getSizeX(), storage.getSizeZ())) {
						if(!connectedInfrastructure.contains(tile)) {

							linkInfrastructure(infrastructure);
							if(!world.isRemote) {
								player.sendMessage(new TextComponentString("Linked Sucessfully"));
							}
							ItemLinker.resetPosition(heldItem);

							return true;
						}
						else if(!world.isRemote)
							player.sendMessage(new TextComponentString("Already linked!"));
					}
					else if(!world.isRemote)
						player.sendMessage(new TextComponentString("The object you are trying to link is too far away"));
				}
				else if(!world.isRemote)
					player.sendMessage(new TextComponentString("This cannot be linked to a rocket!"));
			}
			else if(!world.isRemote)
				player.sendMessage(new TextComponentString("Nothing to be linked"));
			return false;
		}

		else if((FluidUtils.containsFluid(heldItem) && (fluidStack = FluidUtils.getFluidForItem(heldItem)) != null && (fuelMult = FuelRegistry.instance.getMultiplier(FuelType.LIQUID, fluidStack.getFluid())) > 0 )) { 


			int amountToAdd = (int) (fuelMult*fluidStack.amount);
			this.addFuelAmount(amountToAdd);

			//if the player is not in creative then try to use the fluid container
			if(!player.capabilities.isCreativeMode) {
				heldItem = heldItem.copy();
				heldItem.setCount(1);
				IFluidHandlerItem handler = FluidUtils.getFluidHandler(heldItem);
				handler.drain(fluidStack.amount, true);
				ItemStack emptyStack = handler.getContainer();

				if(player.inventory.addItemStackToInventory(emptyStack)) {
					player.getHeldItem(EnumHand.MAIN_HAND).splitStack(1);
					if(player.getHeldItem(EnumHand.MAIN_HAND).isEmpty())
						player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY); 
				}

			}

			return true;
		}
	}

	//If player is holding shift open GUI
	if(player.isSneaking()) {
		openGui(player);
	}
	else if(stats.hasSeat()) { //If pilot seat is open mount entity there
		if(stats.hasSeat() && this.getPassengers().isEmpty()) {
			if(!world.isRemote)
				player.startRiding(this);
		}
		/*else if(stats.getNumPassengerSeats() > 0) { //If a passenger seat exists and one is empty, mount the player to it
			for(int i = 0; i < stats.getNumPassengerSeats(); i++) {
				if(this.mountedEntities[i] == null || this.mountedEntities[i].get() == null) {
					player.ridingEntity = this;
					this.mountedEntities[i] = new WeakReference<Entity>(player);
					break;
				}
			}
		}*/
	}
	return true;
}
 
Example 14
Source File: BlockLogNatural.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
{
	if(world.isRemote)
		return true;

	//get our item parameters
	ItemStack stack = player.getHeldItemMainhand();
	int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
	int maxCut = 0;
	if(stack.getItem() instanceof ItemAxe)
	{
		maxCut = ((ItemAxe)stack.getItem()).maxTreeSize;
	}
	else return false;

	//create the map of our tree
	BlockPosList tree = BlockLogNatural.getTreeForCut(world, pos);
	int count = tree.size();

	//if the tree has too many blocks then prevent chopping
	if(count > maxCut)
	{
		player.sendMessage(new TextComponentTranslation(Core.translate("gui.axe.treetoobig")));
		return false;
	}
	else if(count > stack.getMaxDamage() - stack.getItemDamage())
	{
		player.sendMessage(new TextComponentTranslation(Core.translate("gui.axe.needsrepair")));
		return false;
	}
	else
	{
		for(BlockPos p : tree)
		{
			IBlockState s = world.getBlockState(p);
			this.onBlockHarvested(world, pos, s, player);
			world.setBlockToAir(p);
			s.getBlock().dropBlockAsItem(world, p, s, fortune);
		}
	}
	stack.damageItem(count-1, player);

	return true;
}
 
Example 15
Source File: VersionChecker.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onTick(TickEvent.ClientTickEvent event) {
	if (!ConfigValues.versionCheckerEnabled) return;

	EntityPlayer player = Minecraft.getMinecraft().player;

	if (doneChecking && event.phase == TickEvent.Phase.END && player != null && !triedToWarnPlayer) {
		ITextComponent component = new TextComponentString("[").setStyle(new Style().setColor(TextFormatting.GREEN))
				.appendSibling(new TextComponentTranslation("wizardry.misc.update_link").setStyle(new Style().setColor(TextFormatting.GRAY)))
				.appendSibling(new TextComponentString("]").setStyle(new Style().setColor(TextFormatting.GREEN)));
		component.getStyle()
				.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(updateMessage)))
				.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://minecraft.curseforge.com/projects/wizardry-mod/files"));

		if (onlineVersion != null && !onlineVersion.isEmpty()) {
			String clientBuild = Wizardry.VERSION;
			if (Utils.compareVersions(onlineVersion, clientBuild) > 0) {
				ArrayList<String> messages = new ArrayList<>();
				String base = "wizardry.update";
				int n = 0;
				while (LibrarianLib.PROXY.canTranslate(base + n))
					messages.add(base + n++);

				if (!messages.isEmpty())
					player.sendMessage(new TextComponentTranslation(messages.get(RandUtil.nextInt(messages.size() - 1))).setStyle(new Style().setColor(TextFormatting.YELLOW)));
				player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker0")
						.setStyle(new Style().setColor(TextFormatting.GREEN)));
				player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker1")
						.setStyle(new Style().setColor(TextFormatting.GREEN))
						.appendText(" ")
						.appendSibling(new TextComponentString(clientBuild).setStyle(new Style().setColor(TextFormatting.RED))));
				player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker2")
						.setStyle(new Style().setColor(TextFormatting.GREEN))
						.appendText(" ")
						.appendSibling(new TextComponentString(onlineVersion).setStyle(new Style().setColor(TextFormatting.YELLOW))));

				if (updateMessage != null && !updateMessage.isEmpty())
					player.sendMessage(component);
			} else if (updateMessage != null && !updateMessage.isEmpty())
				player.sendMessage(component);
		}

		triedToWarnPlayer = true;
	}
}
 
Example 16
Source File: EntityShopkeeper.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private void chat(EntityPlayer player, String message) {
	player.sendMessage(new TextComponentString(message));
}
 
Example 17
Source File: DebugModeIGrowable.java    From AgriCraft with MIT License 4 votes vote down vote up
@Override
public void debugActionBlockClicked(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return;
    }

    // Start with the position of the block that was clicked on. '7' is gray. Btw, the chat font is not fixed width. :(
    StringBuilder outputRaw = new StringBuilder(String.format("`7%1$4d,%2$4d,%3$4d`r ", pos.getX(), pos.getY(), pos.getZ()));

    // Check if the clicked on block has the IGrowable interface.
    final IGrowable crop = WorldHelper.getBlock(world, pos, IGrowable.class).orElse(null);
    if (crop == null) {
        // If it does not, add a nicely formatted report, then skip onward.
        outputRaw.append(chatNotIG);
    } else {
        // Otherwise run the tests and record the results.
        IBlockState state = world.getBlockState(pos);
        outputRaw.append(crop.canGrow(world, pos, state, false) ? chatTrue : chatFalse); // canGrow
        outputRaw.append(crop.canUseBonemeal(world, world.rand, pos, state) ? chatTrue : chatFalse); // canUseBonemeal
        crop.grow(world, world.rand, pos, state);                                                    // grow

        // It's also helpful to also make clear what block was being tested.
        outputRaw.append("`3"); // '3' is dark aqua.
        outputRaw.append(crop.toString().replaceFirst("Block", ""));
        outputRaw.append("`r");
    }

    // Ellipsis are added as a clue that there's more text.
    outputRaw.append(" `8[...]`r"); // '8' is dark gray.

    // Create a hover box with explanatory information.
    TextComponentString hoverComponent = new TextComponentString(MessageUtil.colorize(chatInfo));
    HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent);

    // Turn the output String into a chat message.
    TextComponentString outputComponent = new TextComponentString(MessageUtil.colorize(outputRaw.toString()));

    // Add the hover box to the chat message.
    outputComponent.getStyle().setHoverEvent(hoverEvent);

    // Now send the completed chat message.
    player.sendMessage(outputComponent);
}
 
Example 18
Source File: BlockLogNatural2.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
{
	if(world.isRemote)
		return true;

	//get our item parameters
	ItemStack stack = player.getHeldItemMainhand();
	int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
	int maxCut = 0;
	if(stack.getItem() instanceof ItemAxe)
	{
		maxCut = ((ItemAxe)stack.getItem()).maxTreeSize;
	}
	else return false;

	//create the map of our tree
	BlockPosList tree = BlockLogNatural.getTreeForCut(world, pos);
	int count = tree.size();

	//if the tree has too many blocks then prevent chopping
	if(count > maxCut)
	{
		player.sendMessage(new TextComponentTranslation(Core.translate("gui.axe.treetoobig")));
		return false;
	}
	else if(count > stack.getMaxDamage() - stack.getItemDamage())
	{
		player.sendMessage(new TextComponentTranslation(Core.translate("gui.axe.needsrepair")));
		return false;
	}
	else
	{
		for(BlockPos p : tree)
		{
			IBlockState s = world.getBlockState(p);
			this.onBlockHarvested(world, pos, s, player);
			world.setBlockToAir(p);
			s.getBlock().dropBlockAsItem(world, p, s, fortune);
		}
	}
	stack.damageItem(count-1, player);

	return true;
}
 
Example 19
Source File: BlockFuton.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
	if (worldIn.isRemote) {
		return true;
	}
	if (state.getValue(PART) != EnumPartType.HEAD) {
		pos = pos.offset(state.getValue(FACING));
		state = worldIn.getBlockState(pos);

		if (state.getBlock() != this) {
			return true;
		}
	}

	if (worldIn.provider.canRespawnHere() && worldIn.getBiome(pos) != Biomes.HELL) {
		if (state.getValue(OCCUPIED).booleanValue()) {
			EntityPlayer entityplayer = this.getPlayerInBlanket(worldIn, pos);

			if (entityplayer != null) {
				playerIn.sendMessage(new TextComponentTranslation("tile.bed.occupied"));
				return true;
			}

			state = state.withProperty(OCCUPIED, Boolean.valueOf(false));
			worldIn.setBlockState(pos, state, 4);
		}

		EntityPlayer.SleepResult entityplayer$sleepresult = playerIn.trySleep(pos);

		if (entityplayer$sleepresult == EntityPlayer.SleepResult.OK) {
			state = state.withProperty(OCCUPIED, Boolean.valueOf(true));
			worldIn.setBlockState(pos, state, 4);
			return true;
		}
		if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_POSSIBLE_NOW) {
			playerIn.sendMessage(new TextComponentTranslation("tile.bed.noSleep"));
		} else if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_SAFE) {
			playerIn.sendMessage(new TextComponentTranslation("tile.bed.notSafe"));
		}

		return true;
	}
	worldIn.setBlockToAir(pos);
	BlockPos blockpos = pos.offset(state.getValue(FACING).getOpposite());

	if (worldIn.getBlockState(blockpos).getBlock() == this) {
		worldIn.setBlockToAir(blockpos);
	}

	worldIn.newExplosion(null, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, 5.0F, true, true);
	return true;
}
 
Example 20
Source File: TileWirelessTransciever.java    From AdvancedRocketry with MIT License 3 votes vote down vote up
@Override
public boolean onLinkStart(ItemStack item, TileEntity entity, EntityPlayer player, World world) {

	ItemLinker.setMasterCoords(item, getPos());
	
	if(!world.isRemote)
		player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.program")));

	return true;
}